Changeset 85a3806


Ignore:
Timestamp:
Jun 29, 2023, 12:12:35 PM (17 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6587f9d
Parents:
7d25f44
Message:

change from printf to sout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/designations.cfa

    r7d25f44 r85a3806  
    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
Note: See TracChangeset for help on using the changeset viewer.