- Timestamp:
- May 23, 2017, 9:55:37 AM (9 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, resolv-new, with_gc
- Children:
- 27dde72
- Parents:
- 547e9b7 (diff), 935315d (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:
-
- 2 added
- 2 edited
- 1 moved
-
.expect/64/gmp.txt (moved) (moved from src/tests/.expect/gmp.txt ) (2 diffs)
-
.expect/complex.txt (added)
-
complex.c (added)
-
gmp.c (modified) (5 diffs)
-
tuplePolymorphism.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/.expect/64/gmp.txt
r547e9b7 reb182b0 4 4 conversions 5 5 y:97 6 y:12345678901234567890123456789 6 7 y:3 7 8 y:-3 … … 24 25 z:150000000000000000000 25 26 z:16666666666666666666 27 16666666666666666666, 2 16666666666666666666, 2 26 28 x:16666666666666666666 y:2 27 29 -
src/tests/gmp.c
r547e9b7 reb182b0 10 10 // Created On : Tue Apr 19 08:55:51 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 14 14:46:50201713 // Update Count : 53 012 // Last Modified On : Mon May 22 09:05:09 2017 13 // Update Count : 538 14 14 // 15 15 16 16 #include <gmp> 17 17 18 int main( ) {18 int main( void ) { 19 19 sout | "constructors" | endl; 20 20 short int si = 3; … … 25 25 sout | "conversions" | endl; 26 26 y = 'a'; 27 sout | "y:" | y | endl; 28 y = "12345678901234567890123456789"; 27 29 sout | "y:" | y | endl; 28 30 y = si; … … 62 64 z = x / 3; 63 65 sout | "z:" | z | endl; 66 sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl; 64 67 [ x, y ] = div( x, 3 ); 65 68 sout | "x:" | x | "y:" | y | endl; 66 // sout | div( x, 3 ) | x / 3 | "," | x % 3 | endl;67 69 68 70 sout | endl; … … 72 74 fn = (Int){0}; fn1 = fn; // 1st case 73 75 sout | (int)0 | fn | endl; 74 fn = (Int){1}; fn2 = fn1; fn1 = fn;// 2nd case76 fn = 1; fn2 = fn1; fn1 = fn; // 2nd case 75 77 sout | 1 | fn | endl; 76 for ( int i = 2; i <= 200; i += 1 ) {78 for ( unsigned int i = 2; i <= 200; i += 1 ) { 77 79 fn = fn1 + fn2; fn2 = fn1; fn1 = fn; // general case 78 80 sout | i | fn | endl; … … 83 85 sout | "Factorial Numbers" | endl; 84 86 Int fact; 85 fact = (Int){1};// 1st case87 fact = 1; // 1st case 86 88 sout | (int)0 | fact | endl; 87 for ( int i = 1; i <= 40; i += 1 ) {89 for ( unsigned int i = 1; i <= 40; i += 1 ) { 88 90 fact = fact * i; // general case 89 91 sout | i | fact | endl; -
src/tests/tuplePolymorphism.c
r547e9b7 reb182b0 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Nov 16 10:38:00 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T ue Nov 16 10:39:18 201613 // Update Count : 211 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 18 18:05:12 2017 13 // Update Count : 4 14 14 // 15 15 16 16 // packed is needed so that structs are not passed with the same alignment as function arguments 17 17 __attribute__((packed)) struct A { 18 double x;19 char y;20 double z;18 double x; 19 char y; 20 double z; 21 21 }; 22 22 23 23 __attribute__((packed)) struct B { 24 long long x;25 char y;26 long long z;24 long long x; 25 char y; 26 long long z; 27 27 }; 28 28 … … 39 39 40 40 int main() { 41 int x1 = 123, x3 = 456;42 double x2 = 999.123;41 int x1 = 123, x3 = 456; 42 double x2 = 999.123; 43 43 44 int i1 = 111, i3 = 222;45 double i2 = 333;44 int i1 = 111, i3 = 222; 45 double i2 = 333; 46 46 47 int d1 = 555, d3 = 444;48 double d2 = 666;47 int d1 = 555, d3 = 444; 48 double d2 = 666; 49 49 50 50 51 [i1, i2, i3] = ([x1, (int)x2, x3]) + ([9, 2, 3]);52 [d1, d2, d3] = ([x1, x2, x3]) + ([9, 2, 3]);53 printf("%d %g %d\n", i1, i2, i3);54 printf("%d %g %d\n", d1, d2, d3);51 [i1, i2, i3] = ([x1, (int)x2, x3]) + ([9, 2, 3]); 52 [d1, d2, d3] = ([x1, x2, x3]) + ([9, 2, 3]); 53 printf("%d %g %d\n", i1, i2, i3); 54 printf("%d %g %d\n", d1, d2, d3); 55 55 56 [double, double, double] zzz;57 zzz = [x1, x2, x3];58 printf("%g %g %g\n", zzz);59 [x1, x2, x3] = zzz+zzz;60 printf("%d %g %d\n", x1, x2, x3);56 [double, double, double] zzz; 57 zzz = [x1, x2, x3]; 58 printf("%g %g %g\n", zzz); 59 [x1, x2, x3] = zzz+zzz; 60 printf("%d %g %d\n", x1, x2, x3); 61 61 62 // ensure non-matching assertions are specialized correctly63 g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL });62 // ensure non-matching assertions are specialized correctly 63 g((A){ 1.21, 'x', 10.21}, (B){ 1111LL, 'v', 54385938LL }); 64 64 } 65 65 … … 73 73 // tab-width: 4 // 74 74 // End: // 75
Note:
See TracChangeset
for help on using the changeset viewer.