- Timestamp:
- Aug 2, 2024, 9:13:54 AM (4 months ago)
- Branches:
- master
- Children:
- 433e2c3
- Parents:
- 4db0140
- Location:
- tests/ctrl-flow
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/ctrl-flow/.expect/loopctrl.txt
r4db0140 r8789ae4 61 61 (10 10)(9 9)(8 8)(7 7)(6 6)(5 5)(4 4)(3 3)(2 2)(1 1)(0 0) 62 62 63 3 4 5 6 7 8 9 64 3 4 5 6 7 8 9 65 10 9 8 7 6 5 4 66 3.5 4.5 5.5 6.5 7.5 8.5 9.5 67 abcde 68 edcba 69 (0 0)(1 1)(2 2)(3 3)(4 4)(5 5)(6 6) 70 (1 1)(2 2)(3 3)(4 4)(5 5)(6 6) 71 (3 0)(4 1)(5 2)(6 3) 72 (7 0)(6 -1)(5 -2)(4 -3) 73 63 74 A A A A A A A A A A 64 75 B B B B B B B B B B B … … 108 119 0 -2 -4 -6 -8 109 120 0 1 2 3 4 5 6 7 8 9 121 A B C D 122 D C B A -
tests/ctrl-flow/loopctrl.cfa
r4db0140 r8789ae4 10 10 // Created On : Wed Aug 8 18:32:59 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 27 11:00:09202413 // Update Count : 1 6112 // Last Modified On : Fri Aug 2 08:42:55 2024 13 // Update Count : 185 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include <enum.hfa> 17 18 18 19 void fred() { … … 81 82 for ( int j; s ~ @ ~ @ ) { if ( j == 10 ) break; sout | j; j += 1; } sout | nl; 82 83 83 // enumE { A, B, C, D };84 // for ( e; A ~= C ) { sout | j; } 85 // for ( e; A ~= D ) { sout | j; } 86 // for ( e; A -~= D ~ 2 ) { sout | j; } 87 // for ( e; E ) { sout | j; }88 // for ( e; -~ E ) { sout | j; }84 enum(int) E { A, B, C, D }; 85 // for ( E e; A ~= C ) { sout | e; } sout | nl; 86 // for ( e; A ~= D ) { sout | e; } sout | nl; 87 // for ( e; A -~= D ~ 2 ) { sout | e; } sout | nl; 88 for ( e; E ) { sout | e; } sout | nl; 89 for ( e; -~= E ) { sout | e; } sout | nl; 89 90 } 90 91 … … 95 96 void ?{}( S & s, zero_t ) { s.[i, j] = 0; } 96 97 void ?{}( S & s, one_t ) { s.[i, j] = 1; } 97 int ?<?( S t1, S t2 ) { return t1.i < t2.i && t1.j < t2.j; }98 int ?<=?( S t1, S t2 ) { return t1.i <= t2.i && t1.j <= t2.j; }99 int ?>?( S t1, S t2 ) { return t1.i > t2.i && t1.j > t2.j; }100 int ?>=?( S t1, S t2 ) { return t1.i >= t2.i && t1.j >= t2.j; }101 S ?+=?( S & t1, S t2 ) { t1.i += t2.i; t1.j += t2.j; return t1; }102 S ?+=?( S & t, one_t ) { t.i += 1; t.j += 1; return t; }103 S ?-=?( S & t1, S t2 ) { t1.i -= t2.i; t1.j -= t2.j; return t1; }104 S ?-=?( S & t, one_t ) { t.i -= 1; t.j -= 1; return t; }105 ofstream & ?|?( ofstream & os, S v ) { return os | '(' | v.i | v.j | ')'; }106 void & ?|?( ofstream & os, S v ) { (ofstream &)(os | v); ends( os ); }98 int ?<?( S s1, S s2 ) { return s1.i < s2.i || s1.j < s2.j; } 99 int ?<=?( S s1, S s2 ) { return s1.i <= s2.i || s1.j <= s2.j; } 100 int ?>?( S s1, S s2 ) { return s1.i > s2.i || s1.j > s2.j; } 101 int ?>=?( S s1, S s2 ) { return s1.i >= s2.i || s1.j >= s2.j; } 102 S ?+=?( S & s1, S s2 ) { s1.i += s2.i; s1.j += s2.j; return s1; } 103 S ?+=?( S & s, one_t ) { s.i += 1; s.j += 1; return s; } 104 S ?-=?( S & s1, S s2 ) { s1.i -= s2.i; s1.j -= s2.j; return s1; } 105 S ?-=?( S & s, one_t ) { s.i -= 1; s.j -= 1; return s; } 106 ofstream & ?|?( ofstream & os, S s ) { return os | '(' | s.i | s.j | ')'; } 107 void & ?|?( ofstream & os, S s ) { (ofstream &)(os | s); ends( os ); } 107 108 108 109 int main() { … … 183 184 for ( k; 1.5 ~ @ : j; @ -~ -5 ~ 2 : i; 10 ) { sout | i | j | k; } sout | nl; 184 185 185 for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | nl; 186 for ( S s = (S){0}; s < (S){10,10}; s += (S){1} ) { sout | s; } sout | nl; // 0 does not work 186 187 for ( s; (S){10,10} ) { sout | s; } sout | nl; 187 188 sout | nl; … … 196 197 for ( s; (S){0} -~= (S){10,10} ~ (S){1} ) { sout | s; } sout | nl | nl; 197 198 199 int i = 10; 200 double d = 10.; 201 char c = 'e'; 202 S s = { 7 }; 203 204 for ( anon; 3 ~ i ) sout | anon; sout | nl; 205 for ( anon; 3 ~ i ) sout | anon; sout | nl; 206 for ( anon; 3 -~ i ) sout | anon; sout | nl; 207 for ( anon; 3.5 ~ d ) sout | anon; sout | nl; 208 for ( anon; 'a' ~= c ) sout | anon; sout | nl; 209 for ( anon; 'a' -~= c ) sout | anon; sout | nl; 210 for ( anon; (S){0} ~ s ) sout | anon; sout | nl; // 0 does not work 211 for ( anon; (S){1} ~ s ) sout | anon; sout | nl; // 1 does not work 212 for ( anon; (S){3} ~ s ) sout | anon; sout | nl; 213 for ( anon; (S){3} -~ s ) sout | anon; sout | nl | nl; 214 198 215 fred(); 199 216 }
Note: See TracChangeset
for help on using the changeset viewer.