Changeset 3bf9d10 for tests/exceptions/interact.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/interact.cfa
r2de175ce r3bf9d10 1 1 // Testing Interactions Between Termination and Resumption 2 2 3 #include <fstream.hfa> 3 4 #include "except-io.hfa" 4 5 … … 14 15 throwResume (star){&star_vt}; 15 16 } catch (star *) { 16 printf("caught as termination\n");17 sout | "caught as termination"; 17 18 } 18 19 // Variant of the above to check timing. … … 21 22 throwResume (star){&star_vt}; 22 23 } catch (star *) { 23 printf("caught as termination\n");24 sout | "caught as termination"; 24 25 } catchResume (star *) { 25 printf("intermediate rethrow\n");26 sout | "intermediate rethrow"; 26 27 throwResume; 27 28 } 28 printf("\n");29 sout | nl; 29 30 30 31 // Resume does not catch terminate. … … 33 34 throw (star){&star_vt}; 34 35 } catchResume (star *) { 35 printf("resume catch on terminate\n");36 sout | "resume catch on terminate"; 36 37 } 37 38 } catchResume (star *) { 38 printf("resume catch on terminate\n");39 sout | "resume catch on terminate"; 39 40 } catch (star *) { 40 printf("terminate catch on terminate\n");41 sout | "terminate catch on terminate"; 41 42 } 42 printf("\n");43 sout | nl; 43 44 44 45 // Terminate does not catch resume. … … 47 48 throwResume (star){&star_vt}; 48 49 } catch (star *) { 49 printf("terminate catch on resume\n");50 sout | "terminate catch on resume"; 50 51 } 51 52 } catch (star *) { 52 printf("terminate catch on resume\n");53 sout | "terminate catch on resume"; 53 54 } catchResume (star *) { 54 printf("resume catch on resume\n");55 sout | "resume catch on resume"; 55 56 } 56 printf("\n");57 sout | nl; 57 58 58 59 // Resume a termination exception. … … 62 63 throw (star){&star_vt}; 63 64 } catchResume (star *) { 64 printf("inner resume catch (error)\n");65 sout | "inner resume catch (error)"; 65 66 } 66 67 } catch (star * error) { 67 printf("termination catch, will resume\n");68 sout | "termination catch, will resume"; 68 69 throwResume *error; 69 70 } 70 71 } catchResume (star *) { 71 printf("outer resume catch\n");72 sout | "outer resume catch"; 72 73 } 73 printf("\n");74 sout | nl; 74 75 75 76 // Terminate a resumption exception. … … 79 80 throwResume (star){&star_vt}; 80 81 } catch (star *) { 81 printf("inner termination catch\n");82 sout | "inner termination catch"; 82 83 } 83 84 } catchResume (star * error) { 84 printf("resumption catch, will terminate\n");85 sout | "resumption catch, will terminate"; 85 86 throw *error; 86 87 } 87 88 } catch (star *) { 88 printf("outer terminate catch (error)\n");89 sout | "outer terminate catch (error)"; 89 90 } 90 printf("\n");91 sout | nl; 91 92 92 93 // Unwinding a resumption catch does not break the system. … … 95 96 try { 96 97 try { 97 printf("throwing resume moon\n");98 sout | "throwing resume moon"; 98 99 throwResume (moon){&moon_vt}; 99 100 } catch (star *) { 100 printf("termination catch\n");101 sout | "termination catch"; 101 102 } 102 printf("throwing resume star\n");103 sout | "throwing resume star"; 103 104 throwResume (star){&star_vt}; 104 105 } catchResume (star *) { 105 printf("resumption star catch\n");106 sout | "resumption star catch"; 106 107 } 107 108 } catchResume (moon *) { 108 printf("resumption moon catch, will terminate\n");109 sout | "resumption moon catch, will terminate"; 109 110 throw (star){&star_vt}; 110 111 } 111 112 } catchResume (star *) { 112 printf("outermost catch (error)\n");113 sout | "outermost catch (error)"; 113 114 } 114 115 }
Note: See TracChangeset
for help on using the changeset viewer.