use XML::Tiny qw(parsefile);
use strict;
require "t/test_functions";
print "1..7\n";
$^W = 1;
$SIG{__WARN__} = sub { die("Caught a warning, making it fatal:\n\n$_[0]\n"); };
is_deeply(
parsefile(q{_TINY_XML_STRING_&&rubbish;&<>"'}),
[{name => 'x', attrib => {}, type => 'e', content => [{type => 't', content => '&&rubbish;&<>"\''}]}],
"All five entities are normally parsed OK"
);
is_deeply(
parsefile(q{_TINY_XML_STRING_A}),
[{name => 'x', attrib => {}, type => 'e', content => [{type => 't', content => 'A'}]}],
"base ten numeric char entities are normally parsed OK"
);
is_deeply(
parsefile(q{_TINY_XML_STRING_A}),
[{name => 'x', attrib => {}, type => 'e', content => [{type => 't', content => 'A'}]}],
"base 16 numeric char entities are normally parsed OK"
);
is_deeply(
parsefile(q{_TINY_XML_STRING_ª}),
parsefile(q{_TINY_XML_STRING_ª}),
"non-ASCII works, and hex entities aren't case-sensitive"
);
is_deeply(
parsefile(q{_TINY_XML_STRING_&&rubbish;&<>"'}, no_entity_parsing => 1),
[{name => 'x', attrib => {}, type => 'e', content => [{type => 't', content => '&&rubbish;&<>"''}]}],
"no_entity_parsing works"
);
eval { parsefile(q{_TINY_XML_STRING_&}, strict_entity_parsing => 1) };
ok($@, 'strict entity parsing hates naked ampersands');
eval { parsefile(q{_TINY_XML_STRING_&rubbish;}, strict_entity_parsing => 1) };
ok($@, 'strict entity parsing hates unknown entities');