Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/terminate.cfa

    re68d092 r7f9968ad  
    99TRIVIAL_EXCEPTION(moment_of, zen);
    1010
     11void in_void(void);
     12
    1113int main(int argc, char * argv[]) {
    1214        // The simple throw catch test.
     
    1416                loud_exit a = "simple try clause";
    1517                printf("simple throw\n");
    16                 throw &(zen){};
     18                throw (zen){};
    1719                printf("end of try clause\n");
    1820        } catch (zen * error) {
    19         loud_exit a = "simple catch clause";
     21                loud_exit a = "simple catch clause";
    2022                printf("simple catch\n");
     23        }
     24        printf("\n");
     25
     26        // Throw catch-all test.
     27        try {
     28                throw (zen){};
     29        } catch (exception_t * error) {
     30                printf("catch-all\n");
    2131        }
    2232        printf("\n");
     
    2535        try {
    2636                printf("throwing child exception\n");
    27                 throw &(moment_of){};
     37                throw (moment_of){};
    2838        } catch (zen *) {
    2939                printf("inner parent match\n");
     
    3646        try {
    3747                try {
    38                         throw &(yin){};
     48                        throw (yin){};
    3949                } catch (zen *) {
    4050                        printf("caught yin as zen\n");
     
    5262                        loud_exit a = "rethrow inner try";
    5363                        printf("rethrow inner try\n");
    54                         throw &(zen){};
     64                        throw (zen){};
    5565                } catch (zen *) {
    5666                        loud_exit a = "rethrowing catch clause";
     
    6777        try {
    6878                try {
    69                         throw &(yin){};
     79                        throw (yin){};
    7080                } catch (yin *) {
    7181                        printf("caught yin, will throw yang\n");
    72                         throw &(yang){};
     82                        throw (yang){};
    7383                } catch (yang *) {
    7484                        printf("caught exception from same try\n");
     
    8393                try {
    8494                        printf("throwing first exception\n");
    85                         throw &(yin){};
     95                        throw (yin){};
    8696                } catch (yin *) {
    8797                        printf("caught first exception\n");
    8898                        try {
    8999                                printf("throwing second exception\n");
    90                                 throw &(yang){};
     100                                throw (yang){};
    91101                        } catch (yang *) {
    92102                                printf("caught second exception\n");
     
    104114        try {
    105115                try {
    106                         throw &(zen){};
    107                         throw &(zen){};
     116                        throw (zen){};
     117                        throw (zen){};
    108118                } catch (zen *) {
    109119                        printf("inner catch\n");
    110120                }
    111                 throw &(zen){};
     121                throw (zen){};
    112122        } catch (zen *) {
    113123                printf("outer catch\n");
    114124        }
     125        printf("\n");
     126
     127        in_void();
    115128}
     129
     130// Do a throw and rethrow in a void function.
     131void in_void(void) {
     132        try {
     133                try {
     134                        printf("throw\n");
     135                        throw (zen){};
     136                } catch (zen *) {
     137                        printf("rethrow\n");
     138                        throw;
     139                }
     140        } catch (zen *) {
     141                printf("handle\n");
     142        }
     143}
     144
Note: See TracChangeset for help on using the changeset viewer.