source: tests/exceptions/data-except.cfa @ 0a9b5c1

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

fix include files

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