- Timestamp:
- Jun 30, 2023, 1:48:33 PM (3 years ago)
- Branches:
- master
- Children:
- 4bae7b4
- Parents:
- c9019ce (diff), 48ee593 (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:
- tests
- Files:
-
- 5 edited
-
PRNG.cfa (modified) (9 diffs)
-
designations.cfa (modified) (13 diffs)
-
io/.expect/io.txt (modified) (1 diff)
-
io/io.cfa (modified) (6 diffs)
-
raii/dtor-early-exit.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/PRNG.cfa
rc9019ce r599dc6a 10 10 // Created On : Wed Dec 29 09:38:12 2021 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu May 25 15:39:52202313 // Update Count : 42 212 // Last Modified On : Thu Jun 29 10:18:35 2023 13 // Update Count : 424 14 14 // 15 15 … … 144 144 srand( rseed ); 145 145 146 sout | sep Disable;146 sout | sepOff; 147 147 sout | nl | wd(26, "rand()" ) | wd(12, "rand(5)") | wd(12, "rand(0,5)" ); 148 148 for ( 20 ) { … … 151 151 sout | wd(12, rand() % (5 - 0 + 1) + 0); 152 152 } // for 153 sout | sep Enable;153 sout | sepOn; 154 154 sout | "seed" | rseed; 155 155 … … 185 185 if ( seed != 0 ) set_seed( prng, seed ); 186 186 187 sout | sep Disable;187 sout | sepOff; 188 188 sout | nl | wd(26, "PRNG()" ) | wd(12, "PRNG(5)") | wd(12, "PRNG(0,5)" ); 189 189 for ( 20 ) { … … 192 192 sout | wd(12, prng( prng, 0, 5 )); 193 193 } // for 194 sout | sep Enable;194 sout | sepOn; 195 195 sout | "seed" | get_seed( prng ); 196 196 … … 220 220 if ( seed != 0 ) set_seed( seed ); 221 221 222 sout | sep Disable;222 sout | sepOff; 223 223 sout | nl | wd(26, "prng()" ) | wd(12, "prng(5)") | wd(12, "prng(0,5)" ); 224 224 for ( 20 ) { … … 227 227 sout | wd(12, prng( 0, 5 )); 228 228 } // for 229 sout | sep Enable;229 sout | sepOn; 230 230 sout | "seed" | get_seed( prng ); 231 231 … … 256 256 thread$ & th = *active_thread(); 257 257 258 sout | sep Disable;258 sout | sepOff; 259 259 sout | nl | wd(26, "prng(t)" ) | wd(12, "prng(t,5)") | wd(12, "prng(t,0,5)" ); 260 260 for ( 20 ) { … … 263 263 sout | wd(12, prng( th, 0, 5 )); 264 264 } // for 265 sout | sep Enable;265 sout | sepOn; 266 266 sout | "seed" | get_seed( prng ); 267 267 -
tests/designations.cfa
rc9019ce r599dc6a 10 10 // Created On : Thu Jun 29 15:26:36 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 28 22:41:55 2022 13 // Update Count : 15 14 // 12 // Last Modified On : Thu Jun 29 11:31:21 2023 13 // Update Count : 28 14 // 15 16 #include <fstream.hfa> 15 17 16 18 // Note: this test case has been crafted so that it compiles with both cfa and with gcc without any modifications. … … 21 23 #define AT @ 22 24 #else 23 int printf( const char *, ...);24 25 #define _ = 25 26 #define AT … … 28 29 const int indentAmt = 2; 29 30 void indent( int level ) { 30 for ( int i = 0; i < level; ++i ) { 31 printf( " " ); 32 } 31 sout | wd( level, "" ) | nonl; 33 32 } 34 33 … … 40 39 void printA( struct A a, int level ) { 41 40 indent( level ); 42 printf( "(A){ %d %d %p }\n", a.x, a.y, a.ptr );41 sout | "(A){ " | a.x | a.y | a.ptr | " }"; 43 42 } 44 43 … … 49 48 void printB( struct B b, int level ) { 50 49 indent( level ); 51 printf( "(B){\n" );50 sout | "(B){"; 52 51 printA( b.a0, level+indentAmt ); 53 52 printA( b.a1, level+indentAmt ); 54 53 indent( level ); 55 printf( "}\n" );54 sout | "}"; 56 55 } 57 56 … … 63 62 void printC( struct C c, int level ) { 64 63 indent( level ); 65 printf( "(C){\n" );64 sout | "(C){"; 66 65 indent( level+indentAmt ); 67 printf( "(int[]{ %d %d %d }\n", c.arr[0], c.arr[1], c.arr[2]);66 sout | "(int[]{ " | c.arr[0] | c.arr[1] | c.arr[2] | " }"; 68 67 printB( c.b, level+indentAmt ); 69 68 indent( level ); 70 printf( "}\n" );69 sout | "}"; 71 70 } 72 71 … … 79 78 void printD( struct D d, int level ) { 80 79 indent( level); 81 printf( "(D ){ %d }\n", d.x );80 sout | "(D){ " | d.x | "}"; 82 81 } 83 82 … … 92 91 93 92 struct Fred { 94 double i[3];95 int j;96 struct Mary {97 struct Jane {98 double j;99 } j;100 double i;101 } m;93 double i[3]; 94 int j; 95 struct Mary { 96 struct Jane { 97 double j; 98 } j; 99 double i; 100 } m; 102 101 }; 103 102 struct Fred s1 AT= { .m.j _ 3 }; … … 129 128 #endif 130 129 131 printf( "=====A=====\n" );130 sout | "=====A====="; 132 131 printA( y0, 0 ); 133 132 printA( y1, 0 ); 134 133 printA( y2, 0 ); 135 printf( "=====A=====\n\n" );134 sout | "=====A=====" | nl | nl; 136 135 137 136 // initialize only first element (z0.a.x), leaving everything else default-initialized (zero), no nested curly-braces … … 172 171 }; 173 172 174 printf( "=====B=====\n" );173 sout | "=====B====="; 175 174 printB( z0, 0 ); 176 175 printB( z1, 0 ); … … 179 178 printB( z5, 0 ); 180 179 printB( z6, 0 ); 181 printf( "=====B=====\n\n" );180 sout | "=====B=====" | nl | nl; 182 181 183 182 // TODO: what about extra things in a nested init? are empty structs skipped?? … … 190 189 }; 191 190 192 printf( "=====C=====\n" );191 sout | "=====C====="; 193 192 printC( c1, 0 ); 194 printf( "=====C=====\n\n" );193 sout | "=====C=====" | nl | nl; 195 194 196 195 #if ERROR … … 246 245 }; 247 246 248 printf( "=====E=====\n" );247 sout | "=====E====="; 249 248 printA( e0.a, 0 ); 250 249 printA( e1.a, 0 ); 251 250 printA( e2.a, 0 ); 252 251 printB( e3.b, 0 ); 253 printf( "=====E=====\n\n" );252 sout | "=====E=====" | nl | nl; 254 253 255 254 // special case of initialization: char[] can be initialized with a string literal -
tests/io/.expect/io.txt
rc9019ce r599dc6a 61 61 1, 2, 3 4, 5, 6 62 62 63 check sep On/sepOff63 check sep/nosep 64 64 1 2 3 65 65 12 3 -
tests/io/io.cfa
rc9019ce r599dc6a 10 10 // Created On : Wed Mar 2 16:56:02 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 21 10:56:33 202113 // Update Count : 12 112 // Last Modified On : Thu Jun 29 10:19:31 2023 13 // Update Count : 126 14 14 // 15 15 … … 122 122 sout | "toggle separator"; 123 123 sout | f | "" | d | "" | ld; // floating point without separator 124 sout | sep Disable | fc | dc | ldc;// complex without separator125 sout | fc | sep On | dc | ldc;// local separator add126 sout | sep Enable | fc | dc | ldc;// complex with separator127 sout | fc | sepOff| dc | ldc; // local separator removal128 sout | s1 | sepOff | s2;// local separator removal124 sout | sepOff | fc | dc | ldc; // complex without separator 125 sout | fc | sep | dc | ldc; // local separator add 126 sout | sepOn | fc | dc | ldc; // complex with separator 127 sout | fc | nosep | dc | ldc; // local separator removal 128 sout | s1 | nosep | s2; // local separator removal 129 129 sout | s1 | "" | s2; // local separator removal 130 130 sout | nl; 131 131 132 132 sout | "change separator"; 133 sout | "from \"" | sep | "\"" | nonl;133 sout | "from \"" | sepVal | "\"" | nonl; 134 134 sepSet( sout, ", $" ); // change separator, maximum of 15 characters 135 sout | " to \"" | sep | "\"";135 sout | " to \"" | sepVal | "\""; 136 136 sout | f | d | ld; 137 137 sout | fc | dc | ldc; … … 139 139 sout | t1 | t2; // print tuple 140 140 sout | nl; 141 sout | "from \"" | sep | "\" " | nonl;141 sout | "from \"" | sepVal | "\" " | nonl; 142 142 sepSet( sout, " " ); // restore separator 143 sout | "to \"" | sep | "\"";143 sout | "to \"" | sepVal | "\""; 144 144 sout | f | d | ld; 145 145 sout | fc | dc | ldc; … … 148 148 sout | nl; 149 149 150 sout | "check sep On/sepOff";151 sout | sep On | 1 | 2 | 3 | sepOn;// no separator at start/end of line152 sout | 1 | sepOff| 2 | 3; // locally turn off implicit separator153 sout | sep On | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn| '\n' | nonl; // no separator at start/end of line154 sout | 1 | 2 | 3 | "\n\n" | sep On | nonl;// no separator at start of next line150 sout | "check sep/nosep"; 151 sout | sep | 1 | 2 | 3 | sep; // no separator at start/end of line 152 sout | 1 | nosep | 2 | 3; // locally turn off implicit separator 153 sout | sep | sep | 1 | 2 | 3 | sep | nosep | sep | '\n' | nonl; // no separator at start/end of line 154 sout | 1 | 2 | 3 | "\n\n" | sep | nonl; // no separator at start of next line 155 155 sout | 1 | 2 | 3; 156 156 sout | nl; 157 157 158 158 sout | "check enable/disable"; 159 sout | sep Disable | 1 | 2 | 3;// globally turn off implicit separation160 sout | 1 | sep On | 2 | 3;// locally turn on implicit separator161 sout | sep Enable | 1 | 2 | 3 | sepDisable;// globally turn on/off implicit separation162 sout | 1 | 2 | 3 | sep Enable;// globally turn on implicit separation163 sout | 1 | 2 | 3 | sep On | sepDisable;// ignore seperate at end of line164 sout | 1 | 2 | 3 | sep On | sepEnable;// separator at end of line159 sout | sepOff | 1 | 2 | 3; // globally turn off implicit separation 160 sout | 1 | sep | 2 | 3; // locally turn on implicit separator 161 sout | sepOn | 1 | 2 | 3 | sepOff; // globally turn on/off implicit separation 162 sout | 1 | 2 | 3 | sepOn; // globally turn on implicit separation 163 sout | 1 | 2 | 3 | sep | sepOff; // ignore seperate at end of line 164 sout | 1 | 2 | 3 | sep | sepOn; // separator at end of line 165 165 sout | 1 | 2 | 3; 166 166 sout | nl; … … 169 169 170 170 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 171 sout | t1 | t2 | " \"" | sep | "\"";171 sout | t1 | t2 | " \"" | sepVal | "\""; 172 172 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 173 sout | t1 | t2 | " \"" | sep | "\"";173 sout | t1 | t2 | " \"" | sepVal | "\""; 174 174 sout | t1 | t2; // print tuple 175 175 sout | nl; … … 180 180 sepSetTuple( sout, " " ); 181 181 sout | t3; 182 sout | sep On | t3 | sepDisable | t3 | sepEnable| t3;182 sout | sep | t3 | sepOff | t3 | sepOn | t3; 183 183 sepSet( sout, "^" ); 184 184 sepSetTuple( sout, "-" ); -
tests/raii/dtor-early-exit.cfa
rc9019ce r599dc6a 10 10 // Created On : Wed Aug 17 08:26:25 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Dec 21 08:45:19 201813 // Update Count : 1 012 // Last Modified On : Thu Jun 29 11:15:56 2023 13 // Update Count : 11 14 14 // 15 15 … … 244 244 245 245 int main() { 246 sep Disable(sout);246 sepOff(sout); 247 247 for (int i = 0; i < 4; i++) { 248 248 f(i);
Note:
See TracChangeset
for help on using the changeset viewer.