Ignore:
Timestamp:
Nov 8, 2018, 9:00:00 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
80228a7
Parents:
f1aeede
Message:

switch to sout from printf

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/fallthrough.cfa

    rf1aeede r303d866  
    1010// Created On       : Wed Mar 14 10:06:25 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Nov  6 17:53:32 2018
    13 // Update Count     : 15
     12// Last Modified On : Thu Nov  8 09:09:09 2018
     13// Update Count     : 16
    1414//
     15
     16#include <fstream.hfa>
    1517
    1618void test(int choice) {
    1719        choose ( choice ) {
    1820                case 1:
    19                         printf("case 1\n");
     21                        sout | "case 1" | endl;
    2022                        fallthru;
    2123                case 2:
    22                         printf("case 2\n");
     24                        sout | "case 2" | endl;
    2325                        fallthru;
    24                         printf("did not fallthru\n");
     26                        sout | "did not fallthru" | endl;
    2527                        if ( 7 ) fallthru common2;
    2628                        fallthru common1;
    2729                case 3:
    28                         printf("case 3\n");
     30                        sout | "case 3" | endl;
    2931                        fallthru default;
    3032                        fallthru common1;
    3133                common1:
    32                         printf("common1\n");
     34                        sout | "common1" | endl;
    3335                // break
    3436                case 4:
    35                         printf("case 4\n");
     37                        sout | "case 4" | endl;
    3638                        fallthru common2;
    3739                case 5:
    38                         printf("case 5\n");
     40                        sout | "case 5" | endl;
    3941                        fallthru common2;
    4042                        fallthru default;
    4143                case 6:
    42                         printf("case 6\n");
     44                        sout | "case 6" | endl;
    4345                        fallthru common2;
    4446                common2:
    45                         printf("common2\n");
     47                        sout | "common2" | endl;
    4648                // break
    4749                default:
    48                         printf("default\n");
     50                        sout | "default" | endl;
    4951                        fallthru;
    5052        }
    5153
    52         printf("\n");
     54        sout | endl;
    5355
    5456        switch ( choice ) {
    5557          case 1:
    56                 printf("case 1\n");
     58                sout | "case 1" | endl;
    5759                switch ( choice ) {
    5860                  case 1:
    59                         printf("case 1\n");
     61                        sout | "case 1" | endl;
    6062                        for ( int i = 0; i < 4; i += 1 ) {
    6163                                printf("%d\n", i);
     
    6567                break;
    6668          case 5:
    67                 printf("case 5\n");
     69                sout | "case 5" | endl;
    6870                if ( choice == 5 ) {
    6971                        if ( choice != 5 ) {
    70                                 printf("error\n");
     72                                sout | "error" | endl;
    7173                        } else {
    72                                 printf("check\n");
     74                                sout | "check" | endl;
    7375                                fallthru common;
    7476                        } // if
     
    114116
    115117int main() {
    116         test(1);
    117         printf("\n");
    118         test(5);
     118        test( 1 );
     119        sout | endl;
     120        test( 5 );
    119121}
    120122
Note: See TracChangeset for help on using the changeset viewer.