source: tests/exceptions/conditional.cfa@ 4be0117

Last change on this file since 4be0117 was d3cf623, checked in by Andrew Beach <ajbeach@…>, 9 months ago

Solved the requested warning with exceptions. Also went through the exceptions tests and managed to remove about 2/3rds of them from the lax list that now either didn't have any warnings or warnings because of the test itself.

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