XML-Spice
view release on metacpan or search on metacpan
t/10-generation.t view on Meta::CPAN
"something arrayish",
qq(<perlzoo><animal type="camel"/><animal type="llama"/><animal type="dog"/></perlzoo>),
sub {
x("perlzoo",
x("animal", { type => "camel" }),
x("animal", { type => "llama" }),
x("animal", { type => "dog" }));
},
"single tag with text",
qq(<tag>value</tag>),
sub {
x("tag", "value");
},
"subtag with text",
qq(<tag><sub>value</sub></tag>),
sub {
x("tag",
x("sub", "value"));
},
"arrayish text",
qq(<words><weird>foo</weird><weird>bar</weird><weird>baz</weird></words>),
sub {
x("words",
x("weird", "foo"),
x("weird", "bar"),
x("weird", "baz"));
},
"more than one text bit",
qq(<text>together we make a sentence</text>),
sub {
x("text", "together we make ", "a sentence");
},
"text mixed with subtags",
qq(<p>this text is <b>bold</b>, while this is <i>italicised</i>.</p>),
sub {
x("p",
"this text is ",
x("b", "bold"),
", while this is ",
x("i", "italicised"),
".");
},
"escaping",
qq(<escapes>&<>"</escapes>),
sub {
x("escapes", '&<>"');
},
"numeric escaping",
qq(<escapes>).join('', (map { sprintf '&#%d;', $_ } (0x20 .. 0xd7ff))).qq(</escapes>),
sub {
x("escapes", join '', (map { chr($_) } (0x20 .. 0xd7ff)));
},
"0 as cdata works",
qq(<foo>0</foo>),
sub {
x("foo", 0);
},
);
while(@tests > 1) {
my $desc = shift @tests;
my $xml = shift @tests;
my $gen = shift @tests;
is_xml($xml, &{$gen}(), $desc);
}
diag("test set had leftover items, probable bug in $0") if @tests > 0;
( run in 1.417 second using v1.01-cache-2.11-cpan-6aa56a78535 )