Changeset 7fe2498 for src/tests/tupleAssign.c
- Timestamp:
- Mar 7, 2017, 8:29:28 AM (8 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:
- a7c90d4
- Parents:
- 2988eeb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/tupleAssign.c
r2988eeb r7fe2498 9 9 // Author : Rob Schluntz 10 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Tue Nov 15 17:27:28 201613 // Update Count : 3 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 21:23:58 2017 13 // Update Count : 34 14 14 // 15 16 #include <fstream> 15 17 16 18 int main() { … … 21 23 22 24 // swap x, y and store the new [x, y] in [u, v] and in z; 23 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 25 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 26 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl; 24 27 z = [u, v] = [x, y] = [y, x]; 25 printf("u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z); 28 printf( "u=%d v=%d x=%d y=%d z=[%d, %d]\n", u, v, x, y, z ); 29 sout | "u=" | u | "v=" | v | "x=" | x | "y=" | y | "z=[" | z | "]" | endl; 26 30 27 31 // shuffle elements -- v = z.0, z.0 = z.1, z.1 = u, u = v 28 32 [v, z, u] = [z, u, v]; 29 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 33 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 34 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 30 35 31 36 // multiple assignment with tuple expression on right 32 37 z = [111, 222]; 33 38 [u, v] = [123, 456]; 34 printf("u=%d v=%d z=[%d, %d]\n", u, v, z); 39 printf( "u=%d v=%d z=[%d, %d]\n", u, v, z ); 40 sout | "u=" | u | "v=" | v | "z=[" | z | "]" | endl; 35 41 } 36 37 42 { 38 43 // test mass assignment … … 48 53 // no conversion from X to integral types, so this serves as a santiy 49 54 // check that as long as this compiles, ?=?(_, x) is not generated. 50 [t, x, d, i, c, x] = (double)-2153.12; 51 printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t); 52 [x, c, i, d, x, t] = (double)-2153.12; 53 printf("d=%lg i=%d c=%d t=[%d, %lg, %d]\n", d, i, (int)c, t); 55 [t, x, d, i, c, x] = (double)94.12; 56 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, (int)c, t ); 57 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl; 58 [x, c, i, d, x, t] = (double)-94.12; 59 printf( "d=%lg i=%d c=%c t=[%d, %lg, %d]\n", d, i, c, t ); 60 sout | "d=" | d | "i=" | i | "c=" | c | ' ' | "t=[" | t | "]" | endl; 54 61 } 55 62 }
Note: See TracChangeset
for help on using the changeset viewer.