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'));
|