Changeset 8b58bae for tests


Ignore:
Timestamp:
Jun 24, 2020, 5:00:59 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
c953163
Parents:
9791ab5 (diff), 7f9968a (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' into relaxed_ready

Location:
tests
Files:
9 edited

Legend:

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

    r9791ab5 r8b58bae  
    88//
    99// Author           : Peter A. Buhr
    10 // Created On       : Tue Jul 16 16:47:22 2019
     10// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  1 09:10:58 2020
    13 // Update Count     : 28
     12// Last Modified On : Fri Jun 19 17:58:03 2020
     13// Update Count     : 4
    1414//
    1515
    1616#include <fstream.hfa>
    17 #include <stdlib.hfa>                                                                   // new/delete
     17#include <exception.hfa>
    1818
    1919int main( int argc, char * argv[] ) {
    20         ifstream & in  = stdin;                                                         // default files
    21         ofstream & out = stdout;
     20        ifstream in  = stdin;                                                           // copy default files
     21        ofstream out = stdout;
     22
    2223        try {
    2324                choose ( argc ) {
    2425                  case 2, 3:
    25                           &in = new( (const char *)argv[1] );           // open input file first as output creates file
    26                           if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent
    27                   case 1: ;                                     // use default files
     26                        open( in, argv[1] );                                            // open input file first as output creates file
     27                        if ( argc == 3 ) open( out, argv[2] );          // do not create output unless input opens
     28                  case 1: ;                                                                             // use default files
    2829                  default:
    29                           exit | "Usage [ input-file (default stdin) [ output-file (default stdout) ] ]";
     30                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3031                } // choose
     32        } catch( Open_Failure * ex ; ex->istream == &in ) {
     33                exit | "Unable to open input file" | argv[1];
     34        } catch( Open_Failure * ex ; ex->ostream == &out ) {
     35                close( in );                                                                    // optional
     36                exit | "Unable to open output file" | argv[2];
     37        } // try
    3138
    32                 char ch;
    33                 out | nlOff;                                                                    // turn off auto newline
    34                 in  | nlOn;                                                                             // turn on reading newline
     39        out | nlOff;                                                                            // turn off auto newline
     40        in  | nlOn;                                                                                     // turn on reading newline
    3541
    36                 for () {                                                                                // read all characters
    37                         in | ch;
    38                   if ( eof( in ) ) break;                                               // eof ?
    39                         out | ch;
    40                 } // for
    41         } finally {
    42                 if ( &in  != &stdin  ) delete( &in );                   // close file, do not delete stdin!
    43                 if ( &out != &stdout ) delete( &out );                  // close file, do not delete stdout!
    44         } // try
     42        char ch;
     43        for () {                                                                                        // read all characters
     44                in | ch;
     45          if ( eof( in ) ) break;                                                       // eof ?
     46                out | ch;
     47        } //for
    4548} // main
    4649
  • tests/.expect/time.txt

    r9791ab5 r8b58bae  
    1110800 2 3.375 12 1.00001
     20.125 0.0333333333333333 3.375 12000. 1000010.
    230 2 3.375
    347 7 7
  • tests/.in/copyfile.txt

    r9791ab5 r8b58bae  
    88//
    99// Author           : Peter A. Buhr
    10 // Created On       : Tue Jul 16 16:47:22 2019
     10// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  1 09:10:58 2020
    13 // Update Count     : 28
     12// Last Modified On : Fri Jun 19 17:58:03 2020
     13// Update Count     : 4
    1414//
    1515
    1616#include <fstream.hfa>
    17 #include <stdlib.hfa>                                                                   // new/delete
     17#include <exception.hfa>
    1818
    1919int main( int argc, char * argv[] ) {
    20         ifstream & in  = stdin;                                                         // default files
    21         ofstream & out = stdout;
     20        ifstream in  = stdin;                                                           // copy default files
     21        ofstream out = stdout;
     22
    2223        try {
    2324                choose ( argc ) {
    2425                  case 2, 3:
    25                           &in = new( (const char *)argv[1] );           // open input file first as output creates file
    26                           if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent
    27                   case 1: ;                                     // use default files
     26                        open( in, argv[1] );                                            // open input file first as output creates file
     27                        if ( argc == 3 ) open( out, argv[2] );          // do not create output unless input opens
     28                  case 1: ;                                                                             // use default files
    2829                  default:
    29                           exit | "Usage [ input-file (default stdin) [ output-file (default stdout) ] ]";
     30                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3031                } // choose
     32        } catch( Open_Failure * ex ; ex->istream == &in ) {
     33                exit | "Unable to open input file" | argv[1];
     34        } catch( Open_Failure * ex ; ex->ostream == &out ) {
     35                close( in );                                                                    // optional
     36                exit | "Unable to open output file" | argv[2];
     37        } // try
    3138
    32                 char ch;
    33                 out | nlOff;                                                                    // turn off auto newline
    34                 in  | nlOn;                                                                             // turn on reading newline
     39        out | nlOff;                                                                            // turn off auto newline
     40        in  | nlOn;                                                                                     // turn on reading newline
    3541
    36                 for () {                                                                                // read all characters
    37                         in | ch;
    38                   if ( eof( in ) ) break;                                               // eof ?
    39                         out | ch;
    40                 } // for
    41         } finally {
    42                 if ( &in  != &stdin  ) delete( &in );                   // close file, do not delete stdin!
    43                 if ( &out != &stdout ) delete( &out );                  // close file, do not delete stdout!
    44         } // try
     42        char ch;
     43        for () {                                                                                        // read all characters
     44                in | ch;
     45          if ( eof( in ) ) break;                                                       // eof ?
     46                out | ch;
     47        } //for
    4548} // main
    4649
  • tests/copyfile.cfa

    r9791ab5 r8b58bae  
    88//
    99// Author           : Peter A. Buhr
    10 // Created On       : Tue Jul 16 16:47:22 2019
     10// Created On       : Fri Jun 19 13:44:05 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  1 09:10:58 2020
    13 // Update Count     : 28
     12// Last Modified On : Fri Jun 19 17:58:03 2020
     13// Update Count     : 4
    1414//
    1515
    1616#include <fstream.hfa>
    17 #include <stdlib.hfa>                                                                   // new/delete
     17#include <exception.hfa>
    1818
    1919int main( int argc, char * argv[] ) {
    20         ifstream & in  = stdin;                                                         // default files
    21         ofstream & out = stdout;
     20        ifstream in  = stdin;                                                           // copy default files
     21        ofstream out = stdout;
     22
    2223        try {
    2324                choose ( argc ) {
    2425                  case 2, 3:
    25                           &in = new( (const char *)argv[1] );           // open input file first as output creates file
    26                           if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent
    27                   case 1: ;                                     // use default files
     26                        open( in, argv[1] );                                            // open input file first as output creates file
     27                        if ( argc == 3 ) open( out, argv[2] );          // do not create output unless input opens
     28                  case 1: ;                                                                             // use default files
    2829                  default:
    29                           exit | "Usage [ input-file (default stdin) [ output-file (default stdout) ] ]";
     30                        exit | "Usage" | argv[0] | "[ input-file (default stdin) [ output-file (default stdout) ] ]";
    3031                } // choose
     32        } catch( Open_Failure * ex ; ex->istream == &in ) {
     33                exit | "Unable to open input file" | argv[1];
     34        } catch( Open_Failure * ex ; ex->ostream == &out ) {
     35                close( in );                                                                    // optional
     36                exit | "Unable to open output file" | argv[2];
     37        } // try
    3138
    32                 char ch;
    33                 out | nlOff;                                                                    // turn off auto newline
    34                 in  | nlOn;                                                                             // turn on reading newline
     39        out | nlOff;                                                                            // turn off auto newline
     40        in  | nlOn;                                                                                     // turn on reading newline
    3541
    36                 for () {                                                                                // read all characters
    37                         in | ch;
    38                   if ( eof( in ) ) break;                                               // eof ?
    39                         out | ch;
    40                 } // for
    41         } finally {
    42                 if ( &in  != &stdin  ) delete( &in );                   // close file, do not delete stdin!
    43                 if ( &out != &stdout ) delete( &out );                  // close file, do not delete stdout!
    44         } // try
     42        char ch;
     43        for () {                                                                                        // read all characters
     44                in | ch;
     45          if ( eof( in ) ) break;                                                       // eof ?
     46                out | ch;
     47        } //for
    4548} // main
    4649
  • tests/exceptions/.expect/resume.txt

    r9791ab5 r8b58bae  
    3131inner catch
    3232outer catch
     33
     34throw
     35rethrow
     36handle
  • tests/exceptions/.expect/terminate.txt

    r9791ab5 r8b58bae  
    2929inner catch
    3030outer catch
     31
     32throw
     33rethrow
     34handle
  • tests/exceptions/resume.cfa

    r9791ab5 r8b58bae  
    88TRIVIAL_EXCEPTION(zen);
    99TRIVIAL_EXCEPTION(moment_of, zen);
     10
     11void in_void(void);
    1012
    1113int main(int argc, char * argv[]) {
     
    121123                printf("outer catch\n");
    122124        }
     125        printf("\n");
     126
     127        in_void();
    123128}
     129
     130// Do a throw and rethrow in a void function.
     131void in_void(void) {
     132        try {
     133                try {
     134                        printf("throw\n");
     135                        throwResume (zen){};
     136                } catchResume (zen *) {
     137                        printf("rethrow\n");
     138                        throwResume;
     139                }
     140        } catchResume (zen *) {
     141                printf("handle\n");
     142        }
     143}
  • tests/exceptions/terminate.cfa

    r9791ab5 r8b58bae  
    88TRIVIAL_EXCEPTION(zen);
    99TRIVIAL_EXCEPTION(moment_of, zen);
     10
     11void in_void(void);
    1012
    1113int main(int argc, char * argv[]) {
     
    121123                printf("outer catch\n");
    122124        }
     125        printf("\n");
     126
     127        in_void();
    123128}
     129
     130// Do a throw and rethrow in a void function.
     131void in_void(void) {
     132        try {
     133                try {
     134                        printf("throw\n");
     135                        throw (zen){};
     136                } catch (zen *) {
     137                        printf("rethrow\n");
     138                        throw;
     139                }
     140        } catch (zen *) {
     141                printf("handle\n");
     142        }
     143}
     144
  • tests/time.cfa

    r9791ab5 r8b58bae  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Jan  5 18:27:37 2020
    13 // Update Count     : 34
     12// Last Modified On : Thu Jun 18 18:14:49 2020
     13// Update Count     : 37
    1414//
    1515
     
    2020        Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns;
    2121        sout | d1 | d2 | d3 | d4 | d5;
     22        sout | d1`dd | d2`dm | d3`ds | d4`dms | d5`dus;
    2223        d1 = 0;
    2324        sout | d1 | d2 | d3;
Note: See TracChangeset for help on using the changeset viewer.