source: tests/exceptions/finally.cfa @ 474d610

arm-ehjacob/cs343-translationnew-ast-unique-expr
Last change on this file since 474d610 was 046a890, checked in by Andrew Beach <ajbeach@…>, 19 months ago

That should get default operations working for throws. More tests to come.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1// Finally Clause Tests
2
3#include <exception.hfa>
4#include "except-io.hfa"
5
6TRIVIAL_EXCEPTION(myth);
7
8int main(int argc, char * argv[]) {
9        myth exc;
10
11        try {
12                try {
13                        printf("termination throw\n");
14                        throw exc;
15                } finally {
16                        loud_exit a = "termination inner finally";
17                        printf("finally during unwind\n");
18                }
19        } catch (myth * error) {
20                printf("termination catch\n");
21        } finally {
22                loud_exit a = "termination outer finally";
23                printf("finally after catch\n");
24        }
25        printf("\n");
26
27        try {
28                try {
29                        printf("resumption throw\n");
30                        throwResume exc;
31                } finally {
32                        loud_exit a = "resumption inner finally";
33                        printf("finally after resume\n");
34                }
35        } catchResume (myth * error) {
36                printf("resumption catch\n");
37        } finally {
38                loud_exit a = "resumption outer finally";
39                printf("finally after catch\n");
40        }
41        printf("\n");
42
43        try {
44                printf("walking out of try\n");
45        } finally {
46                loud_exit a = "walking finally";
47                printf("walking through finally\n");
48        }
49        printf("\n");
50
51        try {
52                printf("jumping out of try\n");
53                goto endoffunction;
54        } finally {
55                loud_exit a = "jumping finally";
56                printf("jumping through finally\n");
57        }
58        endoffunction:
59        ;
60}
Note: See TracBrowser for help on using the repository browser.