Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/resume.cfa

    recfd758 r7f9968ad  
    44#include "except-io.hfa"
    55
    6 EHM_EXCEPTION(yin)();
    7 EHM_EXCEPTION(yang)();
    8 EHM_EXCEPTION(zen)();
    9 
    10 EHM_VIRTUAL_TABLE(yin, yin_vt);
    11 EHM_VIRTUAL_TABLE(yang, yang_vt);
    12 EHM_VIRTUAL_TABLE(zen, zen_vt);
     6TRIVIAL_EXCEPTION(yin);
     7TRIVIAL_EXCEPTION(yang);
     8TRIVIAL_EXCEPTION(zen);
     9TRIVIAL_EXCEPTION(moment_of, zen);
    1310
    1411void in_void(void);
    1512
    1613int main(int argc, char * argv[]) {
    17         yin a_yin = {&yin_vt};
    18         yang a_yang = {&yang_vt};
    19         zen a_zen = {&zen_vt};
    20 
    2114        // The simple throw catchResume test.
    2215        try {
    2316                loud_exit a = "simple try clause";
    2417                printf("simple throw\n");
    25                 throwResume a_zen;
     18                throwResume (zen){};
    2619                printf("end of try clause\n");
    2720        } catchResume (zen * error) {
     
    3326        // Throw catch-all test.
    3427        try {
    35                 throwResume a_zen;
     28                throwResume (zen){};
    3629        } catchResume (exception_t * error) {
    3730                printf("catch-all\n");
     31        }
     32        printf("\n");
     33
     34        // Catch a parent of the given exception.
     35        try {
     36                printf("throwing child exception\n");
     37                throwResume (moment_of){};
     38        } catchResume (zen *) {
     39                printf("inner parent match\n");
     40        } catchResume (moment_of *) {
     41                printf("outer exact match\n");
    3842        }
    3943        printf("\n");
     
    4246        try {
    4347                try {
    44                         throwResume a_yin;
     48                        throwResume (yin){};
    4549                } catchResume (zen *) {
    4650                        printf("caught yin as zen\n");
     
    5862                        loud_exit a = "rethrow inner try";
    5963                        printf("rethrow inner try\n");
    60                         throwResume a_zen;
     64                        throwResume (zen){};
    6165                } catchResume (zen *) {
    6266                        loud_exit a = "rethrowing catch clause";
     
    7377        try {
    7478                try {
    75                         throwResume a_yin;
     79                        throwResume (yin){};
    7680                } catchResume (yin *) {
    7781                        printf("caught yin, will throw yang\n");
    78                         throwResume a_yang;
     82                        throwResume (yang){};
    7983                } catchResume (yang *) {
    8084                        printf("caught exception from same try\n");
     
    8993                try {
    9094                        printf("throwing first exception\n");
    91                         throwResume a_yin;
     95                        throwResume (yin){};
    9296                } catchResume (yin *) {
    9397                        printf("caught first exception\n");
    9498                        try {
    9599                                printf("throwing second exception\n");
    96                                 throwResume a_yang;
     100                                throwResume (yang){};
    97101                        } catchResume (yang *) {
    98102                                printf("caught second exception\n");
     
    110114        try {
    111115                try {
    112                         throwResume a_zen;
    113                         throwResume a_zen;
     116                        throwResume (zen){};
     117                        throwResume (zen){};
    114118                } catchResume (zen *) {
    115119                        printf("inner catch\n");
    116120                }
    117                 throwResume a_zen;
     121                throwResume (zen){};
    118122        } catchResume (zen *) {
    119123                printf("outer catch\n");
     
    126130// Do a throw and rethrow in a void function.
    127131void in_void(void) {
    128     zen a_zen = {&zen_vt};
    129132        try {
    130133                try {
    131134                        printf("throw\n");
    132                         throwResume a_zen;
     135                        throwResume (zen){};
    133136                } catchResume (zen *) {
    134137                        printf("rethrow\n");
Note: See TracChangeset for help on using the changeset viewer.