Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/PRNG.cfa

    r20cf96d rae7a085c  
    88// Created On       : Wed Dec 29 09:38:12 2021
    99// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Tue Nov 22 22:51:12 2022
    11 // Update Count     : 381
     10// Last Modified On : Wed Dec 21 20:39:59 2022
     11// Update Count     : 406
    1212//
    1313
     
    6060
    6161
    62 unsigned int seed = 1009;
     62size_t seed = 1009;
    6363
    6464thread T1 {};
     
    116116} // dummy
    117117
     118
    118119int main() {
    119120        // causes leaked storage message
    120 //      setlocale( LC_NUMERIC, getenv( "LANG" ) );                      // print digit separator
     121        // setlocale( LC_NUMERIC, getenv( "LANG" ) );                   // print digit separator
     122        // locale_t loc = newlocale( LC_NUMERIC_MASK, getenv( "LANG" ), (locale_t)0p );
     123        // if ( loc == (locale_t)0p ) abort( "newlocale" );
     124        // uselocale( loc );
    121125
    122126        enum { TASKS = 4 };
     
    130134
    131135        sout | sepDisable;
    132         sout | wd(13, "rand()" ) | wd(10, "rand(5)") | wd(13, "rand(0,5)" );
    133         for ( 20 ) {
    134                 sout | wd(13, rand()) | nonl;
    135                 sout | wd(10, rand() % 5) | nonl;
    136                 sout | wd(13, rand() % (5 - 0 + 1) + 0);
     136        sout | wd(26, "rand()" ) | wd(12, "rand(5)") | wd(12, "rand(0,5)" );
     137        for ( 20 ) {
     138                sout | wd(26, rand()) | nonl;
     139                sout | wd(12, rand() % 5) | nonl;
     140                sout | wd(12, rand() % (5 - 0 + 1) + 0);
    137141        } // for
    138142        sout | sepEnable;
     
    168172
    169173        sout | sepDisable;
    170         sout | nl | wd(13, "PRNG()" ) | wd(10, "PRNG(5)") | wd(13, "PRNG(0,5)" );
    171         for ( 20 ) {
    172                 sout | wd(13, prng( prng )) | nonl;                             // cascading => side-effect functions called in arbitary order
    173                 sout | wd(10, prng( prng, 5 )) | nonl;
    174                 sout | wd(13, prng( prng, 0, 5 ));
     174        sout | nl | wd(26, "PRNG()" ) | wd(12, "PRNG(5)") | wd(12, "PRNG(0,5)" );
     175        for ( 20 ) {
     176                sout | wd(26, prng( prng )) | nonl;                             // cascading => side-effect functions called in arbitary order
     177                sout | wd(12, prng( prng, 5 )) | nonl;
     178                sout | wd(12, prng( prng, 0, 5 ));
    175179        } // for
    176180        sout | sepEnable;
     
    203207
    204208        sout | sepDisable;
    205         sout | nl | wd(13, "prng()" ) | wd(10, "prng(5)") | wd(13, "prng(0,5)" );
    206         for ( 20 ) {
    207                 sout | wd(13, prng()) | nonl;                                   // cascading => side-effect functions called in arbitary order
    208                 sout | wd(10, prng( 5 )) | nonl;
    209                 sout | wd(13, prng( 0, 5 ));
     209        sout | nl | wd(26, "prng()" ) | wd(12, "prng(5)") | wd(12, "prng(0,5)" );
     210        for ( 20 ) {
     211                sout | wd(26, prng()) | nonl;                                   // cascading => side-effect functions called in arbitary order
     212                sout | wd(12, prng( 5 )) | nonl;
     213                sout | wd(12, prng( 0, 5 ));
    210214        } // for
    211215        sout | sepEnable;
     
    239243
    240244        sout | sepDisable;
    241         sout | nl | wd(13, "prng(t)" ) | wd(10, "prng(t,5)") | wd(13, "prng(t,0,5)" );
    242         for ( 20 ) {
    243                 sout | wd(13, prng( th )) | nonl;                               // cascading => side-effect functions called in arbitary order
    244                 sout | wd(10, prng( th, 5 )) | nonl;
    245                 sout | wd(13, prng( th, 0, 5 ));
     245        sout | nl | wd(26, "prng(t)" ) | wd(12, "prng(t,5)") | wd(12, "prng(t,0,5)" );
     246        for ( 20 ) {
     247                sout | wd(26, prng( th )) | nonl;                               // cascading => side-effect functions called in arbitary order
     248                sout | wd(12, prng( th, 5 )) | nonl;
     249                sout | wd(12, prng( th, 0, 5 ));
    246250        } // for
    247251        sout | sepEnable;
     
    266270#endif // 0
    267271//      malloc_stats();
     272        // freelocale( loc );
    268273} // main
    269274
Note: See TracChangeset for help on using the changeset viewer.