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