File: caller.t

package info (click to toggle)
libautodie-perl 2.10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 528 kB
  • ctags: 305
  • sloc: perl: 4,012; makefile: 4
file content (34 lines) | stat: -rwxr-xr-x 743 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl -w
use strict;
use warnings;
use autodie;
use Test::More 'no_plan';
use FindBin qw($Bin);
use lib "$Bin/lib";
use Caller_helper;

use constant NO_SUCH_FILE => "kiwifoo_is_so_much_fun";

eval {
    foo();
};

isa_ok($@, 'autodie::exception');

is($@->caller, 'main::foo', "Caller should be main::foo");

sub foo {
    use autodie;
    open(my $fh, '<', NO_SUCH_FILE);
}

eval {
    Caller_helper::foo();
};

isa_ok($@, 'autodie::exception');

is($@->line,     $Caller_helper::line,     "External line number check");
is($@->file,     $INC{"Caller_helper.pm"}, "External filename check");
is($@->package, "Caller_helper",           "External package check");
is($@->caller,  "Caller_helper::foo",      "External subname check");