Changeset 599dc6a for tests


Ignore:
Timestamp:
Jun 30, 2023, 1:48:33 PM (3 years ago)
Author:
caparsons <caparson@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
tests
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tests/PRNG.cfa

    rc9019ce r599dc6a  
    1010// Created On       : Wed Dec 29 09:38:12 2021
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 25 15:39:52 2023
    13 // Update Count     : 422
     12// Last Modified On : Thu Jun 29 10:18:35 2023
     13// Update Count     : 424
    1414//
    1515
     
    144144        srand( rseed );
    145145
    146         sout | sepDisable;
     146        sout | sepOff;
    147147        sout | nl | wd(26, "rand()" ) | wd(12, "rand(5)") | wd(12, "rand(0,5)" );
    148148        for ( 20 ) {
     
    151151                sout | wd(12, rand() % (5 - 0 + 1) + 0);
    152152        } // for
    153         sout | sepEnable;
     153        sout | sepOn;
    154154        sout | "seed" | rseed;
    155155
     
    185185        if ( seed != 0 ) set_seed( prng, seed );
    186186
    187         sout | sepDisable;
     187        sout | sepOff;
    188188        sout | nl | wd(26, "PRNG()" ) | wd(12, "PRNG(5)") | wd(12, "PRNG(0,5)" );
    189189        for ( 20 ) {
     
    192192                sout | wd(12, prng( prng, 0, 5 ));
    193193        } // for
    194         sout | sepEnable;
     194        sout | sepOn;
    195195        sout | "seed" | get_seed( prng );
    196196
     
    220220        if ( seed != 0 ) set_seed( seed );
    221221
    222         sout | sepDisable;
     222        sout | sepOff;
    223223        sout | nl | wd(26, "prng()" ) | wd(12, "prng(5)") | wd(12, "prng(0,5)" );
    224224        for ( 20 ) {
     
    227227                sout | wd(12, prng( 0, 5 ));
    228228        } // for
    229         sout | sepEnable;
     229        sout | sepOn;
    230230        sout | "seed" | get_seed( prng );
    231231
     
    256256        thread$ & th = *active_thread();
    257257
    258         sout | sepDisable;
     258        sout | sepOff;
    259259        sout | nl | wd(26, "prng(t)" ) | wd(12, "prng(t,5)") | wd(12, "prng(t,0,5)" );
    260260        for ( 20 ) {
     
    263263                sout | wd(12, prng( th, 0, 5 ));
    264264        } // for
    265         sout | sepEnable;
     265        sout | sepOn;
    266266        sout | "seed" | get_seed( prng );
    267267
  • tests/designations.cfa

    rc9019ce r599dc6a  
    1010// Created On       : Thu Jun 29 15:26:36 2017
    1111// 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>
    1517
    1618// Note: this test case has been crafted so that it compiles with both cfa and with gcc without any modifications.
     
    2123#define AT @
    2224#else
    23 int printf( const char *, ...);
    2425#define _ =
    2526#define AT
     
    2829const int indentAmt = 2;
    2930void indent( int level ) {
    30         for ( int i = 0; i < level; ++i ) {
    31                 printf( " " );
    32         }
     31        sout | wd( level, "" ) | nonl;
    3332}
    3433
     
    4039void printA( struct A a, int level ) {
    4140        indent( level );
    42         printf( "(A){ %d %d %p }\n", a.x, a.y, a.ptr );
     41        sout | "(A){ " | a.x | a.y | a.ptr | " }";
    4342}
    4443
     
    4948void printB( struct B b, int level ) {
    5049        indent( level );
    51         printf( "(B){\n" );
     50        sout | "(B){";
    5251        printA( b.a0, level+indentAmt );
    5352        printA( b.a1, level+indentAmt );
    5453        indent( level );
    55         printf( "}\n" );
     54        sout | "}";
    5655}
    5756
     
    6362void printC( struct C c, int level ) {
    6463        indent( level );
    65         printf( "(C){\n" );
     64        sout | "(C){";
    6665        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] | " }";
    6867        printB( c.b, level+indentAmt );
    6968        indent( level );
    70         printf( "}\n" );
     69        sout | "}";
    7170}
    7271
     
    7978void printD( struct D d, int level ) {
    8079        indent( level);
    81         printf( "(D ){ %d }\n", d.x );
     80        sout | "(D){ " | d.x | "}";
    8281}
    8382
     
    9291
    9392struct 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;
    102101};
    103102struct Fred s1 AT= { .m.j _ 3 };
     
    129128#endif
    130129
    131         printf( "=====A=====\n" );
     130        sout | "=====A=====";
    132131        printA( y0, 0 );
    133132        printA( y1, 0 );
    134133        printA( y2, 0 );
    135         printf( "=====A=====\n\n" );
     134        sout | "=====A=====" | nl | nl;
    136135
    137136        // initialize only first element (z0.a.x), leaving everything else default-initialized (zero), no nested curly-braces
     
    172171        };
    173172
    174         printf( "=====B=====\n" );
     173        sout | "=====B=====";
    175174        printB( z0, 0 );
    176175        printB( z1, 0 );
     
    179178        printB( z5, 0 );
    180179        printB( z6, 0 );
    181         printf( "=====B=====\n\n" );
     180        sout | "=====B=====" | nl | nl;
    182181
    183182        // TODO: what about extra things in a nested init? are empty structs skipped??
     
    190189        };
    191190
    192         printf( "=====C=====\n" );
     191        sout | "=====C=====";
    193192        printC( c1, 0 );
    194         printf( "=====C=====\n\n" );
     193        sout | "=====C=====" | nl | nl;
    195194
    196195#if ERROR
     
    246245        };
    247246
    248         printf( "=====E=====\n" );
     247        sout | "=====E=====";
    249248        printA( e0.a, 0 );
    250249        printA( e1.a, 0 );
    251250        printA( e2.a, 0 );
    252251        printB( e3.b, 0 );
    253         printf( "=====E=====\n\n" );
     252        sout | "=====E=====" | nl | nl;
    254253
    255254        // special case of initialization: char[] can be initialized with a string literal
  • tests/io/.expect/io.txt

    rc9019ce r599dc6a  
    61611, 2, 3 4, 5, 6
    6262
    63 check sepOn/sepOff
     63check sep/nosep
    64641 2 3
    656512 3
  • tests/io/io.cfa

    rc9019ce r599dc6a  
    1010// Created On       : Wed Mar  2 16:56:02 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Feb 21 10:56:33 2021
    13 // Update Count     : 121
     12// Last Modified On : Thu Jun 29 10:19:31 2023
     13// Update Count     : 126
    1414//
    1515
     
    122122        sout | "toggle separator";
    123123        sout | f | "" | d | "" | ld;                                            // floating point without separator
    124         sout | sepDisable | fc | dc | ldc;                                      // complex without separator
    125         sout | fc | sepOn | dc | ldc;                                           // local separator add
    126         sout | sepEnable | fc | dc | ldc;                                       // complex with separator
    127         sout | fc | sepOff | dc | ldc;                                          // local separator removal
    128         sout | s1 | sepOff | s2;                                                        // local separator removal
     124        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
    129129        sout | s1 | "" | s2;                                                            // local separator removal
    130130        sout | nl;
    131131
    132132        sout | "change separator";
    133         sout | "from \"" | sep | "\"" | nonl;
     133        sout | "from \"" | sepVal | "\"" | nonl;
    134134        sepSet( sout, ", $" );                                                          // change separator, maximum of 15 characters
    135         sout | " to \"" | sep | "\"";
     135        sout | " to \"" | sepVal | "\"";
    136136        sout | f | d | ld;
    137137        sout | fc | dc | ldc;
     
    139139        sout | t1 | t2;                                                                         // print tuple
    140140        sout | nl;
    141         sout | "from \"" | sep | "\" " | nonl;
     141        sout | "from \"" | sepVal | "\" " | nonl;
    142142        sepSet( sout, " " );                                                            // restore separator
    143         sout | "to \"" | sep | "\"";
     143        sout | "to \"" | sepVal | "\"";
    144144        sout | f | d | ld;
    145145        sout | fc | dc | ldc;
     
    148148        sout | nl;
    149149
    150         sout | "check sepOn/sepOff";
    151         sout | sepOn | 1 | 2 | 3 | sepOn;                                       // no separator at start/end of line
    152         sout | 1 | sepOff | 2 | 3;                                                      // locally turn off implicit separator
    153         sout | sepOn | sepOn | 1 | 2 | 3 | sepOn | sepOff | sepOn | '\n' | nonl; // no separator at start/end of line
    154         sout | 1 | 2 | 3 | "\n\n" | sepOn | nonl;                       // no separator at start of next line
     150        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
    155155        sout | 1 | 2 | 3;
    156156        sout | nl;
    157157
    158158        sout | "check enable/disable";
    159         sout | sepDisable | 1 | 2 | 3;                                          // globally turn off implicit separation
    160         sout | 1 | sepOn | 2 | 3;                                                       // locally turn on implicit separator
    161         sout | sepEnable | 1 | 2 | 3 | sepDisable;                      // globally turn on/off implicit separation
    162         sout | 1 | 2 | 3 | sepEnable;                                           // globally turn on implicit separation
    163         sout | 1 | 2 | 3 | sepOn | sepDisable;                          // ignore seperate at end of line
    164         sout | 1 | 2 | 3 | sepOn | sepEnable;                           // separator at end of line
     159        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
    165165        sout | 1 | 2 | 3;
    166166        sout | nl;
     
    169169
    170170        sepSetTuple( sout, " " );                                                       // set tuple separator from ", " to " "
    171         sout | t1 | t2 | " \"" | sep | "\"";
     171        sout | t1 | t2 | " \"" | sepVal | "\"";
    172172        sepSetTuple( sout, ", " );                                                      // reset tuple separator to ", "
    173         sout | t1 | t2 | " \"" | sep | "\"";
     173        sout | t1 | t2 | " \"" | sepVal | "\"";
    174174        sout | t1 | t2;                                                                         // print tuple
    175175        sout | nl;
     
    180180        sepSetTuple( sout, " " );
    181181        sout | t3;
    182         sout | sepOn | t3 | sepDisable | t3 | sepEnable | t3;
     182        sout | sep | t3 | sepOff | t3 | sepOn | t3;
    183183        sepSet( sout, "^" );
    184184        sepSetTuple( sout, "-" );
  • tests/raii/dtor-early-exit.cfa

    rc9019ce r599dc6a  
    1010// Created On       : Wed Aug 17 08:26:25 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 21 08:45:19 2018
    13 // Update Count     : 10
     12// Last Modified On : Thu Jun 29 11:15:56 2023
     13// Update Count     : 11
    1414//
    1515
     
    244244
    245245int main() {
    246         sepDisable(sout);
     246        sepOff(sout);
    247247        for (int i = 0; i < 4; i++) {
    248248                f(i);
Note: See TracChangeset for help on using the changeset viewer.