Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.38 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4.  
  5. use Test::More;
  6.  
  7. sub escape {
  8.     no warnings 'exiting';
  9.     eval { last ESCAPE };
  10. }
  11.  
  12. my $escaped = 1;
  13. my $safe1 = eval {
  14.     ESCAPE: {
  15.         eval "escape()";
  16.         ok(0, "Should not see this");
  17.         $escaped = 0;
  18.     }  
  19.  
  20.     warn "First Exception: $@" if $@;
  21.  
  22.     1;  
  23. };
  24.  
  25. ok($safe1, "We can escape");
  26. ok(1, "Got here");
  27.  
  28. $escaped = 1;
  29. my $safe2 = eval {
  30.     ESCAPE: {
  31.         eval "BEGIN { escape() }";
  32.         fail("Should not see this");
  33.         $escaped = 0;
  34.     }  
  35.  
  36.     warn "Second Exception: $@" if $@;
  37.  
  38.     1;  
  39. };
  40.  
  41. ok($escaped, "We can escape when there is a begin between us and the escape point");
  42. ok(1, "Got here as well");
  43.  
  44. done_testing;
  45.  
  46. =head1 perl 5.20.1
  47.  
  48. ok 1 - We can escape
  49. ok 2 - Got here
  50. not ok 3 - Should not see this
  51. #   Failed test 'Should not see this'
  52. #   at test.pl line 32.
  53. not ok 4 - We can escape when there is a begin between us and the escape point
  54. #   Failed test 'We can escape when there is a begin between us and the escape point'
  55. #   at test.pl line 41.
  56. ok 5 - Got here as well
  57. 1..5
  58. # Looks like you failed 2 tests of 5.
  59.  
  60. =head1 perl 5.10.1
  61.  
  62. ok 1 - We can escape
  63. ok 2 - Got here
  64. ok 3 - We can escape when there is a begin between us and the escape point
  65. ok 4 - Got here as well
  66. 1..4
  67. zsh: segmentation fault (core dumped)  perl -Ilib test.pl
  68.  
  69. =cut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement