| 1 |
#!/usr/bin/perl -w |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use autodie; |
| 5 |
use Test::More 'no_plan'; |
| 6 |
use FindBin qw($Bin); |
| 7 |
use lib "$Bin/lib"; |
| 8 |
use Caller_helper; |
| 9 |
|
| 10 |
use constant NO_SUCH_FILE => "kiwifoo_is_so_much_fun"; |
| 11 |
|
| 12 |
eval { |
| 13 |
foo(); |
| 14 |
}; |
| 15 |
|
| 16 |
isa_ok($@, 'autodie::exception'); |
| 17 |
|
| 18 |
is($@->caller, 'main::foo', "Caller should be main::foo"); |
| 19 |
|
| 20 |
sub foo { |
| 21 |
use autodie; |
| 22 |
open(my $fh, '<', NO_SUCH_FILE); |
| 23 |
} |
| 24 |
|
| 25 |
eval { |
| 26 |
Caller_helper::foo(); |
| 27 |
}; |
| 28 |
|
| 29 |
isa_ok($@, 'autodie::exception'); |
| 30 |
|
| 31 |
is($@->line, $Caller_helper::line, "External line number check"); |
| 32 |
is($@->file, $INC{"Caller_helper.pm"}, "External filename check"); |
| 33 |
is($@->package, "Caller_helper", "External package check"); |
| 34 |
is($@->caller, "Caller_helper::foo", "External subname check"); |