ADT
ast-experimental
Last change
on this file since 116a2ea was d00d581, checked in by Henry Xue <y58xue@…>, 4 years ago |
Update exception tests to use new syntax
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[6d43cdde] | 1 | // Finally Clause Tests
|
---|
| 2 |
|
---|
| 3 | #include "except-io.hfa"
|
---|
| 4 |
|
---|
[d00d581] | 5 | exception myth {};
|
---|
[ecfd758] | 6 |
|
---|
[d00d581] | 7 | vtable(myth) myth_vt;
|
---|
[6d43cdde] | 8 |
|
---|
| 9 | int main(int argc, char * argv[]) {
|
---|
[ecfd758] | 10 | myth exc = {&myth_vt};
|
---|
[6d43cdde] | 11 |
|
---|
| 12 | try {
|
---|
| 13 | try {
|
---|
| 14 | printf("termination throw\n");
|
---|
[046a890] | 15 | throw exc;
|
---|
[6d43cdde] | 16 | } finally {
|
---|
| 17 | loud_exit a = "termination inner finally";
|
---|
| 18 | printf("finally during unwind\n");
|
---|
| 19 | }
|
---|
| 20 | } catch (myth * error) {
|
---|
| 21 | printf("termination catch\n");
|
---|
| 22 | } finally {
|
---|
| 23 | loud_exit a = "termination outer finally";
|
---|
| 24 | printf("finally after catch\n");
|
---|
| 25 | }
|
---|
| 26 | printf("\n");
|
---|
| 27 |
|
---|
| 28 | try {
|
---|
| 29 | try {
|
---|
| 30 | printf("resumption throw\n");
|
---|
[046a890] | 31 | throwResume exc;
|
---|
[6d43cdde] | 32 | } finally {
|
---|
| 33 | loud_exit a = "resumption inner finally";
|
---|
| 34 | printf("finally after resume\n");
|
---|
| 35 | }
|
---|
| 36 | } catchResume (myth * error) {
|
---|
| 37 | printf("resumption catch\n");
|
---|
| 38 | } finally {
|
---|
| 39 | loud_exit a = "resumption outer finally";
|
---|
| 40 | printf("finally after catch\n");
|
---|
| 41 | }
|
---|
| 42 | printf("\n");
|
---|
| 43 |
|
---|
| 44 | try {
|
---|
| 45 | printf("walking out of try\n");
|
---|
| 46 | } finally {
|
---|
| 47 | loud_exit a = "walking finally";
|
---|
| 48 | printf("walking through finally\n");
|
---|
| 49 | }
|
---|
| 50 | printf("\n");
|
---|
| 51 |
|
---|
| 52 | try {
|
---|
| 53 | printf("jumping out of try\n");
|
---|
| 54 | goto endoffunction;
|
---|
| 55 | } finally {
|
---|
| 56 | loud_exit a = "jumping finally";
|
---|
| 57 | printf("jumping through finally\n");
|
---|
| 58 | }
|
---|
| 59 | endoffunction:
|
---|
| 60 | ;
|
---|
| 61 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.