Blame t/caller.t

Packit 6427f8
#!/usr/bin/perl -w
Packit 6427f8
use strict;
Packit 6427f8
use warnings;
Packit 6427f8
use autodie;
Packit 6427f8
use Test::More 'no_plan';
Packit 6427f8
use FindBin qw($Bin);
Packit 6427f8
use lib "$Bin/lib";
Packit 6427f8
use Caller_helper;
Packit 6427f8
Packit 6427f8
use constant NO_SUCH_FILE => "kiwifoo_is_so_much_fun";
Packit 6427f8
Packit 6427f8
eval {
Packit 6427f8
    foo();
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
isa_ok($@, 'autodie::exception');
Packit 6427f8
Packit 6427f8
is($@->caller, 'main::foo', "Caller should be main::foo");
Packit 6427f8
Packit 6427f8
sub foo {
Packit 6427f8
    use autodie;
Packit 6427f8
    open(my $fh, '<', NO_SUCH_FILE);
Packit 6427f8
}
Packit 6427f8
Packit 6427f8
eval {
Packit 6427f8
    Caller_helper::foo();
Packit 6427f8
};
Packit 6427f8
Packit 6427f8
isa_ok($@, 'autodie::exception');
Packit 6427f8
Packit 6427f8
is($@->line,     $Caller_helper::line,     "External line number check");
Packit 6427f8
is($@->file,     $INC{"Caller_helper.pm"}, "External filename check");
Packit 6427f8
is($@->package, "Caller_helper",           "External package check");
Packit 6427f8
is($@->caller,  "Caller_helper::foo",      "External subname check");