Changeset 8789ae4 for tests/ctrl-flow


Ignore:
Timestamp:
Aug 2, 2024, 9:13:54 AM (5 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
433e2c3
Parents:
4db0140
Message:

update loop control test and expected output

Location:
tests/ctrl-flow
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/ctrl-flow/.expect/loopctrl.txt

    r4db0140 r8789ae4  
    6161(10 10)(9 9)(8 8)(7 7)(6 6)(5 5)(4 4)(3 3)(2 2)(1 1)(0 0)
    6262
     633 4 5 6 7 8 9
     643 4 5 6 7 8 9
     6510 9 8 7 6 5 4
     663.5 4.5 5.5 6.5 7.5 8.5 9.5
     67abcde
     68edcba
     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
    6374A A A A A A A A A A
    6475B B B B B B B B B B B
     
    1081190 -2 -4 -6 -8
    1091200 1 2 3 4 5 6 7 8 9
     121A B C D
     122D C B A
  • tests/ctrl-flow/loopctrl.cfa

    r4db0140 r8789ae4  
    1010// Created On       : Wed Aug  8 18:32:59 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jun 27 11:00:09 2024
    13 // Update Count     : 161
     12// Last Modified On : Fri Aug  2 08:42:55 2024
     13// Update Count     : 185
    1414//
    1515
    1616#include <fstream.hfa>
     17#include <enum.hfa>
    1718
    1819void fred() {
     
    8182        for ( int j; s ~ @ ~ @ ) { if ( j == 10 ) break; sout | j; j += 1; } sout | nl;
    8283
    83         // enum E { 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;
    8990}
    9091
     
    9596void ?{}( S & s, zero_t ) { s.[i, j] = 0; }
    9697void ?{}( 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 ); }
     98int ?<?( S s1, S s2 ) { return s1.i < s2.i || s1.j < s2.j; }
     99int ?<=?( S s1, S s2 ) { return s1.i <= s2.i || s1.j <= s2.j; }
     100int ?>?( S s1, S s2 ) { return s1.i > s2.i || s1.j > s2.j; }
     101int ?>=?( S s1, S s2 ) { return s1.i >= s2.i || s1.j >= s2.j; }
     102S ?+=?( S & s1, S s2 ) { s1.i += s2.i; s1.j += s2.j; return s1; }
     103S ?+=?( S & s, one_t ) { s.i += 1; s.j += 1; return s; }
     104S ?-=?( S & s1, S s2 ) { s1.i -= s2.i; s1.j -= s2.j; return s1; }
     105S ?-=?( S & s, one_t ) { s.i -= 1; s.j -= 1; return s; }
     106ofstream & ?|?( ofstream & os, S s ) { return os | '(' | s.i | s.j | ')'; }
     107void & ?|?( ofstream & os, S s ) { (ofstream &)(os | s); ends( os ); }
    107108
    108109int main() {
     
    183184        for ( k; 1.5 ~ @ : j; @ -~ -5 ~ 2 : i; 10 ) { sout | i | j | k; } sout | nl;
    184185
    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
    186187        for ( s; (S){10,10} ) { sout | s; } sout | nl;
    187188        sout | nl;
     
    196197        for ( s; (S){0} -~= (S){10,10} ~ (S){1} ) { sout | s; } sout | nl | nl;
    197198
     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
    198215        fred();
    199216}
Note: See TracChangeset for help on using the changeset viewer.