implement !
[catagits/Web-Simple.git] / t / tags.t
CommitLineData
afe60e53 1use strict; use warnings FATAL => 'all';
2use Test::More qw(no_plan);
3
4{
5
6 package Foo;
7
8 sub foo {
9 use XML::Tags qw(one two three);
10 <one>, <two>, <three>;
11 }
12
13 sub bar {
14 no warnings 'once'; # this is supposed to warn, it's broken
15 <one>
16 }
17
18 sub baz {
19 use XML::Tags qw(bar);
20 </bar>;
21 }
cb5717ef 22
23 sub quux {
24 use HTML::Tags;
cc050137 25 <html>, <body id="spoon">, "YAY", </body>, </html>;
cb5717ef 26 }
43a70ddb 27
0f339458 28 sub fleem {
29 use XML::Tags qw(woo);
30 my $ent = "one&two";
31 <woo ent="$ent">;
32 }
33
43a70ddb 34 sub globbery {
35 <t/globbery/*>;
36 }
afe60e53 37}
38
39is(
49a6c0b5 40 join(', ', XML::Tags::to_xml_string Foo::foo()),
afe60e53 41 '<one>, <two>, <three>',
42 'open tags ok'
43);
44
45ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag');
46
47is(
49a6c0b5 48 join(', ', XML::Tags::to_xml_string Foo::baz()),
afe60e53 49 '</bar>',
50 'close tag ok'
51);
cb5717ef 52
53is(
49a6c0b5 54 join('', HTML::Tags::to_html_string Foo::quux),
cb5717ef 55 '<html><body id="spoon">YAY</body></html>',
56 'HTML tags ok'
57);
43a70ddb 58
59is(
0f339458 60 join('', XML::Tags::to_xml_string Foo::fleem),
61 '<woo ent="one&amp;two">',
62 'Escaping ok'
63);
64
65is(
43a70ddb 66 join(', ', Foo::globbery),
67 't/globbery/one, t/globbery/two',
68 'real glob re-installed ok'
69);