summaryrefslogtreecommitdiff
path: root/t/05text-errors-with-file-handles.t
blob: dd36b33ffab6d810a796ef4fe0f88f4e8c3b4856 (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl

use strict;
use warnings;

use Test::More tests => 4;

use Error qw(:try);

BEGIN
{
    use File::Spec;
    use lib File::Spec->catdir(File::Spec->curdir(), "t", "lib");
    use MyDie;
}

package MyError::Foo;

use vars qw(@ISA);

@ISA=(qw(Error));

package main;

my $ok = 1;
eval
{
    try
    {
        MyDie::mydie();
    }
    catch MyError::Foo with
    {
        my $err = shift;
        $ok = 0;
    };
};

my $err = $@;

# TEST
ok($ok, "Not MyError::Foo");

# TEST
ok($err->isa("Error::Simple"), "Testing");

# TEST
is($err->{-line}, 16, "Testing for correct line number");

# TEST
ok(($err->{-file} =~ m{MyDie\.pm$}), "Testing for correct module");