Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[6.d] Spec start in sink context attaches ex. handler
  • Loading branch information
zoffixznet committed Sep 21, 2018
1 parent 2e35d67 commit 7a426fb
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion MISC/misc-6.d.t
Expand Up @@ -7,7 +7,7 @@ use Test::Util;
# They might be rearranged into other files in the future, but for now, keeping them in this
# file avoids creating a ton of `-6.d.t` files for the sake of single tests.

plan 6;
plan 7;

group-of 6 => ':sym<> colonpair on subroutine names is reserved' => {
throws-like 'use v6.d.PREVIEW; sub meow:sym<bar> {}', X::Syntax::Reserved, ':sym<...>';
Expand Down Expand Up @@ -196,4 +196,45 @@ group-of 3 => 'smiley constraints default to type object without smiley' => {
}
}

group-of 6 => 'sunk `start`' => {
is_run
use v6.d.PREVIEW;
start { die "PASS" }; sleep ⅓; print "fail"
, {:out{not .contains: 'fail'}, :err{.contains: 'PASS'}, :1status }, 'block';

is_run
use v6.d.PREVIEW;
start die "PASS"; sleep ⅓; print "pass"
, {:out{not .contains: 'fail'}, :err{.contains: 'PASS'}, :1status }, 'thunk';

is_run
use v6.d.PREVIEW;
start { CATCH { when X::Str::Numeric {} }; die "PASS" };
sleep ⅓; print "pass"
, {:out{not .contains: 'fail'}, :err{.contains: 'PASS'}, :1status },
'with non-catching handler';

is_run
use v6.d.PREVIEW;
start { CATCH { default { note "caught" } }; die "PASS" }
sleep ⅓; print "pass"
, {:out<pass>, :err{.contains: 'caught'}, :0status },
'with catching handler';

is_run
use v6.d.PREVIEW;
(start die "fail"; sleep ⅓).sink;
print "pass"
, {:out{not .contains: 'fail'}, :err{not .contains: 'PASS'}, :0status },
'non-sunk context, even if we call .sink on it';

is_run
use v6.d.PREVIEW;
class Exceptions::Meows { method process (| --> False) { note "MEOWS" } }
BEGIN %*ENV<PERL6_EXCEPTIONS_HANDLER> = 'Meows';
start die "PASS"; sleep ⅓; print "fail"
, {:out{not .contains: 'fail'}, :err{.contains: 'MEOWS'}, :1status},
'custom exceptions handler respected';
}

# vim: expandtab shiftwidth=4 ft=perl6

0 comments on commit 7a426fb

Please sign in to comment.