Changeset 200fcb3 for tests/coroutine
- Timestamp:
- Dec 12, 2018, 9:16:12 AM (6 years ago)
- 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:
- 5ebb1368
- Parents:
- 3d99498
- Location:
- tests/coroutine
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/coroutine/.expect/fmtLines.txt ¶
r3d99498 r200fcb3 16 16 difi ed B y : Pete r A. 17 17 Buh r// Last Mod ifie 18 d On : M on S ep 1 8 1119 :3 5: 57 2 017/ / Up date20 Cou nt : 3 1/ /#in18 d On : T ue D ec 1 1 23 19 :31: 12 2 018/ / Up date 20 Cou nt : 32/ /#in 21 21 clud e <f stre am.h fa># 22 22 incl ude <cor outi ne.h … … 34 34 t ) { if ( fm t.g 35 35 != 0 || fmt. b != 0 ) 36 sou t | endl ;}vo id m 37 ain( For mat & fm t ) 38 { fo r ( ;; ) { 39 // f or a s ma ny c 40 hara cter s f or ( fmt 41 .g = 0; fmt. g < 5; f 42 mt.g += 1 ) { / / gr 43 oups of 5 bl ocks f 44 or ( fmt .b = 0; fmt. 45 b < 4; f mt.b += 1 ) 46 { // blo cks of 4 cha 47 ract ers f or ( ;; 48 ) { // for new 49 line cha ract ers 50 susp end( ); i f ( 51 fmt. ch ! = '\ n' ) bre 52 ak; // igno re n ewli 53 ne } // f or so 54 ut | fmt .ch; / 55 / pr int char acte r 56 } // for s out | " 57 "; / / pr int 58 bloc k se para tor } / 59 / fo r s out | en dl; 60 // p rint gro 61 up s epar ator } / / fo 62 r} / / ma invo id p rt( 63 Form at & fmt , ch ar c 64 h ) { fmt .ch = ch 65 ; res ume( fmt );} 66 // prti nt m ain( ) { 67 Form at f mt; char ch; 68 for ( ; ; ) { s in | 69 ch; // rea 70 d on e ch arac ter if 71 ( e of( sin ) ) brea 72 k; // eof ? p 73 rt( fmt, ch ); } // 74 for} // main // L ocal 75 Var iabl es: //// tab 76 -wid th: 4 // // c ompi 77 le-c omma nd: "cfa fmt 78 Line s.c" /// / En d: / 79 / 36 sou t | nl;} void mai 37 n( F orma t & fmt ) { 38 for ( ;; ) { 39 // for as many cha 40 ract ers for ( f mt.g 41 = 0 ; fm t.g < 5; fmt 42 .g + = 1 ) { // grou 43 ps o f 5 bloc ks for 44 ( f mt.b = 0 ; fm t.b 45 < 4; fmt .b + = 1 ) { 46 // b lock s of 4 c hara 47 cter s for ( ; ; ) 48 { // f or n ewli 49 ne c hara cter s su 50 spen d(); if ( fm 51 t.ch != '\n' ) b reak 52 ; / / ig nore new line 53 } // for sout 54 | f mt.c h; // 55 prin t ch arac ter } 56 // f or sou t | " " 57 ; // prin t bl 58 ock sepa rato r } // 59 for sou t | nl; 60 // p rint gro up s 61 epar ator } / / fo r} / 62 / ma invo id p rt( Form 63 at & fmt , ch ar c h ) 64 { fmt .ch = ch ; 65 res ume( fmt );} // 66 prti nt m ain( ) { Form 67 at f mt; char ch; for 68 ( ; ; ) { s in | ch; 69 // rea d on 70 e ch arac ter if ( e 71 of( sin ) ) brea k; 72 // eof ? p rt( 73 fmt, ch ); } // for} 74 // main // L ocal Var 75 iabl es: //// tab -wid 76 th: 4 // // c ompi le-c 77 omma nd: "cfa fmt Line 78 s.c" /// / En d: / / -
TabularUnified tests/coroutine/.in/fmtLines.txt ¶
r3d99498 r200fcb3 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Sep 18 11:35:57 201713 // Update Count : 3 112 // Last Modified On : Tue Dec 11 23:31:12 2018 13 // Update Count : 32 14 14 // 15 15 … … 27 27 28 28 void ^?{}( Format & fmt ) { 29 if ( fmt.g != 0 || fmt.b != 0 ) sout | endl;29 if ( fmt.g != 0 || fmt.b != 0 ) sout | nl; 30 30 } 31 31 … … 42 42 sout | " "; // print block separator 43 43 } // for 44 sout | endl; // print group separator44 sout | nl; // print group separator 45 45 } // for 46 46 } // main -
TabularUnified tests/coroutine/fibonacci.c ¶
r3d99498 r200fcb3 10 10 // Created On : Thu Jun 8 07:29:37 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:21:58201813 // Update Count : 2 412 // Last Modified On : Tue Dec 11 21:57:33 2018 13 // Update Count : 25 14 14 // 15 15 … … 39 39 Fibonacci f1, f2; 40 40 for ( 10 ) { // print N Fibonacci values 41 sout | next( f1 ) | next( f2 ) | endl;41 sout | next( f1 ) | next( f2 ); 42 42 } // for 43 43 } -
TabularUnified tests/coroutine/fibonacci_1.c ¶
r3d99498 r200fcb3 10 10 // Created On : Thu Apr 26 23:20:08 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:21:02201813 // Update Count : 1 312 // Last Modified On : Tue Dec 11 21:57:54 2018 13 // Update Count : 14 14 14 // 15 15 … … 36 36 Fibonacci f1, f2; 37 37 for ( 10 ) { // print N Fibonacci values 38 sout | next( f1 ) | next( f2 ) | endl;38 sout | next( f1 ) | next( f2 ); 39 39 } // for 40 40 } -
TabularUnified tests/coroutine/fmtLines.c ¶
r3d99498 r200fcb3 10 10 // Created On : Sun Sep 17 21:56:15 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:20:54201813 // Update Count : 4 512 // Last Modified On : Tue Dec 11 21:58:49 2018 13 // Update Count : 47 14 14 // 15 15 … … 34 34 sout | " "; // print block separator 35 35 } // for 36 sout | endl;// print group separator36 sout | nl; // print group separator 37 37 } // for 38 38 } // main … … 43 43 44 44 void ^?{}( Format & fmt ) with( fmt ) { 45 if ( g != 0 || b != 0 ) sout | endl;45 if ( g != 0 || b != 0 ) sout | nl; 46 46 } 47 47 … … 52 52 int main() { 53 53 Format fmt; 54 sout | nlOff; // turn off auto newline 54 55 55 56 eof: for () { // read until end of file -
TabularUnified tests/coroutine/pingpong.c ¶
r3d99498 r200fcb3 10 10 // Created On : Wed Sep 20 11:55:23 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 11:31:11201813 // Update Count : 2 812 // Last Modified On : Tue Dec 11 21:58:06 2018 13 // Update Count : 29 14 14 // 15 15 … … 40 40 void main( PingPong & pingpong ) { // ping's starter ::main, pong's starter ping 41 41 for ( pingpong.N ) { // N ping-pongs 42 sout | pingpong.name | endl;42 sout | pingpong.name; 43 43 cycle( *pingpong.part ); 44 44 } // for -
TabularUnified tests/coroutine/prodcons.c ¶
r3d99498 r200fcb3 10 10 // Created On : Mon Sep 18 12:23:39 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Aug 18 12:55:10201813 // Update Count : 5 112 // Last Modified On : Tue Dec 11 21:58:25 2018 13 // Update Count : 52 14 14 // 15 15 … … 32 32 int p1 = random( 100 ); 33 33 int p2 = random( 100 ); 34 sout | p1 | " " | p2 | endl;34 sout | p1 | " " | p2; 35 35 int status = delivery( *c, p1, p2 ); 36 sout | " $" | money | endl;37 sout | status | endl;36 sout | " $" | money; 37 sout | status; 38 38 receipt += 1; 39 39 } 40 40 stop( *c ); 41 sout | "prod stops" | endl;41 sout | "prod stops"; 42 42 } 43 43 int payment( Prod & prod, int money ) { … … 68 68 int money = 1, receipt; 69 69 for ( ; ! done; ) { 70 sout | p1 | " " | p2 | endl;71 sout | " $" | money | endl;70 sout | p1 | " " | p2; 71 sout | " $" | money; 72 72 status += 1; 73 73 receipt = payment( *p, money ); 74 sout | " #" | receipt | endl;74 sout | " #" | receipt; 75 75 money += 1; 76 76 } 77 sout | "cons stops" | endl;77 sout | "cons stops"; 78 78 } 79 79 int delivery( Cons & cons, int p1, int p2 ) { … … 92 92 srandom( /* getpid() */ 103 ); // fixed seed for testing 93 93 start( prod, 5, cons ); 94 sout | "main stops" | endl;94 sout | "main stops"; 95 95 } 96 96 -
TabularUnified tests/coroutine/runningTotal.c ¶
r3d99498 r200fcb3 10 10 // Created On : Wed Dec 6 08:05:27 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Aug 16 08:22:29201813 // Update Count : 312 // Last Modified On : Tue Dec 11 21:59:00 2018 13 // Update Count : 4 14 14 // 15 15 … … 42 42 RunTotal rntl; 43 43 for ( i; 10 ) { 44 sout | i | add( rntl, i ) | endl;44 sout | i | add( rntl, i ); 45 45 } // for 46 46 }
Note: See TracChangeset
for help on using the changeset viewer.