Changeset 8a930c03 for tests


Ignore:
Timestamp:
Jun 12, 2023, 12:05:58 PM (2 years ago)
Author:
JiadaL <j82liang@…>
Branches:
master
Children:
fec8bd1
Parents:
2b78949 (diff), 38e266ca (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:
8 added
3 deleted
10 edited
198 moved

Legend:

Unmodified
Added
Removed
  • tests/.expect/array.txt

    r2b78949 r8a930c03  
    1 array.cfa:52:25: warning: Compiled
     1array.cfa:119:25: warning: Preprocessor started
  • tests/.expect/copyfile.txt

    r2b78949 r8a930c03  
    1010// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 19 17:58:03 2020
    13 // Update Count     : 4
     12// Last Modified On : Mon Jun  5 21:20:07 2023
     13// Update Count     : 5
    1414//
    1515
     
    3030                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3131                } // choose
    32         } catch( Open_Failure * ex ; ex->istream == &in ) {
     32        } catch( open_failure * ex ; ex->istream == &in ) {
    3333                exit | "Unable to open input file" | argv[1];
    34         } catch( Open_Failure * ex ; ex->ostream == &out ) {
     34        } catch( open_failure * ex ; ex->ostream == &out ) {
    3535                close( in );                                                                    // optional
    3636                exit | "Unable to open output file" | argv[2];
  • tests/.in/copyfile.txt

    r2b78949 r8a930c03  
    1010// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 19 17:58:03 2020
    13 // Update Count     : 4
     12// Last Modified On : Mon Jun  5 21:20:07 2023
     13// Update Count     : 5
    1414//
    1515
     
    3030                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3131                } // choose
    32         } catch( Open_Failure * ex ; ex->istream == &in ) {
     32        } catch( open_failure * ex ; ex->istream == &in ) {
    3333                exit | "Unable to open input file" | argv[1];
    34         } catch( Open_Failure * ex ; ex->ostream == &out ) {
     34        } catch( open_failure * ex ; ex->ostream == &out ) {
    3535                close( in );                                                                    // optional
    3636                exit | "Unable to open output file" | argv[2];
  • tests/Makefile.am

    r2b78949 r8a930c03  
    1111## Created On       : Sun May 31 09:08:15 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Tue May 16 09:27:48 2023
    14 ## Update Count     : 178
     13## Last Modified On : Sun May 28 08:15:43 2023
     14## Update Count     : 196
    1515###############################################################################
    1616
     
    2626ARCH = ${if ${arch},"--arch=${arch}"}
    2727arch_support = "x86/x64/arm"
     28TIMEOUT = ${if ${timeout},"--timeout=${timeout}"}
     29GLOBAL_TIMEOUT = ${if ${global-timeout},"--global-timeout=${global-timeout}"}
     30ARCHIVE_ERRORS = ${if ${archive-errors},"--archive-errors=${archive-errors}"}
     31
    2832DEBUG_FLAGS = -debug -g -O0
    2933
    3034quick_test = avl_test operators numericConstants expression enum array typeof cast raii/dtor-early-exit raii/init_once attributes meta/dumpable
    31 
    32 archiveerrors=
    33 concurrent=
    34 timeouts=
    3535
    3636TEST_PY = python3 ${builddir}/test.py
     
    6767PRETTY_PATH = mkdir -p ${dir ${abspath ${@}}} && cd ${srcdir} &&
    6868
    69 .PHONY : list .validate .test_makeflags
     69.PHONY : concurrency list .validate .test_makeflags
    7070.INTERMEDIATE : .validate .validate.cfa .test_makeflags
    7171EXTRA_PROGRAMS = avl_test linkonce linking/mangling/anon .dummy_hack # build but do not install
     
    7979        avltree/avl-private.h \
    8080        avltree/avl.h \
    81         concurrent/clib_tls.c \
    82         concurrent/clib.c \
    8381        configs/.in/parseconfig-all.txt \
    8482        configs/.in/parseconfig-errors.txt \
     
    8987        io/.in/many_read.data \
    9088        meta/fork+exec.hfa \
    91         concurrent/unified_locking/mutex_test.hfa \
    92         concurrent/channels/parallel_harness.hfa
     89        concurrency/clib_tls.c \
     90        concurrency/clib.c \
     91        concurrency/unified_locking/mutex_test.hfa \
     92        concurrency/channels/parallel_harness.hfa
    9393
    9494dist-hook:
     
    109109#----------------------------------------------------------------------------------------------------------------
    110110
     111# '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
    111112all-local : # This name is important to automake and implies the default build target.
    112         @+${TEST_PY} --debug=${debug} --install=${installed} --invariant --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${ARCH} --all # '@' => do not echo command (SILENT), '+' => allows recursive make from within python program
    113 
    114 install : all-local # PAB only
    115 
    116 tests : all-local
     113        @+${TEST_PY} --debug=${debug} --install=${installed} --invariant ${ARCHIVE_ERRORS} ${TIMEOUT} ${GLOBAL_TIMEOUT} ${ARCH} --all
     114
     115tests : all-local # synonym
     116
     117install : all-local  # synonym, PAB only
    117118
    118119quick :
    119         @+${TEST_PY} --debug=${debug} --install=${installed} --archive-errors=${archiveerrors} ${concurrent} ${timeouts} ${ARCH} ${quick_test}
     120        @+${TEST_PY} --debug=${debug} --install=${installed} ${ARCHIVE_ERRORS} ${ARCH} ${quick_test}
    120121
    121122concurrency :
    122         @+${TEST_PY} --debug=${debug} --install=${installed} ${ARCH} -Iconcurrent
     123        @+${TEST_PY} --debug=${debug} --install=${installed} ${ARCHIVE_ERRORS} ${TIMEOUT} ${GLOBAL_TIMEOUT} ${ARCH} -Iconcurrency
    123124
    124125list :
    125         @+${TEST_PY} --list ${concurrent}
     126        @+${TEST_PY} --list
    126127
    127128help :
    128129        @echo "user targets:"
    129130        @echo "    Run the complete test suite."
    130         @echo "    $$ make (null) / tests [debug=yes/no] [installed=yes/no] [arch=${arch_support}]"
     131        @echo "    $$ make (null) / tests [debug=yes/no] [installed=yes/no] [archive-errors=dump-dir] [timeout=seconds] [global-timeout=seconds] [arch=${arch_support}]"
    131132        @echo ""
    132133        @echo "    Run the short (quick) test suite."
    133         @echo "    $$ make quick [debug=yes/no] [installed=yes/no] [arch=${arch_support}]"
     134        @echo "    $$ make quick [debug=yes/no] [installed=yes/no] [archive-errors=dump-dir] [arch=${arch_support}]"
    134135        @echo ""
    135         @echo "    Run the concurrent test suite."
    136         @echo "    $$ make concurrency [debug=yes/no] [installed=yes/no] [arch=${arch_support}]"
     136        @echo "    Run the concurrency test suite."
     137        @echo "    $$ make concurrency [debug=yes/no] [installed=yes/no] [archive-errors=dump-dir] [timeout=seconds] [global-timeout=seconds] [arch=${arch_support}]"
    137138        @echo ""
    138139        @echo "    List all tests in the test suite."
     
    204205
    205206SYNTAX_ONLY_CODE = expression typedefRedef variableDeclarator switch numericConstants identFuncDeclarator \
    206         init1 limits nested-types cast labelledExit array quasiKeyword include/stdincludes include/includes builtins/sync warnings/self-assignment concurrent/waitfor/parse
     207        init1 limits nested-types cast labelledExit array quasiKeyword include/stdincludes include/includes builtins/sync warnings/self-assignment concurrency/waitfor/parse
    207208${SYNTAX_ONLY_CODE} : % : %.cfa ${CFACCBIN}
    208209        ${CFACOMPILE_SYNTAX}
     
    211212# expected failures
    212213# use custom target since they require a custom define *and* have a name that doesn't match the file
     214
     215array-ERR1 : array.cfa ${CFACCBIN}
     216        ${CFACOMPILE_SYNTAX} -DERR1
     217        -cp ${test} ${abspath ${@}}
     218
     219array-ERR2 : array.cfa ${CFACCBIN}
     220        ${CFACOMPILE_SYNTAX} -DERR2
     221        -cp ${test} ${abspath ${@}}
     222
     223array-ERR3 : array.cfa ${CFACCBIN}
     224        ${CFACOMPILE_SYNTAX} -DERR3
     225        -cp ${test} ${abspath ${@}}
     226
    213227alloc-ERROR : alloc.cfa ${CFACCBIN}
    214228        ${CFACOMPILE_SYNTAX} -DERR1
  • tests/PRNG.cfa

    r2b78949 r8a930c03  
    1 //                               -*- Mode: C -*-
    2 //
     1//
    32// Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
    4 //
    5 // PRNG.c --
    6 //
     3//
     4// PRNG.c -- high-perforamnce pseudo-random numbers
     5//
     6// The contents of this file are covered under the licence agreement in the
     7// file "LICENCE" distributed with Cforall.
     8//
    79// Author           : Peter A. Buhr
    810// Created On       : Wed Dec 29 09:38:12 2021
    911// Last Modified By : Peter A. Buhr
    10 // Last Modified On : Sun Apr 23 22:02:09 2023
    11 // Update Count     : 420
     12// Last Modified On : Thu May 25 15:39:52 2023
     13// Update Count     : 422
    1214//
    1315
  • tests/array.cfa

    r2b78949 r8a930c03  
    1515//
    1616
    17 int a1[0];
    18 //int a2[*];
    19 //double a4[3.0];
     17// Tests syntax.  Comments explain semantics.  Test does not show semantics.
     18// Mostly illustrates facts about C (with which CFA is being tested to agree).
     19// Is a test oracle under `gcc -x c`.
    2020
    21 int m1[0][3];
    22 //int m2[*][*];
    23 int m4[3][3];
     21#ifdef ERR1
     22#define E1(...) __VA_ARGS__
     23#else
     24#define E1(...)
     25#endif
    2426
    25 typedef int T;
     27#ifdef ERR2
     28#define E2(...) __VA_ARGS__
     29#else
     30#define E2(...)
     31#endif
    2632
    27 int fred() {
    28 //      int a1[];
    29 //      int a2[*];
    30         int a4[3];
    31         int T[3];
    32 }
     33#ifdef ERR3
     34#define E3(...) __VA_ARGS__
     35#else
     36#define E3(...)
     37#endif
    3338
    34 int mary( int T[3],
    35                   int p1[const 3],
    36                   int p2[static 3],
    37                   int p3[static const 3]
    38         ) {
    39 }
     39    int a1[0];
     40E1( int a2[*];       )
     41                                                        #ifndef __cforall
     42E1( double a4[3.0];  )                                  // BUG 275: CFA accepts but should reject
     43                                                        #endif
    4044
    41 int (*tom())[3] {
    42 }
     45    int m1[0][3];
     46E1( int m2[*][*];    )
     47    int m4[3][3];
    4348
    44 int (*(jane)())( int T[3],
    45                                  int p1[const 3],
    46                                  int p2[static 3],
    47                                  int p3[static const 3]
    48         ) {
    49 }
     49    typedef int T;
     50
     51    int fred(int n) {
     52E1(     int a1[];    )
     53E1(     int a2[*];   )
     54        int a4[3];
     55        int T[3];
     56        int a5[n];
     57    }
     58
     59    int mary( int T[3],                                 // same as: int *T
     60              int p1[const 3],                          // same as: int const *p1
     61              int p2[static 3],                         // same as T, but length >=3 checked
     62              int p3[static const 3]                    // both above: 3 is static, p3 is const
     63        ) {
     64    }
     65
     66    // function taking (), returning pointer to array of ints
     67    int (*tom())[3] {
     68    }
     69
     70    // function taking (), returning pointer to function of same type as mary
     71    int (*(jane)())( int T[3],
     72                     int p1[const 3],
     73                     int p2[static 3],
     74                     int p3[static const 3]
     75        ) {
     76    }
     77
     78    // functions returning same exotic pointers, in CFA's non-onion syntax
     79    #ifdef __cforall
     80    [ * [3] int ] toms_twin(...) {
     81    }
     82    [ * [int]( [3] int T,
     83               [const 3] int p1,
     84               [static 3] int p2,
     85               [static const 3] int p3
     86             )
     87    ] janes_twin(...) {
     88    }
     89    #endif
     90
     91    // GCC 11+ gives a false warning (-Wvla-parameter) on the valid (C11 ARM p134-135) combination:
     92    // declare with type int[*], define with type int[n].
     93    // https://gcc.gnu.org/bugzilla//show_bug.cgi?id=100420 suggests the internal representation of
     94    // of a[*] is the same as a[0].
     95    // https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wno-vla-parameter explains
     96    // the purpose of -Wvla-parameter is to report conflicts between int[] and int[n], which would
     97    // understandably also include those between int[42] and int[n].
     98    // https://stackoverflow.com/questions/17371645/why-use-an-asterisk-instead-of-an-integer-for-a-vla-array-parameter-of-a-f
     99    // explains the declare-*, define-n pattern.
     100
     101    // To work around the false warning, and keep to this test's purpose of exercising CFA's
     102    // handling of exotic C array syntax, what would ideally be demonstrated as a declaration of
     103    // fm1, followed by its definition, is instead split into fm1x and fm1y.  And similarly for
     104    // fm5.
     105
     106    int fm1x( int, int, int[][*] );
     107    int fm1y( int r, int c, int m[][c] ) {}
     108    int fm2( int r, int c, int (*m)[c] ) {}             // same as fm1
     109E2( int fm3( int r, int c, int m[][static c] ) {}  )    // that's not static
     110E3( int fm4( int r, int c, int m[][] );            )    // m's immediate element type is incomplete
     111    int fm5x( int, int, int[*][*] );                    // same as fm1 decl
     112                                                        #ifndef __cforall
     113    int fm5y( int r, int c, int m[r][c] ) {}            // BUG 276: CFA chokes but should accept
     114                                                        // C: same as fm1 defn
     115                                                        #endif
     116
    50117
    51118int main() {
    52     #pragma GCC warning "Compiled"                      // force non-empty .expect file, NO TABS!!!
     119    #pragma GCC warning "Preprocessor started"          // force non-empty .expect file, NO TABS!!!
    53120}
    54121
  • tests/concurrency/.expect/ctor-check.txt

    r2b78949 r8a930c03  
    1 concurrent/ctor-check.cfa:11:1 error: constructors cannot have mutex parameters
     1concurrency/ctor-check.cfa:11:1 error: constructors cannot have mutex parameters
    22?{}: function
    33... with parameters
  • tests/concurrency/actors/dynamic.cfa

    r2b78949 r8a930c03  
    1919void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
    2020
    21 Allocation receive( derived_actor & receiver, derived_msg & msg ) {
     21allocation receive( derived_actor & receiver, derived_msg & msg ) {
    2222    if ( msg.cnt >= Times ) {
    2323        sout | "Done";
  • tests/concurrency/actors/executor.cfa

    r2b78949 r8a930c03  
    2424struct d_msg { inline message; } shared_msg;
    2525
    26 Allocation receive( d_actor & this, d_msg & msg ) with( this ) {
     26allocation receive( d_actor & this, d_msg & msg ) with( this ) {
    2727    if ( recs == rounds ) return Finished;
    2828    if ( recs % Batch == 0 ) {
  • tests/concurrency/actors/inherit.cfa

    r2b78949 r8a930c03  
    1515void ^?{}( D_msg & this ) { mutex(sout) sout | 'A'; }
    1616
    17 Allocation handle() {
     17allocation handle() {
    1818    return Finished;
    1919}
    2020
    21 Allocation receive( Server & receiver, D_msg & msg ) { return handle(); }
    22 Allocation receive( Server & receiver, D_msg2 & msg ) { return handle(); }
    23 Allocation receive( Server2 & receiver, D_msg & msg ) { return Delete; }
    24 Allocation receive( Server2 & receiver, D_msg2 & msg ) { return Delete; }
     21allocation receive( Server & receiver, D_msg & msg ) { return handle(); }
     22allocation receive( Server & receiver, D_msg2 & msg ) { return handle(); }
     23allocation receive( Server2 & receiver, D_msg & msg ) { return Delete; }
     24allocation receive( Server2 & receiver, D_msg2 & msg ) { return Delete; }
    2525
    2626int main() {
  • tests/concurrency/actors/matrix.cfa

    r2b78949 r8a930c03  
    2424}
    2525
    26 Allocation receive( derived_actor & receiver, derived_msg & msg ) {
     26allocation receive( derived_actor & receiver, derived_msg & msg ) {
    2727    for ( unsigned int i = 0; i < yc; i += 1 ) { // multiply X_row by Y_col and sum products
    2828        msg.Z[i] = 0;
  • tests/concurrency/actors/pingpong.cfa

    r2b78949 r8a930c03  
    1919size_t times = 100000;
    2020
    21 Allocation receive( ping & receiver, p_msg & msg ) {
     21allocation receive( ping & receiver, p_msg & msg ) {
    2222    msg.count++;
    2323    if ( msg.count > times ) return Finished;
    2424
    25     Allocation retval = Nodelete;
     25    allocation retval = Nodelete;
    2626    if ( msg.count == times ) retval = Finished;
    2727    *po << msg;
     
    2929}
    3030
    31 Allocation receive( pong & receiver, p_msg & msg ) {
     31allocation receive( pong & receiver, p_msg & msg ) {
    3232    msg.count++;
    3333    if ( msg.count > times ) return Finished;
    3434   
    35     Allocation retval = Nodelete;
     35    allocation retval = Nodelete;
    3636    if ( msg.count == times ) retval = Finished;
    3737    *pi << msg;
  • tests/concurrency/actors/poison.cfa

    r2b78949 r8a930c03  
    1818        Server s[10];
    1919        for ( i; 10 ) {
    20             s[i] << FinishedMsg;
     20            s[i] << finished_msg;
    2121        }
    2222        stop_actor_system();
     
    2929            Server * s = alloc();
    3030            (*s){};
    31             (*s) << DeleteMsg;
     31            (*s) << delete_msg;
    3232        }
    3333        stop_actor_system();
     
    3939        Server s[10];
    4040        for ( i; 10 )
    41             s[i] << DestroyMsg;
     41            s[i] << destroy_msg;
    4242        stop_actor_system();
    4343        for ( i; 10 )
  • tests/concurrency/actors/static.cfa

    r2b78949 r8a930c03  
    1919void ?{}( derived_msg & this ) { ((derived_msg &)this){ 0 }; }
    2020
    21 Allocation receive( derived_actor & receiver, derived_msg & msg ) {
     21allocation receive( derived_actor & receiver, derived_msg & msg ) {
    2222    if ( msg.cnt >= Times ) {
    2323        sout | "Done";
  • tests/concurrency/actors/types.cfa

    r2b78949 r8a930c03  
    2020
    2121// this isn't a valid receive routine since int is not a message type
    22 Allocation receive( derived_actor & receiver, int i ) with( receiver ) {
     22allocation receive( derived_actor & receiver, int i ) with( receiver ) {
    2323    mutex(sout) sout | i;
    2424    counter++;
     
    2727}
    2828
    29 Allocation receive( derived_actor & receiver, d_msg & msg ) {
     29allocation receive( derived_actor & receiver, d_msg & msg ) {
    3030    return receive( receiver, msg.num );
    3131}
     
    3636};
    3737
    38 Allocation receive( derived_actor2 & receiver, d_msg & msg ) {
     38allocation receive( derived_actor2 & receiver, d_msg & msg ) {
    3939    mutex(sout) sout | msg.num;
    4040    return Finished;
     
    4848};
    4949
    50 Allocation receive( derived_actor3 & receiver, d_msg & msg ) {
     50allocation receive( derived_actor3 & receiver, d_msg & msg ) {
    5151    mutex(sout) sout | msg.num;
    5252    if ( msg.num == -1 ) return Nodelete;
     
    5454}
    5555
    56 Allocation receive( derived_actor3 & receiver, d_msg2 & msg ) {
     56allocation receive( derived_actor3 & receiver, d_msg2 & msg ) {
    5757    mutex(sout) sout | msg.num;
    5858    return Finished;
  • tests/concurrency/barrier/gen_generation_expect.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // gen_generation_expect.cfa -- simple 'script' generates the expect file for concurrent/barrier/generation
     7// gen_generation_expect.cfa -- simple 'script' generates the expect file for concurrency/barrier/generation
    88//
    99// Author           : Thierry Delisle
  • tests/concurrency/barrier/generation.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // concurrent/barrier/generation.cfa -- simple test that validates barriers by printing
    8 //                                      alphabetical generations
     7// generation.cfa -- simple test that validates barriers by printing alphabetical generations
    98//
    109// Author           : Thierry Delisle
  • tests/concurrency/barrier/last.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // concurrent/barrier/last.cfa -- validates barrier's last hook functionality
     7// last.cfa -- validates barrier's last hook functionality
    88//
    99// Author           : Thierry Delisle
  • tests/concurrency/barrier/order.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // concurrent/barrier/order.cfa -- validates barriers the return value of
     7// order.cfa -- validates barriers the return value of
    88//                                 barrier block
    99//
  • tests/concurrency/readyQ/barrier_sleeper.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // concurrent/readyQ/barrier_sleeper.cfa -- testing the ready-queue
     7// barrier_sleeper.cfa -- testing the ready-queue
    88//
    99// Author           : Thierry Delisle
  • tests/concurrency/readyQ/leader_spin.cfa

    r2b78949 r8a930c03  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // concurrent/readyQ/leader_spin.cfa -- validates ready queue fairness
     7// leader_spin.cfa -- validates ready queue fairness
    88//
    99// Author           : Thierry Delisle
  • tests/concurrency/waituntil/locks.cfa

    r2b78949 r8a930c03  
    22#include <thread.hfa>
    33#include <locks.hfa>
     4#include <fstream.hfa>
    45#include <mutex_stmt.hfa>
    56
  • tests/configs/.expect/parseconfig.txt

    r2b78949 r8a930c03  
    1212Maximum student trips: 3
    1313
    14 Open_Failure thrown when config file does not exist
     14open_failure thrown when config file does not exist
    1515Failed to open the config file
    1616
  • tests/configs/parseconfig.cfa

    r2b78949 r8a930c03  
    6666
    6767
    68         sout | "Open_Failure thrown when config file does not exist";
     68        sout | "open_failure thrown when config file does not exist";
    6969        try {
    7070                parse_config( xstr(IN_DIR) "doesnt-exist.txt", entries, NUM_ENTRIES, parse_tabular_config_format );
    71         } catch( Open_Failure * ex ) {
     71        } catch( open_failure * ex ) {
    7272                sout | "Failed to open the config file";
    7373        }
  • tests/copyfile.cfa

    r2b78949 r8a930c03  
    1010// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug 15 15:00:48 2020
    13 // Update Count     : 6
     12// Last Modified On : Mon Jun  5 21:20:19 2023
     13// Update Count     : 7
    1414//
    1515
     
    3030                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3131                } // choose
    32         } catch( Open_Failure * ex ; ex->istream == &in ) {
     32        } catch( open_failure * ex ; ex->istream == &in ) {
    3333                exit | "Unable to open input file" | argv[1];
    34         } catch( Open_Failure * ex ; ex->ostream == &out ) {
     34        } catch( open_failure * ex ; ex->ostream == &out ) {
    3535                close( in );                                                                    // optional
    3636                exit | "Unable to open output file" | argv[2];
  • tests/rational.cfa

    r2b78949 r8a930c03  
    1010// Created On       : Mon Mar 28 08:43:12 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 20 18:13:40 2021
    13 // Update Count     : 107
     12// Last Modified On : Mon Jun  5 22:58:09 2023
     13// Update Count     : 108
    1414//
    1515
     
    1919#include <fstream.hfa>
    2020
    21 typedef Rational(int) RatInt;
     21typedef rational(int) rat_int;
    2222double convert( int i ) { return (double)i; }                   // used by narrow/widen
    2323int convert( double d ) { return (int)d; }
     
    2525int main() {
    2626        sout | "constructor";
    27         RatInt a = { 3 }, b = { 4 }, c, d = 0, e = 1;
     27        rat_int a = { 3 }, b = { 4 }, c, d = 0, e = 1;
    2828        sout | "a : " | a | "b : " | b | "c : " | c | "d : " | d | "e : " | e;
    2929
    30         a = (RatInt){ 4, 8 };
    31         b = (RatInt){ 5, 7 };
     30        a = (rat_int){ 4, 8 };
     31        b = (rat_int){ 5, 7 };
    3232        sout | "a : " | a | "b : " | b;
    33         a = (RatInt){ -2, -3 };
    34         b = (RatInt){ 3, -2 };
     33        a = (rat_int){ -2, -3 };
     34        b = (rat_int){ 3, -2 };
    3535        sout | "a : " | a | "b : " | b;
    36         a = (RatInt){ -2, 3 };
    37         b = (RatInt){ 3, 2 };
     36        a = (rat_int){ -2, 3 };
     37        b = (rat_int){ 3, 2 };
    3838        sout | "a : " | a | "b : " | b;
    3939        sout | nl;
    4040
    4141        sout | "comparison";
    42         a = (RatInt){ -2 };
    43         b = (RatInt){ -3, 2 };
     42        a = (rat_int){ -2 };
     43        b = (rat_int){ -3, 2 };
    4444        sout | "a : " | a | "b : " | b;
    45         sout | "a == 0 : " | a == (Rational(int)){0}; // FIX ME
    46         sout | "a == 1 : " | a == (Rational(int)){1}; // FIX ME
     45        sout | "a == 0 : " | a == (rational(int)){0}; // FIX ME
     46        sout | "a == 1 : " | a == (rational(int)){1}; // FIX ME
    4747        sout | "a != 0 : " | a != 0;
    4848        sout | "! a : " | ! a;
     
    7373
    7474        sout | "conversion";
    75         a = (RatInt){ 3, 4 };
     75        a = (rat_int){ 3, 4 };
    7676        sout | widen( a );
    77         a = (RatInt){ 1, 7 };
     77        a = (rat_int){ 1, 7 };
    7878        sout | widen( a );
    79         a = (RatInt){ 355, 113 };
     79        a = (rat_int){ 355, 113 };
    8080        sout | widen( a );
    8181        sout | narrow( 0.75, 4 );
     
    9090
    9191        sout | "more tests";
    92         RatInt x = { 1, 2 }, y = { 2 };
     92        rat_int x = { 1, 2 }, y = { 2 };
    9393        sout | x - y;
    9494        sout | x > y;
     
    9696        sout | y | denominator( y, -2 ) | y;
    9797
    98         RatInt z = { 0, 5 };
     98        rat_int z = { 0, 5 };
    9999        sout | z;
    100100
    101101        sout | x | numerator( x, 0 ) | x;
    102102
    103         x = (RatInt){ 1, MAX } + (RatInt){ 1, MAX };
     103        x = (rat_int){ 1, MAX } + (rat_int){ 1, MAX };
    104104        sout | x;
    105         x = (RatInt){ 3, MAX } + (RatInt){ 2, MAX };
     105        x = (rat_int){ 3, MAX } + (rat_int){ 2, MAX };
    106106        sout | x;
    107107
Note: See TracChangeset for help on using the changeset viewer.