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