- Timestamp:
- Jun 5, 2018, 3:35:49 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- beefc34c
- Parents:
- 41770ed1 (diff), dafdbe7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/tests
- Files:
-
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/tests/.expect/ifwhileCtl.txt
r41770ed1 r174845e 3 3 x == y correct 4 4 s.i < 4 correct 5 x != 0 correct 6 x == y correct 7 s.i < 4 correct -
src/tests/ifwhileCtl.c
r41770ed1 r174845e 10 10 // Created On : Sat Aug 26 10:13:11 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 2 09:55:02201813 // Update Count : 1 512 // Last Modified On : Mon Jun 4 22:46:48 2018 13 // Update Count : 19 14 14 // 15 15 … … 42 42 43 43 if ( struct S { int i; } s = { 3 }; s.i < 4 ) { 44 S s1; 44 45 sout | "s.i < 4 correct" | endl; 45 46 } else { 47 S s1; 46 48 sout | "s.i >= 4 incorrect" | endl; 47 49 } // if 50 51 while ( int x = 1 ) { 52 sout | "x != 0 correct" | endl; 53 break; 54 } // while 55 56 while ( int x = 4, y = 0 ) { 57 sout | "x != 0 && y != 0 incorrect" | endl; 58 } // while 59 60 while ( int x = 5, y = f( x ); x == y ) { 61 sout | "x == y correct" | endl; 62 break; 63 } // while 64 65 while ( struct S { int i; } s = { 3 }; s.i < 4 ) { 66 S s1; 67 sout | "s.i < 4 correct" | endl; 68 break; 69 } // while 48 70 } // main 49 71 -
src/tests/sum.c
r41770ed1 r174845e 11 11 // Created On : Wed May 27 17:56:53 2015 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : S at Feb 17 11:49:17201814 // Update Count : 27 313 // Last Modified On : Sun Jun 3 19:23:41 2018 14 // Update Count : 278 15 15 // 16 16 … … 18 18 #include <stdlib> 19 19 20 void ?{}( int & c, zero_t ) { c = 0; } 20 void ?{}( int & c, zero_t ) { c = 0; } // not in prelude 21 21 22 22 trait sumable( otype T ) { 23 void ?{}( T &, zero_t ); // constructor from 0 literal23 void ?{}( T &, zero_t ); // 0 literal constructor 24 24 T ?+?( T, T ); // assortment of additions 25 25 T ?+=?( T &, T ); … … 29 29 30 30 forall( otype T | sumable( T ) ) // use trait 31 T sum( unsigned int size, T a[] ) {32 T total = 0; // in stantiate T from 0 by callingconstructor33 for ( unsigned int i = 0; i < size; i += 1 )31 T sum( size_t size, T a[] ) { 32 T total = 0; // initialize by 0 constructor 33 for ( size_t i = 0; i < size; i += 1 ) 34 34 total += a[i]; // select appropriate + 35 35 return total; … … 111 111 for ( int i = 0; i < size; i += 1, v += 1 ) { 112 112 s += (int)v; 113 gs.x[i] = (int)v; // set fi led array in generic type113 gs.x[i] = (int)v; // set field array in generic type 114 114 } // for 115 115 sout | "sum from" | low | "to" | High | "is" 116 | sum( size, gs.x ) | ", check" | (int)s | endl; // add fi led array in generic type116 | sum( size, gs.x ) | ", check" | (int)s | endl; // add field array in generic type 117 117 } // main 118 118
Note:
See TracChangeset
for help on using the changeset viewer.