Skip to content

Commit e420571

Browse files
committed
Corrections and re-fudging of S04-exception-handlers/catch.t.
1 parent 2881bb5 commit e420571

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

S04-exception-handlers/catch.t

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ Tests C<CATCH> blocks.
1414

1515
# L<S04/"Exception handlers"/If you define a CATCH block within the try, it replaces the default CATCH>
1616

17-
#?rakudo 2 todo 'empty CATCH block'
1817
dies_ok { die 'blah'; CATCH {} }, 'Empty CATCH rethrows exception';
1918
dies_ok { try {die 'blah'; CATCH {}} }, 'CATCH in try overrides default exception handling';
2019

21-
22-
2320
# L<S04/"Exception handlers"/any block can function as a try block if you put a CATCH block within it>
2421

2522
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
6966

7067
ok(!$not_died, "did not live after death");
7168
#?pugs 1 todo
72-
#?rakudo todo 'smart matching against exception'
7369
ok($caught, "caught exception of class Naughty");
7470
};
7571

@@ -80,7 +76,7 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
8076

8177
my ($other, $naughty);
8278
{
83-
die Naughty::Specific("error");
79+
die Naughty::Specific.new();
8480

8581
CATCH {
8682
when Naughty::Other {
@@ -103,6 +99,7 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
10399
class Dandy is Exception {};
104100

105101
my ($naughty, $lived);
102+
try {
106103
{
107104
die Dandy.new();
108105

@@ -113,26 +110,26 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
113110
}
114111
};
115112
$lived = 1;
116-
117-
#?rakudo todo 'smart matching in CATCH'
113+
}
114+
118115
ok(!$lived, "did not live past uncaught throw");
119116
ok(!$naughty, "did not get caught by wrong handler");
120117
ok(WHAT($!).gist, '$! is an object');
121118
#?pugs skip 'bug'
122-
#?rakudo todo 'Exception types'
123119
is(WHAT($!).gist, Dandy.gist, ".. of the right class");
124120
};
125121

126-
#?rakudo skip 'loops'
127122
{
128123
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+
}
136133
}
137134

138135
is $s, 'c', 'Caught number';
@@ -165,7 +162,6 @@ lives_ok { do {die 'blah'; CATCH {default {}}}; }, 'do block with CATCH {default
165162
};
166163
}
167164

168-
#?rakudo 2 todo 'CATCH block catching its own exceptions (RT #64262)'
169165
is $catches, 1, "CATCH doesn't catch exceptions thrown in its own lexical scope";
170166

171167
$catches = 0;

0 commit comments

Comments
 (0)