source: tests/exceptions/conditional.cfa @ fe8aa21

ADTast-experimentalenumforall-pointer-decayjacob/cs343-translationpthread-emulationqualifiedEnum
Last change on this file since fe8aa21 was d00d581, checked in by Henry Xue <y58xue@…>, 3 years ago

Update exception tests to use new syntax

  • Property mode set to 100644
File size: 817 bytes
RevLine 
[6d43cdde]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
[d00d581]6exception num_error {
[ecfd758]7        int num;
[d00d581]8};
[6d43cdde]9
[d00d581]10vtable(num_error) num_error_vt;
[6d43cdde]11
12void caught_num_error(int expect, num_error * actual) {
13        printf("Caught num_error: expected=%d actual=%d.\n", expect, actual->num);
14}
15
16int main(int argc, char * argv[]) {
[ecfd758]17        num_error exc = {&num_error_vt, 2};
[6d43cdde]18
19        try {
[046a890]20                throw exc;
[ecfd758]21        } catch (num_error * error ; 3 == error->num ) {
[6d43cdde]22                caught_num_error(3, error);
[ecfd758]23        } catch (num_error * error ; 2 == error->num ) {
[6d43cdde]24                caught_num_error(2, error);
25        }
26
27        try {
[046a890]28                throwResume exc;
[ecfd758]29        } catchResume (num_error * error ; 3 == error->num ) {
[6d43cdde]30                caught_num_error(3, error);
[ecfd758]31        } catchResume (num_error * error ; 2 == error->num ) {
[6d43cdde]32                caught_num_error(2, error);
33        }
34}
Note: See TracBrowser for help on using the repository browser.