Ignore:
Timestamp:
Jun 21, 2023, 9:45:08 PM (10 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6065281f
Parents:
2de175ce
Message:

change printf to sout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/exceptions/terminate.cfa

    r2de175ce r3bf9d10  
    11// Termination Exception Tests
    22
     3#include <fstream.hfa>
    34#include "except-io.hfa"
    45
     
    2122        try {
    2223                loud_exit a = "simple try clause";
    23                 printf("simple throw\n");
     24                sout | "simple throw";
    2425                throw a_zen;
    25                 printf("end of try clause\n");
     26                sout | "end of try clause";
    2627        } catch (zen * error) {
    2728                loud_exit a = "simple catch clause";
    28                 printf("simple catch\n");
     29                sout | "simple catch";
    2930        }
    30         printf("\n");
     31        sout | nl;
    3132
    3233        // Throw catch-all test.
     
    3435                throw a_zen;
    3536        } catch (exception_t * error) {
    36                 printf("catch-all\n");
     37                sout | "catch-all";
    3738        }
    38         printf("\n");
     39        sout | nl;
    3940
    4041        // Don't catch if handler does not match exception.
     
    4344                        throw a_yin;
    4445                } catch (zen *) {
    45                         printf("caught yin as zen\n");
     46                        sout | "caught yin as zen";
    4647                }
    4748        } catch (yang *) {
    48                 printf("caught yin as yang\n");
     49                sout | "caught yin as yang";
    4950        } catch (yin *) {
    50                 printf("caught yin as yin\n");
     51                sout | "caught yin as yin";
    5152        }
    52         printf("\n");
     53        sout | nl;
    5354
    5455        // Test rethrowing an exception.
     
    5657                try {
    5758                        loud_exit a = "rethrow inner try";
    58                         printf("rethrow inner try\n");
     59                        sout | "rethrow inner try";
    5960                        throw a_zen;
    6061                } catch (zen *) {
    6162                        loud_exit a = "rethrowing catch clause";
    62                         printf("caught throw, will rethrow\n");
     63                        sout | "caught throw, will rethrow";
    6364                        throw;
    6465                }
    6566        } catch (zen *) {
    6667                loud_exit a = "rethrow catch clause";
    67                 printf("caught rethrow\n");
     68                sout | "caught rethrow";
    6869        }
    69         printf("\n");
     70        sout | nl;
    7071
    7172        // Throw a different exception in a catch.
     
    7475                        throw a_yin;
    7576                } catch (yin *) {
    76                         printf("caught yin, will throw yang\n");
     77                        sout | "caught yin, will throw yang";
    7778                        throw a_yang;
    7879                } catch (yang *) {
    79                         printf("caught exception from same try\n");
     80                        sout | "caught exception from same try";
    8081                }
    8182        } catch (yang *) {
    82                 printf("caught yang\n");
     83                sout | "caught yang";
    8384        }
    84         printf("\n");
     85        sout | nl;
    8586
    8687        // Another throw in the catch does not interfere.
    8788        try {
    8889                try {
    89                         printf("throwing first exception\n");
     90                        sout | "throwing first exception";
    9091                        throw a_yin;
    9192                } catch (yin *) {
    92                         printf("caught first exception\n");
     93                        sout | "caught first exception";
    9394                        try {
    94                                 printf("throwing second exception\n");
     95                                sout | "throwing second exception";
    9596                                throw a_yang;
    9697                        } catch (yang *) {
    97                                 printf("caught second exception\n");
     98                                sout | "caught second exception";
    9899                        }
    99100                        throw;
    100101                }
    101102        } catch (yin *) {
    102                 printf("recaught first exception\n");
     103                sout | "recaught first exception";
    103104        } catch (yang *) {
    104                 printf("caught second exception (bad location)\n");
     105                sout | "caught second exception (bad location)";
    105106        }
    106         printf("\n");
     107        sout | nl;
    107108
    108109        // Check successive operations.
     
    112113                        throw a_zen;
    113114                } catch (zen *) {
    114                         printf("inner catch\n");
     115                        sout | "inner catch";
    115116                }
    116117                throw a_zen;
    117118        } catch (zen *) {
    118                 printf("outer catch\n");
     119                sout | "outer catch";
    119120        }
    120         printf("\n");
     121        sout | nl;
    121122
    122123        in_void();
     
    128129        try {
    129130                try {
    130                         printf("throw\n");
     131                        sout | "throw";
    131132                        throw a_zen;
    132133                } catch (zen *) {
    133                         printf("rethrow\n");
     134                        sout | "rethrow";
    134135                        throw;
    135136                }
    136137        } catch (zen *) {
    137                 printf("handle\n");
     138                sout | "handle";
    138139        }
    139140}
Note: See TracChangeset for help on using the changeset viewer.