Commit | Line | Data |
afe60e53 |
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 | } |
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); |
be64ff24 |
30 | my $ent = 'one&two<three>"four'; |
0f339458 |
31 | <woo ent="$ent">; |
32 | } |
33 | |
dc7d4cf0 |
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 | } |
9935bd6c |
40 | |
943937da |
41 | sub PI { |
42 | use XML::Tags; |
43 | <?xml version="1.0" encoding="UTF-8"?>; |
44 | } |
45 | |
4882e90f |
46 | sub DTD { |
47 | use HTML::Tags; |
48 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
49 | } |
50 | |
43a70ddb |
51 | sub globbery { |
52 | <t/globbery/*>; |
53 | } |
afe60e53 |
54 | } |
55 | |
56 | is( |
49a6c0b5 |
57 | join(', ', XML::Tags::to_xml_string Foo::foo()), |
afe60e53 |
58 | '<one>, <two>, <three>', |
59 | 'open tags ok' |
60 | ); |
61 | |
62 | ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag'); |
63 | |
64 | is( |
49a6c0b5 |
65 | join(', ', XML::Tags::to_xml_string Foo::baz()), |
afe60e53 |
66 | '</bar>', |
67 | 'close tag ok' |
68 | ); |
cb5717ef |
69 | |
70 | is( |
49a6c0b5 |
71 | join('', HTML::Tags::to_html_string Foo::quux), |
cb5717ef |
72 | '<html><body id="spoon">YAY</body></html>', |
73 | 'HTML tags ok' |
74 | ); |
43a70ddb |
75 | |
76 | is( |
0f339458 |
77 | join('', XML::Tags::to_xml_string Foo::fleem), |
be64ff24 |
78 | '<woo ent="one&two<three>"four">', |
0f339458 |
79 | 'Escaping ok' |
80 | ); |
81 | |
82 | is( |
9935bd6c |
83 | join('', XML::Tags::to_xml_string Foo::flaax), |
84 | '<woo>one&two<three>four</woo><woo>one&two<three>four</woo>', |
85 | 'Escaping user data ok' |
86 | ); |
87 | |
88 | is( |
943937da |
89 | join('', XML::Tags::to_xml_string Foo::PI), |
90 | '<?xml version="1.0" encoding="UTF-8"?>', |
91 | 'XML processing instruction' |
92 | ); |
93 | |
94 | is( |
4882e90f |
95 | join('', HTML::Tags::to_html_string Foo::DTD), |
96 | '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', |
97 | 'DTD ok' |
98 | ); |
99 | |
100 | is( |
43a70ddb |
101 | join(', ', Foo::globbery), |
102 | 't/globbery/one, t/globbery/two', |
103 | 'real glob re-installed ok' |
104 | ); |