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 $safe1 = eval {
- ESCAPE: {
- eval "escape()";
- ok(0, "Should not see this");
- $escaped = 0;
- }
- warn "First Exception: $@" if $@;
- 1;
- };
- ok($safe1, "We can escape");
- ok(1, "Got here");
- $escaped = 1;
- my $safe2 = eval {
- ESCAPE: {
- eval "BEGIN { escape() }";
- fail("Should not see this");
- $escaped = 0;
- }
- warn "Second Exception: $@" if $@;
- 1;
- };
- ok($escaped, "We can escape when there is a begin between us and the escape point");
- ok(1, "Got here as well");
- done_testing;
- =head1 perl 5.20.1
- ok 1 - We can escape
- ok 2 - Got here
- not ok 3 - Should not see this
- # Failed test 'Should not see this'
- # at test.pl line 32.
- 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 41.
- ok 5 - Got here as well
- 1..5
- # Looks like you failed 2 tests of 5.
- =head1 perl 5.10.1
- ok 1 - We can escape
- ok 2 - Got here
- ok 3 - We can escape when there is a begin between us and the escape point
- ok 4 - Got here as well
- 1..4
- zsh: segmentation fault (core dumped) perl -Ilib test.pl
- =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement