]> git.vpit.fr Git - perl/modules/Scope-Upper.git/blobdiff - t/13-reap-ctl.t
Also apply the context overwrite workaround when not under OP_DIE
[perl/modules/Scope-Upper.git] / t / 13-reap-ctl.t
index 210b5b5de4c631143f29b83ac2870bf8b4b2739d..39a0bb4e3f74162cb1cae2079031cd6e70125457 100644 (file)
@@ -3,7 +3,7 @@
 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/;
 
@@ -122,6 +122,19 @@ $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;