Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Test::More;
- sub escape {
- no warnings 'exiting';
- eval { last ESCAPE };
- }
- my $escaped = 1;
- my $safe = eval {
- ESCAPE: {
- eval "escape(); 1" || diag "Exception: $@";
- ok(0, "Should not see this");
- $escaped = 0;
- }
- 1;
- };
- ok($safe, "outer eval 1 completed");
- ok($escaped, "We can escape");
- $escaped = 1;
- $safe = eval {
- ESCAPE: {
- eval "BEGIN { escape() }; 1" || diag "Exception: $@";
- $escaped = 0;
- }
- 1;
- };
- ok($safe, "outer eval 2 completed");
- ok($escaped, "We can escape when there is a BEGIN between us and the escape point");
- done_testing;
- =head1 5.20.1
- ok 1 - outer eval 1 completed
- ok 2 - We can escape
- ok 3 - outer eval 2 completed
- not ok 4 - We can escape when there is a BEGIN between us and the escape point
- # Failed test 'We can escape when there is a BEGIN between us and the escape point'
- # at test.pl line 37.
- 1..4
- # Looks like you failed 1 test of 4.
- =head1 5.10.1
- ok 1 - outer eval 1 completed
- ok 2 - We can escape
- ok 3 - outer eval 2 completed
- ok 4 - We can escape when there is a BEGIN between us and the escape point
- 1..4
- segmentation fault
- =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement