source: tests/exceptions/data-except.cfa @ 960665c

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

fix include files

  • Property mode set to 100644
File size: 774 bytes
Line 
1// Test exceptions that add data but no functionality.
2
3#include <fstream.hfa>
4
5exception paired {
6        int first;
7        int second;
8};
9
10vtable(paired) paired_vt;
11
12const char * virtual_msg(paired * this) {
13        return this->virtual_table->msg(this);
14}
15
16int main(int argc, char * argv[]) {
17        paired except = {&paired_vt, 3, 13};
18
19        try {
20                throw except;
21        } catch (paired * exc) {
22                sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')';
23                ++exc->first;
24        }
25
26        sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')';
27
28        try {
29                throwResume except;
30        } catchResume (paired * exc) {
31                sout | virtual_msg(exc) | '(' | exc->first | ", " | exc->second | ')';
32                ++exc->first;
33        }
34
35        sout | virtual_msg(&except) | '(' | except.first | ", " | except.second | ')';
36}
Note: See TracBrowser for help on using the repository browser.