Created
May 17, 2012 19:27
-
-
Save berekuk/2721102 to your computer and use it in GitHub Desktop.
require fails when called from exception()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./test.t | |
| exception script.pl did not return a true value at ./test.t line 9. | |
| $ perl --version | |
| This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env perl | |
| package X; | |
| use strict; | |
| use warnings; | |
| sub f { | |
| return 1; | |
| } | |
| return f(); # if I replace this with direct 'return 1', error goes away |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| use strict; | |
| use warnings; | |
| use Test::Fatal; | |
| # if I replace exception() with my $f = sub { ... }, error goes away | |
| my $e = exception(sub { | |
| require 'script.pl'; | |
| # 1; # if I uncomment this line, error goes away | |
| }); | |
| if (defined $e) { | |
| warn "exception $e"; | |
| } | |
| else { | |
| warn "ok"; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment