Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/interact.cfa

    r3bf9d10 rd00d581  
    11// Testing Interactions Between Termination and Resumption
    22
    3 #include <fstream.hfa>
    43#include "except-io.hfa"
    54
     
    1514                throwResume (star){&star_vt};
    1615        } catch (star *) {
    17                 sout | "caught as termination";
     16                printf("caught as termination\n");
    1817        }
    1918        // Variant of the above to check timing.
     
    2221                throwResume (star){&star_vt};
    2322        } catch (star *) {
    24                 sout | "caught as termination";
     23                printf("caught as termination\n");
    2524        } catchResume (star *) {
    26                 sout | "intermediate rethrow";
     25                printf("intermediate rethrow\n");
    2726                throwResume;
    2827        }
    29         sout | nl;
     28        printf("\n");
    3029
    3130        // Resume does not catch terminate.
     
    3433                        throw (star){&star_vt};
    3534                } catchResume (star *) {
    36                         sout | "resume catch on terminate";
     35                        printf("resume catch on terminate\n");
    3736                }
    3837        } catchResume (star *) {
    39                 sout | "resume catch on terminate";
     38                printf("resume catch on terminate\n");
    4039        } catch (star *) {
    41                 sout | "terminate catch on terminate";
     40                printf("terminate catch on terminate\n");
    4241        }
    43         sout | nl;
     42        printf("\n");
    4443
    4544        // Terminate does not catch resume.
     
    4847                        throwResume (star){&star_vt};
    4948                } catch (star *) {
    50                         sout | "terminate catch on resume";
     49                        printf("terminate catch on resume\n");
    5150                }
    5251        } catch (star *) {
    53                 sout | "terminate catch on resume";
     52                printf("terminate catch on resume\n");
    5453        } catchResume (star *) {
    55                 sout | "resume catch on resume";
     54                printf("resume catch on resume\n");
    5655        }
    57         sout | nl;
     56        printf("\n");
    5857
    5958        // Resume a termination exception.
     
    6362                                throw (star){&star_vt};
    6463                        } catchResume (star *) {
    65                                 sout | "inner resume catch (error)";
     64                                printf("inner resume catch (error)\n");
    6665                        }
    6766                } catch (star * error) {
    68                         sout | "termination catch, will resume";
     67                        printf("termination catch, will resume\n");
    6968                        throwResume *error;
    7069                }
    7170        } catchResume (star *) {
    72                 sout | "outer resume catch";
     71                printf("outer resume catch\n");
    7372        }
    74         sout | nl;
     73        printf("\n");
    7574
    7675        // Terminate a resumption exception.
     
    8079                                throwResume (star){&star_vt};
    8180                        } catch (star *) {
    82                                 sout | "inner termination catch";
     81                                printf("inner termination catch\n");
    8382                        }
    8483                } catchResume (star * error) {
    85                         sout | "resumption catch, will terminate";
     84                        printf("resumption catch, will terminate\n");
    8685                        throw *error;
    8786                }
    8887        } catch (star *) {
    89                 sout | "outer terminate catch (error)";
     88                printf("outer terminate catch (error)\n");
    9089        }
    91         sout | nl;
     90        printf("\n");
    9291
    9392        // Unwinding a resumption catch does not break the system.
     
    9695                        try {
    9796                                try {
    98                                         sout | "throwing resume moon";
     97                                        printf("throwing resume moon\n");
    9998                                        throwResume (moon){&moon_vt};
    10099                                } catch (star *) {
    101                                         sout | "termination catch";
     100                                        printf("termination catch\n");
    102101                                }
    103                                 sout | "throwing resume star";
     102                                printf("throwing resume star\n");
    104103                                throwResume (star){&star_vt};
    105104                        } catchResume (star *) {
    106                                 sout | "resumption star catch";
     105                                printf("resumption star catch\n");
    107106                        }
    108107                } catchResume (moon *) {
    109                         sout | "resumption moon catch, will terminate";
     108                        printf("resumption moon catch, will terminate\n");
    110109                        throw (star){&star_vt};
    111110                }
    112111        } catchResume (star *) {
    113                 sout | "outermost catch (error)";
     112                printf("outermost catch (error)\n");
    114113        }
    115114}
Note: See TracChangeset for help on using the changeset viewer.