Changeset e68d092 for tests/exceptions
- Timestamp:
- May 7, 2020, 11:25:15 AM (5 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:
- 8e16177, af7acb9
- Parents:
- d6566c1
- Location:
- tests/exceptions
- Files:
-
- 2 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified tests/exceptions/conditional.cfa ¶
rd6566c1 re68d092 4 4 // up the non-trivial exception is reasonable to do. 5 5 6 #include "except-mac.hfa"6 #include <exception.hfa> 7 7 #include <stdio.h> 8 8 9 DECLARE_EXCEPT(num_error, BASE_EXCEPT, 9 VTABLE_DECLARATION(num_error)( 10 10 int (*code)(num_error *this); 11 11 ); … … 36 36 this.num = other.num; 37 37 } 38 void copy(num_error * this, num_error * other) {39 *this = *other;40 }41 38 void ^?{}(num_error & this) { 42 39 if( this.msg ) free( this.msg ); … … 46 43 } 47 44 48 VTABLE_INSTANCE(num_error, BASE_EXCEPT, copy, ^?{}, 49 num_error_msg, num_error_code 45 VTABLE_INSTANCE(num_error)( 46 num_error_msg, 47 num_error_code, 50 48 ); 51 49 … … 58 56 59 57 try { 60 THROW(&exc);58 throw &exc; 61 59 } catch (num_error * error ; 3 == error->virtual_table->code( error )) { 62 60 caught_num_error(3, error); … … 66 64 67 65 try { 68 THROW_RESUME(&exc);66 throwResume &exc; 69 67 } catchResume (num_error * error ; 3 == error->virtual_table->code( error )) { 70 68 caught_num_error(3, error); -
TabularUnified tests/exceptions/finally.cfa ¶
rd6566c1 re68d092 1 1 // Finally Clause Tests 2 2 3 #include "except-mac.hfa"3 #include <exception.hfa> 4 4 #include "except-io.hfa" 5 5 … … 12 12 try { 13 13 printf("termination throw\n"); 14 THROW(&exc);14 throw &exc; 15 15 } finally { 16 16 loud_exit a = "termination inner finally"; … … 28 28 try { 29 29 printf("resumption throw\n"); 30 THROW_RESUME(&exc);30 throwResume &exc; 31 31 } finally { 32 32 loud_exit a = "resumption inner finally"; -
TabularUnified tests/exceptions/interact.cfa ¶
rd6566c1 re68d092 1 1 // Testing Interactions Between Termination and Resumption 2 2 3 #include "except-mac.hfa"3 #include <exception.hfa> 4 4 #include "except-io.hfa" 5 5 … … 10 10 // Resume falls back to terminate. 11 11 try { 12 THROW_RESUME(&(star){});12 throwResume &(star){}; 13 13 } catch (star *) { 14 14 printf("caught as termination\n"); … … 17 17 try { 18 18 loud_region a = "try block with resume throw"; 19 THROW_RESUME(&(star){});19 throwResume &(star){}; 20 20 } catch (star *) { 21 21 printf("caught as termination\n"); … … 29 29 try { 30 30 try { 31 THROW(&(star){});31 throw &(star){}; 32 32 } catchResume (star *) { 33 33 printf("resume catch on terminate\n"); … … 43 43 try { 44 44 try { 45 THROW_RESUME(&(star){});45 throwResume &(star){}; 46 46 } catch (star *) { 47 47 printf("terminate catch on resume\n"); … … 58 58 try { 59 59 try { 60 THROW(&(star){});60 throw &(star){}; 61 61 } catchResume (star *) { 62 62 printf("inner resume catch (error)\n"); … … 64 64 } catch (star * error) { 65 65 printf("termination catch, will resume\n"); 66 THROW_RESUME(error);66 throwResume error; 67 67 } 68 68 } catchResume (star *) { … … 75 75 try { 76 76 try { 77 THROW_RESUME(&(star){});77 throwResume &(star){}; 78 78 } catch (star *) { 79 79 printf("inner termination catch\n"); … … 81 81 } catchResume (star * error) { 82 82 printf("resumption catch, will terminate\n"); 83 THROW(error);83 throw error; 84 84 } 85 85 } catch (star *) { … … 94 94 try { 95 95 printf("throwing resume moon\n"); 96 THROW_RESUME(&(moon){});96 throwResume &(moon){}; 97 97 } catch (star *) { 98 98 printf("termination catch\n"); 99 99 } 100 100 printf("throwing resume star\n"); 101 THROW_RESUME(&(star){});101 throwResume &(star){}; 102 102 } catchResume (star *) { 103 103 printf("resumption star catch\n"); … … 105 105 } catchResume (moon *) { 106 106 printf("resumption moon catch, will terminate\n"); 107 THROW(&(star){});107 throw &(star){}; 108 108 } 109 109 } catchResume (star *) { -
TabularUnified tests/exceptions/resume.cfa ¶
rd6566c1 re68d092 1 1 // Resumption Exception Tests 2 2 3 #include "except-mac.hfa"3 #include <exception.hfa> 4 4 #include "except-io.hfa" 5 5 … … 14 14 loud_exit a = "simple try clause"; 15 15 printf("simple throw\n"); 16 THROW_RESUME(&(zen){});16 throwResume &(zen){}; 17 17 printf("end of try clause\n"); 18 18 } catchResume (zen * error) { … … 25 25 try { 26 26 printf("throwing child exception\n"); 27 THROW_RESUME(&(moment_of){});27 throwResume &(moment_of){}; 28 28 } catchResume (zen *) { 29 29 printf("inner parent match\n"); … … 36 36 try { 37 37 try { 38 THROW_RESUME(&(yin){});38 throwResume &(yin){}; 39 39 } catchResume (zen *) { 40 40 printf("caught yin as zen\n"); … … 52 52 loud_exit a = "rethrow inner try"; 53 53 printf("rethrow inner try\n"); 54 THROW_RESUME(&(zen){});54 throwResume &(zen){}; 55 55 } catchResume (zen *) { 56 56 loud_exit a = "rethrowing catch clause"; … … 67 67 try { 68 68 try { 69 THROW_RESUME(&(yin){});69 throwResume &(yin){}; 70 70 } catchResume (yin *) { 71 71 printf("caught yin, will throw yang\n"); 72 THROW_RESUME(&(yang){});72 throwResume &(yang){}; 73 73 } catchResume (yang *) { 74 74 printf("caught exception from same try\n"); … … 83 83 try { 84 84 printf("throwing first exception\n"); 85 THROW_RESUME(&(yin){});85 throwResume &(yin){}; 86 86 } catchResume (yin *) { 87 87 printf("caught first exception\n"); 88 88 try { 89 89 printf("throwing second exception\n"); 90 THROW_RESUME(&(yang){});90 throwResume &(yang){}; 91 91 } catchResume (yang *) { 92 92 printf("caught second exception\n"); … … 104 104 try { 105 105 try { 106 THROW_RESUME(&(zen){});107 THROW_RESUME(&(zen){});106 throwResume &(zen){}; 107 throwResume &(zen){}; 108 108 } catchResume (zen *) { 109 109 printf("inner catch\n"); 110 110 } 111 THROW_RESUME(&(zen){});111 throwResume &(zen){}; 112 112 } catchResume (zen *) { 113 113 printf("outer catch\n"); -
TabularUnified tests/exceptions/terminate.cfa ¶
rd6566c1 re68d092 1 1 // Termination Exception Tests 2 2 3 #include "except-mac.hfa"3 #include <exception.hfa> 4 4 #include "except-io.hfa" 5 5 … … 14 14 loud_exit a = "simple try clause"; 15 15 printf("simple throw\n"); 16 THROW(&(zen){});16 throw &(zen){}; 17 17 printf("end of try clause\n"); 18 18 } catch (zen * error) { … … 25 25 try { 26 26 printf("throwing child exception\n"); 27 THROW(&(moment_of){});27 throw &(moment_of){}; 28 28 } catch (zen *) { 29 29 printf("inner parent match\n"); … … 36 36 try { 37 37 try { 38 THROW(&(yin){});38 throw &(yin){}; 39 39 } catch (zen *) { 40 40 printf("caught yin as zen\n"); … … 52 52 loud_exit a = "rethrow inner try"; 53 53 printf("rethrow inner try\n"); 54 THROW(&(zen){});54 throw &(zen){}; 55 55 } catch (zen *) { 56 56 loud_exit a = "rethrowing catch clause"; … … 67 67 try { 68 68 try { 69 THROW(&(yin){});69 throw &(yin){}; 70 70 } catch (yin *) { 71 71 printf("caught yin, will throw yang\n"); 72 THROW(&(yang){});72 throw &(yang){}; 73 73 } catch (yang *) { 74 74 printf("caught exception from same try\n"); … … 83 83 try { 84 84 printf("throwing first exception\n"); 85 THROW(&(yin){});85 throw &(yin){}; 86 86 } catch (yin *) { 87 87 printf("caught first exception\n"); 88 88 try { 89 89 printf("throwing second exception\n"); 90 THROW(&(yang){});90 throw &(yang){}; 91 91 } catch (yang *) { 92 92 printf("caught second exception\n"); … … 104 104 try { 105 105 try { 106 THROW(&(zen){});107 THROW(&(zen){});106 throw &(zen){}; 107 throw &(zen){}; 108 108 } catch (zen *) { 109 109 printf("inner catch\n"); 110 110 } 111 THROW(&(zen){});111 throw &(zen){}; 112 112 } catch (zen *) { 113 113 printf("outer catch\n");
Note: See TracChangeset
for help on using the changeset viewer.