File: 01exception.t

package info (click to toggle)
libxml-sax-base-perl 1.09-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 328 kB
  • sloc: perl: 3,142; makefile: 6
file content (49 lines) | stat: -rw-r--r-- 1,090 bytes parent folder | download | duplicates (8)
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
use Test;
BEGIN { plan tests => 14 }
use XML::SAX::Exception;
eval {
    throw XML::SAX::Exception ( Message => "Test" );
};
ok($@); # test died
ok($@, "Test\n"); # test stringification
ok($@->isa('XML::SAX::Exception')); # test isa

eval {
    throw XML::SAX::Exception::Parse (
            Message => "Parse",
            LineNumber => 12,
            ColumnNumber => 2,
            SystemId => "throw.xml",
            PublicId => "Some // Public // Identifier",
            );
};
ok($@);
ok($@->{Message}, "Parse");
ok($@, qr/Parse/);
ok($@->{LineNumber}, 12);
ok($@->isa('XML::SAX::Exception::Parse'));

eval {
    throw XML::SAX::Exception::ThisOneDoesNotExist (
            Message => "Fubar",
            );
};
ok($@);
ok(!UNIVERSAL::isa($@, 'XML::SAX::Exception'));

eval {
    throw XML::SAX::Exception::NotRecognized (
            Message => "Not Recognized",
            );
};
ok($@);
ok($@->isa('XML::SAX::Exception'));

eval {
    throw XML::SAX::Exception::NotSupported (
            Message => "Not Supported",
            );
};
ok($@);
ok($@->isa('XML::SAX::Exception'));