X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F13-reap-ctl.t;h=085cc050baacdca23e8643b9ab15866916363716;hb=e8b8c066e959120b28db728fc7640b606f29faa6;hp=210b5b5de4c631143f29b83ac2870bf8b4b2739d;hpb=c8997e4a75e935854f13e100fdcbc222978c1211;p=perl%2Fmodules%2FScope-Upper.git diff --git a/t/13-reap-ctl.t b/t/13-reap-ctl.t index 210b5b5..085cc05 100644 --- a/t/13-reap-ctl.t +++ b/t/13-reap-ctl.t @@ -3,9 +3,9 @@ use strict; use warnings; -use Test::More tests => 38 + 30 + 4 * 7; +use Test::More tests => 41 + 30 + 4 * 7; -use Scope::Upper qw/reap UP HERE/; +use Scope::Upper qw; our ($x, $y); @@ -122,11 +122,30 @@ $y = undef; is $y, 1, 'die - reap inside eval [ok - y]'; } +{ + my $z = 0; + my $reaped = 0; + eval { + reap { $reaped = 1 }; + is $reaped, 0, 'died of natural death - not reaped yet'; + my $res = 1 / $z; + }; + my $err = $@; + is $reaped, 1, 'died of natural death - reaped'; + like $err, qr/division by zero/, 'died of natural death - divided by zero'; +} + SKIP: { - skip 'Perl 5.10 required to test given/when' => 30 if $] < 5.010; + skip 'Perl 5.10 required to test given/when' => 30 if "$]" < 5.010; eval <<' GIVEN_TEST_1'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -148,6 +167,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_2'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -171,6 +196,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_3'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -192,6 +223,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_4'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -215,6 +252,12 @@ SKIP: fail $@ if $@; eval <<' GIVEN_TEST_5'; + BEGIN { + if ("$]" >= 5.017_011) { + require warnings; + warnings->unimport('experimental::smartmatch'); + } + } use feature 'switch'; local $y; { @@ -259,10 +302,12 @@ $y = undef; reap { ++$y; die "reaped\n" } => HERE; is $x, 3, 'die in reap at eval [not yet - x]'; is $y, undef, 'die in reap at eval [not yet - y]'; - }; # should trigger here, but the die isn't catched by this eval - die "failed\n"; + }; # should trigger here, but the die isn't catched by this eval in + # ealier perls + die "inner\n"; }; - is $@, "reaped\n", 'die in reap at eval [ok - $@]'; + is $@, ($] >= 5.023008 ? "inner\n" : "reaped\n"), + 'die in reap at eval [ok - $@]'; is $x, 1, 'die in reap at eval [ok - x]'; is $y, 1, 'die in reap at eval [ok - y]'; }