af792cb610aabfadbf57ab8b21b4c84d520dcebd
[catagits/Web-Simple.git] / t / tags.t
1 use strict; use warnings FATAL => 'all';
2 use 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   }
22
23   sub quux {
24     use HTML::Tags;
25     <html>, <body id="spoon">, "YAY", </body>, </html>;
26   }
27
28   sub fleem {
29     use XML::Tags qw(woo);
30     my $ent = "one&two";
31     <woo ent="$ent">;
32   }
33
34 sub flaax {
35   use XML::Tags qw(woo);
36   my $data = "one&two<three>four";
37   <woo>,  $data, </woo>,
38   <woo>, \$data, </woo>;
39 }
40
41   sub globbery {
42     <t/globbery/*>;
43   }
44 }
45
46 is(
47   join(', ', XML::Tags::to_xml_string Foo::foo()),
48   '<one>, <two>, <three>',
49   'open tags ok'
50 );
51
52 ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag');
53
54 is(
55   join(', ', XML::Tags::to_xml_string Foo::baz()),
56   '</bar>',
57   'close tag ok'
58 );
59
60 is(
61   join('', HTML::Tags::to_html_string Foo::quux),
62   '<html><body id="spoon">YAY</body></html>',
63   'HTML tags ok'
64 );
65
66 is(
67   join('', XML::Tags::to_xml_string Foo::fleem),
68   '<woo ent="one&amp;two">',
69   'Escaping ok'
70 );
71
72 is(
73   join('', XML::Tags::to_xml_string Foo::flaax),
74   '<woo>one&amp;two&lt;three&gt;four</woo><woo>one&two<three>four</woo>',
75   'Escaping user data ok'
76 );
77
78 is(
79   join(', ', Foo::globbery),
80   't/globbery/one, t/globbery/two',
81   'real glob re-installed ok'
82 );