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

ADTast-experimentalenumforall-pointer-decaypthread-emulationqualifiedEnum
Last change on this file since c0f881b 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: 734 bytes
RevLine 
[e68d092]1// Test exceptions that add data but no functionality.
2
[d00d581]3exception paired {
[e68d092]4        int first;
5        int second;
[d00d581]6};
[e68d092]7
[d00d581]8vtable(paired) paired_vt;
[e68d092]9
[ecfd758]10const char * virtual_msg(paired * this) {
11        return this->virtual_table->msg(this);
[e68d092]12}
13
14int main(int argc, char * argv[]) {
[ecfd758]15        paired except = {&paired_vt, 3, 13};
[e68d092]16
17        try {
[046a890]18                throw except;
[e68d092]19        } catch (paired * exc) {
[ecfd758]20                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
[e68d092]21                ++exc->first;
22        }
23
[ecfd758]24        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
[e68d092]25
26        try {
[046a890]27                throwResume except;
[e68d092]28        } catchResume (paired * exc) {
[ecfd758]29                printf("%s(%d, %d)\n", virtual_msg(exc), exc->first, exc->second);
[e68d092]30                ++exc->first;
31        }
32
[ecfd758]33        printf("%s(%d, %d)\n", virtual_msg(&except), except.first, except.second);
[e68d092]34}
Note: See TracBrowser for help on using the repository browser.