Changeset 18f0b70 for tests


Ignore:
Timestamp:
Nov 10, 2020, 12:21:21 AM (4 years ago)
Author:
Fangren Yu <f37yu@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
0dd9a5e
Parents:
16ba4a6 (diff), 75baaa3 (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:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/alloc.cfa

    r16ba4a6 r18f0b70  
    208208
    209209
     210        int const_count, dest_count;
    210211        struct Struct { int x; double y; };
     212        void  ?{}( Struct & a ) {                                       // construct
     213                a.[ x, y ] = [ -1, -1.0 ];
     214        }
     215        void  ?{}( Struct & a, int x, double y ) {      // initialize
     216                a.[ x, y ] = [ x, y ];
     217                const_count++;
     218        }
     219        void ^?{}( Struct & a ) {  dest_count++; }      // destruct
    211220        Struct st, st1, sta[dim], sta1[dim], * stp, * stp1;
    212221
     
    329338        printf( "\n" );
    330339
     340        const_count = dest_count = 0;
    331341        stp = new( 42, 42.5 );
     342        assert( const_count == 1 && dest_count == 0 );                                          // assertion for testing
    332343        stp1 = new( 42, 42.5 );
     344        assert( const_count == 2 && dest_count == 0 );                                          // assertion for testing
     345
    333346        printf( "CFA new initialize\n%d %g %d %g\n", stp->x, stp->y, stp1->x, stp1->y );
    334347        delete( stp, stp1 );
     348        assert( const_count == 2 && dest_count == 2 );                                          // assertion for testing
    335349
    336350        // new, array types
    337351        stp = anew( dim, 42, 42.5 );
     352        assert( const_count == 2 + dim && dest_count == 2 );                            // assertion for testing
    338353        printf( "CFA array new initialize\n" );
    339354        for ( i; dim ) { printf( "%d %g, ", stp[i].x, stp[i].y ); }
    340355        printf( "\n" );
     356
    341357        stp1 = anew( dim, 42, 42.5 );
     358        assert( const_count == 2 + 2 * dim && dest_count == 2 );                        // assertion for testing
    342359        for ( i; dim ) { printf( "%d %g, ", stp1[i].x, stp1[i].y ); }
    343360        printf( "\n" );
    344361        adelete( stp, stp1 );
     362        assert( const_count == 2 + 2 * dim && dest_count == 2 + 2 * dim);       // assertion for testing
    345363
    346364        // extras
     
    354372        *ip = 0xdeadbeef;
    355373        printf( "CFA deep malloc %#x\n", *ip );
    356         free( ip );
     374
     375        dp = alloc(5.0`fill); // just for testing multiple free
     376        assert(*dp == 5.0);
     377        free( ip, dp );
    357378
    358379#ifdef ERR1
  • tests/malloc.cfa

    r16ba4a6 r18f0b70  
    319319        free(ip);
    320320
    321         free( 0p ); // sanity check
     321        free( (void*) 0p ); // sanity check
    322322        free( NULL ); // sanity check
    323323
Note: See TracChangeset for help on using the changeset viewer.