- Timestamp:
- Jun 24, 2020, 5:00:59 PM (4 years ago)
- 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. - Location:
- tests
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/.expect/copyfile.txt
r9791ab5 r8b58bae 8 8 // 9 9 // Author : Peter A. Buhr 10 // Created On : Tue Jul 16 16:47:22 201910 // Created On : Fri Jun 19 13:44:05 2020 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 1 09:10:58202013 // Update Count : 2812 // Last Modified On : Fri Jun 19 17:58:03 2020 13 // Update Count : 4 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include < stdlib.hfa> // new/delete17 #include <exception.hfa> 18 18 19 19 int 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 22 23 try { 23 24 choose ( argc ) { 24 25 case 2, 3: 25 &in = new( (const char *)argv[1] );// open input file first as output creates file26 if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent27 case 1: ; // use default files26 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 28 29 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) ] ]"; 30 31 } // 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 31 38 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 35 41 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 45 48 } // main 46 49 -
tests/.expect/time.txt
r9791ab5 r8b58bae 1 1 10800 2 3.375 12 1.00001 2 0.125 0.0333333333333333 3.375 12000. 1000010. 2 3 0 2 3.375 3 4 7 7 7 -
tests/.in/copyfile.txt
r9791ab5 r8b58bae 8 8 // 9 9 // Author : Peter A. Buhr 10 // Created On : Tue Jul 16 16:47:22 201910 // Created On : Fri Jun 19 13:44:05 2020 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 1 09:10:58202013 // Update Count : 2812 // Last Modified On : Fri Jun 19 17:58:03 2020 13 // Update Count : 4 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include < stdlib.hfa> // new/delete17 #include <exception.hfa> 18 18 19 19 int 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 22 23 try { 23 24 choose ( argc ) { 24 25 case 2, 3: 25 &in = new( (const char *)argv[1] );// open input file first as output creates file26 if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent27 case 1: ; // use default files26 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 28 29 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) ] ]"; 30 31 } // 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 31 38 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 35 41 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 45 48 } // main 46 49 -
tests/copyfile.cfa
r9791ab5 r8b58bae 8 8 // 9 9 // Author : Peter A. Buhr 10 // Created On : Tue Jul 16 16:47:22 201910 // Created On : Fri Jun 19 13:44:05 2020 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 1 09:10:58202013 // Update Count : 2812 // Last Modified On : Fri Jun 19 17:58:03 2020 13 // Update Count : 4 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include < stdlib.hfa> // new/delete17 #include <exception.hfa> 18 18 19 19 int 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 22 23 try { 23 24 choose ( argc ) { 24 25 case 2, 3: 25 &in = new( (const char *)argv[1] );// open input file first as output creates file26 if ( argc == 3 ) &out = new( (const char *)argv[2] ); // only open output if input opens as output created if nonexistent27 case 1: ; // use default files26 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 28 29 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) ] ]"; 30 31 } // 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 31 38 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 35 41 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 45 48 } // main 46 49 -
tests/exceptions/.expect/resume.txt
r9791ab5 r8b58bae 31 31 inner catch 32 32 outer catch 33 34 throw 35 rethrow 36 handle -
tests/exceptions/.expect/terminate.txt
r9791ab5 r8b58bae 29 29 inner catch 30 30 outer catch 31 32 throw 33 rethrow 34 handle -
tests/exceptions/resume.cfa
r9791ab5 r8b58bae 8 8 TRIVIAL_EXCEPTION(zen); 9 9 TRIVIAL_EXCEPTION(moment_of, zen); 10 11 void in_void(void); 10 12 11 13 int main(int argc, char * argv[]) { … … 121 123 printf("outer catch\n"); 122 124 } 125 printf("\n"); 126 127 in_void(); 123 128 } 129 130 // Do a throw and rethrow in a void function. 131 void 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 8 8 TRIVIAL_EXCEPTION(zen); 9 9 TRIVIAL_EXCEPTION(moment_of, zen); 10 11 void in_void(void); 10 12 11 13 int main(int argc, char * argv[]) { … … 121 123 printf("outer catch\n"); 122 124 } 125 printf("\n"); 126 127 in_void(); 123 128 } 129 130 // Do a throw and rethrow in a void function. 131 void 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 10 10 // Created On : Tue Mar 27 17:24:56 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Jan 5 18:27:37202013 // Update Count : 3 412 // Last Modified On : Thu Jun 18 18:14:49 2020 13 // Update Count : 37 14 14 // 15 15 … … 20 20 Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns; 21 21 sout | d1 | d2 | d3 | d4 | d5; 22 sout | d1`dd | d2`dm | d3`ds | d4`dms | d5`dus; 22 23 d1 = 0; 23 24 sout | d1 | d2 | d3;
Note: See TracChangeset
for help on using the changeset viewer.