source: tests/exceptions/data-except.cfa@ eb42db4

Last change on this file since eb42db4 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: 751 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
[d3cf623]16int main() {
[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.