source: tests/exceptions/conditional.cfa @ df8ba61a

Last change on this file since df8ba61a was fe0b94f, checked in by Peter A. Buhr <pabuhr@…>, 12 months ago

fix include files

  • Property mode set to 100644
File size: 845 bytes
Line 
1// Conditional Catch Test
2
3// I may fold this back into terminate.cfa and resume.cfa once setting
4// up the non-trivial exception is reasonable to do.
5
6#include <fstream.hfa>
7
8exception num_error {
9        int num;
10};
11
12vtable(num_error) num_error_vt;
13
14void caught_num_error(int expect, num_error * actual) {
15        sout | "Caught num_error: expected=" | expect | "actual=" | actual->num | '.';
16}
17
18int main(int argc, char * argv[]) {
19        num_error exc = {&num_error_vt, 2};
20
21        try {
22                throw exc;
23        } catch (num_error * error ; 3 == error->num ) {
24                caught_num_error(3, error);
25        } catch (num_error * error ; 2 == error->num ) {
26                caught_num_error(2, error);
27        }
28
29        try {
30                throwResume exc;
31        } catchResume (num_error * error ; 3 == error->num ) {
32                caught_num_error(3, error);
33        } catchResume (num_error * error ; 2 == error->num ) {
34                caught_num_error(2, error);
35        }
36}
Note: See TracBrowser for help on using the repository browser.