Changes in tests/exceptions/terminate.cfa [3bf9d10:d00d581]
- File:
-
- 1 edited
-
tests/exceptions/terminate.cfa (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/exceptions/terminate.cfa
r3bf9d10 rd00d581 1 1 // Termination Exception Tests 2 2 3 #include <fstream.hfa>4 3 #include "except-io.hfa" 5 4 … … 22 21 try { 23 22 loud_exit a = "simple try clause"; 24 sout | "simple throw";23 printf("simple throw\n"); 25 24 throw a_zen; 26 sout | "end of try clause";25 printf("end of try clause\n"); 27 26 } catch (zen * error) { 28 27 loud_exit a = "simple catch clause"; 29 sout | "simple catch";28 printf("simple catch\n"); 30 29 } 31 sout | nl;30 printf("\n"); 32 31 33 32 // Throw catch-all test. … … 35 34 throw a_zen; 36 35 } catch (exception_t * error) { 37 sout | "catch-all";36 printf("catch-all\n"); 38 37 } 39 sout | nl;38 printf("\n"); 40 39 41 40 // Don't catch if handler does not match exception. … … 44 43 throw a_yin; 45 44 } catch (zen *) { 46 sout | "caught yin as zen";45 printf("caught yin as zen\n"); 47 46 } 48 47 } catch (yang *) { 49 sout | "caught yin as yang";48 printf("caught yin as yang\n"); 50 49 } catch (yin *) { 51 sout | "caught yin as yin";50 printf("caught yin as yin\n"); 52 51 } 53 sout | nl;52 printf("\n"); 54 53 55 54 // Test rethrowing an exception. … … 57 56 try { 58 57 loud_exit a = "rethrow inner try"; 59 sout | "rethrow inner try";58 printf("rethrow inner try\n"); 60 59 throw a_zen; 61 60 } catch (zen *) { 62 61 loud_exit a = "rethrowing catch clause"; 63 sout | "caught throw, will rethrow";62 printf("caught throw, will rethrow\n"); 64 63 throw; 65 64 } 66 65 } catch (zen *) { 67 66 loud_exit a = "rethrow catch clause"; 68 sout | "caught rethrow";67 printf("caught rethrow\n"); 69 68 } 70 sout | nl;69 printf("\n"); 71 70 72 71 // Throw a different exception in a catch. … … 75 74 throw a_yin; 76 75 } catch (yin *) { 77 sout | "caught yin, will throw yang";76 printf("caught yin, will throw yang\n"); 78 77 throw a_yang; 79 78 } catch (yang *) { 80 sout | "caught exception from same try";79 printf("caught exception from same try\n"); 81 80 } 82 81 } catch (yang *) { 83 sout | "caught yang";82 printf("caught yang\n"); 84 83 } 85 sout | nl;84 printf("\n"); 86 85 87 86 // Another throw in the catch does not interfere. 88 87 try { 89 88 try { 90 sout | "throwing first exception";89 printf("throwing first exception\n"); 91 90 throw a_yin; 92 91 } catch (yin *) { 93 sout | "caught first exception";92 printf("caught first exception\n"); 94 93 try { 95 sout | "throwing second exception";94 printf("throwing second exception\n"); 96 95 throw a_yang; 97 96 } catch (yang *) { 98 sout | "caught second exception";97 printf("caught second exception\n"); 99 98 } 100 99 throw; 101 100 } 102 101 } catch (yin *) { 103 sout | "recaught first exception";102 printf("recaught first exception\n"); 104 103 } catch (yang *) { 105 sout | "caught second exception (bad location)";104 printf("caught second exception (bad location)\n"); 106 105 } 107 sout | nl;106 printf("\n"); 108 107 109 108 // Check successive operations. … … 113 112 throw a_zen; 114 113 } catch (zen *) { 115 sout | "inner catch";114 printf("inner catch\n"); 116 115 } 117 116 throw a_zen; 118 117 } catch (zen *) { 119 sout | "outer catch";118 printf("outer catch\n"); 120 119 } 121 sout | nl;120 printf("\n"); 122 121 123 122 in_void(); … … 129 128 try { 130 129 try { 131 sout | "throw";130 printf("throw\n"); 132 131 throw a_zen; 133 132 } catch (zen *) { 134 sout | "rethrow";133 printf("rethrow\n"); 135 134 throw; 136 135 } 137 136 } catch (zen *) { 138 sout | "handle";137 printf("handle\n"); 139 138 } 140 139 }
Note:
See TracChangeset
for help on using the changeset viewer.