@@ -14,12 +14,9 @@ Tests C<CATCH> blocks.
14
14
15
15
# L<S04/"Exception handlers"/If you define a CATCH block within the try, it replaces the default CATCH>
16
16
17
- # ?rakudo 2 todo 'empty CATCH block'
18
17
dies_ok { die ' blah' ; CATCH {} }, ' Empty CATCH rethrows exception' ;
19
18
dies_ok { try {die ' blah' ; CATCH {}} }, ' CATCH in try overrides default exception handling' ;
20
19
21
-
22
-
23
20
# L<S04/"Exception handlers"/any block can function as a try block if you put a CATCH block within it>
24
21
25
22
lives_ok { die ' blah' ; CATCH {default {}} }, ' Closure with CATCH {default {}} ignores exceptions' ;
@@ -69,7 +66,6 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
69
66
70
67
ok (! $ not_died , " did not live after death" );
71
68
# ?pugs 1 todo
72
- # ?rakudo todo 'smart matching against exception'
73
69
ok ($ caught , " caught exception of class Naughty" );
74
70
};
75
71
@@ -80,7 +76,7 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
80
76
81
77
my ($ other , $ naughty );
82
78
{
83
- die Naughty::Specific( " error " );
79
+ die Naughty::Specific. new ( );
84
80
85
81
CATCH {
86
82
when Naughty::Other {
@@ -103,6 +99,7 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
103
99
class Dandy is Exception {};
104
100
105
101
my ($ naughty , $ lived );
102
+ try {
106
103
{
107
104
die Dandy. new ();
108
105
@@ -113,26 +110,26 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
113
110
}
114
111
};
115
112
$ lived = 1 ;
116
-
117
- # ?rakudo todo 'smart matching in CATCH'
113
+ }
114
+
118
115
ok (! $ lived , " did not live past uncaught throw" );
119
116
ok (! $ naughty , " did not get caught by wrong handler" );
120
117
ok (WHAT ($! ). gist , ' $! is an object' );
121
118
# ?pugs skip 'bug'
122
- # ?rakudo todo 'Exception types'
123
119
is (WHAT ($! ). gist , Dandy. gist , " .. of the right class" );
124
120
};
125
121
126
- # ?rakudo skip 'loops'
127
122
{
128
123
my $ s = ' ' ;
129
- die 3 ;
130
- CATCH {
131
- when 1 {$ s ~ = ' a' ;}
132
- when 2 {$ s ~ = ' b' ;}
133
- when 3 {$ s ~ = ' c' ;}
134
- when 4 {$ s ~ = ' d' ;}
135
- default {$ s ~ = ' z' ;}
124
+ {
125
+ die 3 ;
126
+ CATCH {
127
+ when 1 {$ s ~ = ' a' ;}
128
+ when 2 {$ s ~ = ' b' ;}
129
+ when 3 {$ s ~ = ' c' ;}
130
+ when 4 {$ s ~ = ' d' ;}
131
+ default {$ s ~ = ' z' ;}
132
+ }
136
133
}
137
134
138
135
is $ s , ' c' , ' Caught number' ;
@@ -165,7 +162,6 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
165
162
};
166
163
}
167
164
168
- # ?rakudo 2 todo 'CATCH block catching its own exceptions (RT #64262)'
169
165
is $ catches , 1 , " CATCH doesn't catch exceptions thrown in its own lexical scope" ;
170
166
171
167
$ catches = 0 ;
0 commit comments