Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/resume.cfa

    r3bf9d10 rd00d581  
    11// Resumption Exception Tests
    22
    3 #include <fstream.hfa>
    43#include "except-io.hfa"
    54
     
    2221        try {
    2322                loud_exit a = "simple try clause";
    24                 sout | "simple throw";
     23                printf("simple throw\n");
    2524                throwResume a_zen;
    26                 sout | "end of try clause";
     25                printf("end of try clause\n");
    2726        } catchResume (zen * error) {
    2827                loud_exit a = "simple catch clause";
    29                 sout | "simple catch";
     28                printf("simple catch\n");
    3029        }
    31         sout | nl;
     30        printf("\n");
    3231
    3332        // Throw catch-all test.
     
    3534                throwResume a_zen;
    3635        } catchResume (exception_t * error) {
    37                 sout | "catch-all";
     36                printf("catch-all\n");
    3837        }
    39         sout | nl;
     38        printf("\n");
    4039
    4140        // Don't catch if handler does not match exception.
     
    4443                        throwResume a_yin;
    4544                } catchResume (zen *) {
    46                         sout | "caught yin as zen";
     45                        printf("caught yin as zen\n");
    4746                }
    4847        } catchResume (yang *) {
    49                 sout | "caught yin as yang";
     48                printf("caught yin as yang\n");
    5049        } catchResume (yin *) {
    51                 sout | "caught yin as yin";
     50                printf("caught yin as yin\n");
    5251        }
    53         sout | nl;
     52        printf("\n");
    5453
    5554        // Test rethrowing an exception.
     
    5756                try {
    5857                        loud_exit a = "rethrow inner try";
    59                         sout | "rethrow inner try";
     58                        printf("rethrow inner try\n");
    6059                        throwResume a_zen;
    6160                } catchResume (zen *) {
    6261                        loud_exit a = "rethrowing catch clause";
    63                         sout | "caught throw, will rethrow";
     62                        printf("caught throw, will rethrow\n");
    6463                        throwResume;
    6564                }
    6665        } catchResume (zen *) {
    6766                loud_exit a = "rethrow catch clause";
    68                 sout | "caught rethrow";
     67                printf("caught rethrow\n");
    6968        }
    70         sout | nl;
     69        printf("\n");
    7170
    7271        // Throw a different exception in a catch.
     
    7574                        throwResume a_yin;
    7675                } catchResume (yin *) {
    77                         sout | "caught yin, will throw yang";
     76                        printf("caught yin, will throw yang\n");
    7877                        throwResume a_yang;
    7978                } catchResume (yang *) {
    80                         sout | "caught exception from same try";
     79                        printf("caught exception from same try\n");
    8180                }
    8281        } catchResume (yang *) {
    83                 sout | "caught yang";
     82                printf("caught yang\n");
    8483        }
    85         sout | nl;
     84        printf("\n");
    8685
    8786        // Another throw in the catch does not interfere.
    8887        try {
    8988                try {
    90                         sout | "throwing first exception";
     89                        printf("throwing first exception\n");
    9190                        throwResume a_yin;
    9291                } catchResume (yin *) {
    93                         sout | "caught first exception";
     92                        printf("caught first exception\n");
    9493                        try {
    95                                 sout | "throwing second exception";
     94                                printf("throwing second exception\n");
    9695                                throwResume a_yang;
    9796                        } catchResume (yang *) {
    98                                 sout | "caught second exception";
     97                                printf("caught second exception\n");
    9998                        }
    10099                        throwResume;
    101100                }
    102101        } catchResume (yin *) {
    103                 sout | "recaught first exception";
     102                printf("recaught first exception\n");
    104103        } catchResume (yang *) {
    105                 sout | "caught second exception (bad location)";
     104                printf("caught second exception (bad location)\n");
    106105        }
    107         sout | nl;
     106        printf("\n");
    108107
    109108        // Check successive operations.
     
    113112                        throwResume a_zen;
    114113                } catchResume (zen *) {
    115                         sout | "inner catch";
     114                        printf("inner catch\n");
    116115                }
    117116                throwResume a_zen;
    118117        } catchResume (zen *) {
    119                 sout | "outer catch";
     118                printf("outer catch\n");
    120119        }
    121         sout | nl;
     120        printf("\n");
    122121
    123122        in_void();
     
    129128        try {
    130129                try {
    131                         sout | "throw";
     130                        printf("throw\n");
    132131                        throwResume a_zen;
    133132                } catchResume (zen *) {
    134                         sout | "rethrow";
     133                        printf("rethrow\n");
    135134                        throwResume;
    136135                }
    137136        } catchResume (zen *) {
    138                 sout | "handle";
     137                printf("handle\n");
    139138        }
    140139}
Note: See TracChangeset for help on using the changeset viewer.