Ignore:
Timestamp:
May 18, 2025, 11:24:01 AM (4 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
e25b30b
Parents:
0528d79
Message:

update enumerator input test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/enum_tests/input.cfa

    r0528d79 r1e28e05  
    22
    33int main() {
    4         enum(int) E { BBB = 3, AAA, AA, AB, B, CB, AC };
    5         E e;
     4        { // enumerators small to large
     5                enum(int) E { B, AB, AA, AAA, BBB };
     6                E e;
    67
    7         try {
    8                 for () {
    9                         try {
    10                                 sin | e;
    11                         } catch( missing_data * ) {
    12                                 sout | "missing data";
    13                                 continue;                                                               // try again
    14                         } // try
    15                         sout | e | "= " | value( e );
    16                 } // for
    17         } catch( end_of_file * ) {
    18         } // try
     8                try {
     9                        for ( 14 ) {                                                            // eums in input
     10                                try {
     11                                        sin | e;
     12                                } catch( missing_data * ) {
     13                                        sout | "missing data";
     14                                        continue;                                                       // try again
     15                                } // try
     16                                sout | e | nonl;
     17                        } // for
     18                } catch( end_of_file * ) {
     19                        abort( "enum test failure" );
     20                } // try
     21                sout | nl;
     22        }
     23        sout | nl;
     24        { // enumerators large to small
     25                enum(int) E { BBB, AAA, AA, AB, B };
     26                E e;
     27
     28                try {
     29                        for ( 14 ) {                                                            // eums in input
     30                                try {
     31                                        sin | e;
     32                                } catch( missing_data * ) {
     33                                        sout | "missing data";
     34                                        continue;                                                       // try again
     35                                } // try
     36                                sout | e | nonl;
     37                        } // for
     38                } catch( end_of_file * ) {
     39                        abort( "enum test failure" );
     40                } // try
     41                sout | nl | nl;
     42        }
     43        { // enumerators small to large, overlapping patterns
     44                enum(int) E { A, B, BB, AB, BA, AA, AAA, ABA, AAB, BBB, BBA, BAB };
     45                E e;
     46
     47                try {
     48                        for ( 3 ) {                                                                     // N rows
     49                                for ( countof( E ) ) {                                  // eums in input
     50                                        try {
     51                                                sin | e;
     52                                        } catch( missing_data * ) {
     53                                                sout | "missing data";
     54                                                continue;                                               // try again
     55                                        } // try
     56                                        sout | e | nonl;
     57                                } // for
     58                                sout | nl;
     59                        } // for
     60                } catch( end_of_file * ) {
     61                        abort( "enum test failure" );
     62                } // try
     63                sout | nl;
     64        }
     65        { // enumerators large to small, overlapping patterns
     66                enum(int) E { BAB, BBA, BBB, AAB, ABA, AAA, AA, BA, AB, BB, B, A };
     67                E e;
     68
     69                try {
     70                        for ( 3 ) {                                                                     // N rows
     71                                for ( countof( E ) ) {                                  // eums in input
     72                                        try {
     73                                                sin | e;
     74                                        } catch( missing_data * ) {
     75                                                sout | "missing data";
     76                                                continue;                                               // try again
     77                                        } // try
     78                                        sout | e | nonl;
     79                                } // for
     80                                sout | nl;
     81                        } // for
     82                } catch( end_of_file * ) {
     83                        abort( "enum test failure" );
     84                } // try
     85                sout | nl;
     86        }
     87        { // general, end of file
     88                enum(int) E { BBB = 3, AAA, AA, AB, B, CB, AC };
     89                E e;
     90
     91                try {
     92                        for () {
     93                                try {
     94                                        sin | e;
     95                                } catch( missing_data * ) {
     96                                        sout | "missing data";
     97                                        continue;                                                       // try again
     98                                } // try
     99                                sout | e | "= " | value( e ) | nonl;
     100                        } // for
     101                } catch( end_of_file * ) {
     102                } // try
     103        }
    19104} // main
Note: See TracChangeset for help on using the changeset viewer.