chiark / gitweb /
Initial sketch.
[finally] / try-catch.cc
1 /* -*-c++-*-
2  *
3  * Check handling of exceptions
4  *
5  * (c) 2023 Straylight/Edgeware
6  */
7
8 /*----- Licensing notice --------------------------------------------------*
9  *
10  * This file is part of the `Finally' package.
11  *
12  * Finally is free software: you can redistribute it and/or modify it
13  * under the terms of the GNU Library General Public License as published
14  * by the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * Finally is distributed in the hope that it will be useful, but WITHOUT
18  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
20  * License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with Finally.  If not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
25  * USA.
26  */
27
28 /*----- Header files ------------------------------------------------------*/
29
30 #include "finally-test.h"
31
32 /*----- Main code ---------------------------------------------------------*/
33
34 class ball { };
35
36 void try_catch_inner(unsigned f)
37 {
38   if (f&TCF_THROW) STEP(11);
39   else STEP(3);
40   if (f&TCF_THROW) throw ball();
41 }
42
43 void try_catch_outer(unsigned f)
44 {
45   if (f&TCF_THROW) STEP(9);
46   else STEP(1);
47   try { try_catch_filling(f); STEP(6); }
48   catch (ball) { STEP(13); }
49   if (f&TCF_THROW) STEP(14);
50   else STEP(7);
51 }
52
53 /*----- That's all, folks -------------------------------------------------*/