Commit | Line | Data |
afe60e53 |
1 | use strict; use warnings FATAL => 'all'; |
2 | use Test::More qw(no_plan); |
3 | |
724b3136 |
4 | my $globbery; |
5 | BEGIN { $globbery = join(', ', <t/globbery/o* t/globbery/t*>) } |
afe60e53 |
6 | { |
7 | |
8 | package Foo; |
9 | |
10 | sub foo { |
11 | use XML::Tags qw(one two three); |
12 | <one>, <two>, <three>; |
13 | } |
14 | |
15 | sub bar { |
16 | no warnings 'once'; # this is supposed to warn, it's broken |
17 | <one> |
18 | } |
19 | |
20 | sub baz { |
21 | use XML::Tags qw(bar); |
22 | </bar>; |
23 | } |
cb5717ef |
24 | |
25 | sub quux { |
26 | use HTML::Tags; |
cc050137 |
27 | <html>, <body id="spoon">, "YAY", </body>, </html>; |
cb5717ef |
28 | } |
43a70ddb |
29 | |
318343ca |
30 | sub xquux { |
31 | use HTML::Tags; |
32 | <link href="#self" rel="me" />, |
33 | <table>,<tr>,<td>,'x',<sub>,1,</sub>,</td>,</tr>,</table>; |
34 | } |
35 | |
0f339458 |
36 | sub fleem { |
37 | use XML::Tags qw(woo); |
be64ff24 |
38 | my $ent = 'one&two<three>"four'; |
0f339458 |
39 | <woo ent="$ent">; |
40 | } |
41 | |
dc7d4cf0 |
42 | sub flaax { |
43 | use XML::Tags qw(woo); |
44 | my $data = "one&two<three>four"; |
45 | <woo>, $data, </woo>, |
46 | <woo>, \$data, </woo>; |
47 | } |
9935bd6c |
48 | |
9d031ab2 |
49 | sub HTML_comment { |
50 | use HTML::Tags; |
51 | <!-- this is a comment -->; |
52 | } |
53 | |
943937da |
54 | sub PI { |
55 | use XML::Tags; |
56 | <?xml version="1.0" encoding="UTF-8"?>; |
57 | } |
58 | |
4882e90f |
59 | sub DTD { |
60 | use HTML::Tags; |
61 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
62 | } |
63 | |
43a70ddb |
64 | sub globbery { |
724b3136 |
65 | <t/globbery/o* t/globbery/t*>; |
43a70ddb |
66 | } |
afe60e53 |
67 | } |
68 | |
69 | is( |
49a6c0b5 |
70 | join(', ', XML::Tags::to_xml_string Foo::foo()), |
afe60e53 |
71 | '<one>, <two>, <three>', |
72 | 'open tags ok' |
73 | ); |
74 | |
75 | ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag'); |
76 | |
77 | is( |
49a6c0b5 |
78 | join(', ', XML::Tags::to_xml_string Foo::baz()), |
afe60e53 |
79 | '</bar>', |
80 | 'close tag ok' |
81 | ); |
cb5717ef |
82 | |
83 | is( |
49a6c0b5 |
84 | join('', HTML::Tags::to_html_string Foo::quux), |
cb5717ef |
85 | '<html><body id="spoon">YAY</body></html>', |
86 | 'HTML tags ok' |
87 | ); |
43a70ddb |
88 | |
89 | is( |
318343ca |
90 | join('', HTML::Tags::to_html_string Foo::xquux), |
91 | '<link href="#self" rel="me" />' . |
92 | '<table><tr><td>x<sub>1</sub></td></tr></table>', |
93 | 'Conflicting HTML tags ok' |
94 | ); |
95 | |
96 | is( |
9d031ab2 |
97 | join('', XML::Tags::to_xml_string Foo::HTML_comment), |
98 | '<!-- this is a comment -->', |
99 | 'HTML comment ok' |
100 | ); |
101 | |
102 | is( |
0f339458 |
103 | join('', XML::Tags::to_xml_string Foo::fleem), |
be64ff24 |
104 | '<woo ent="one&two<three>"four">', |
0f339458 |
105 | 'Escaping ok' |
106 | ); |
107 | |
108 | is( |
9935bd6c |
109 | join('', XML::Tags::to_xml_string Foo::flaax), |
110 | '<woo>one&two<three>four</woo><woo>one&two<three>four</woo>', |
111 | 'Escaping user data ok' |
112 | ); |
113 | |
114 | is( |
943937da |
115 | join('', XML::Tags::to_xml_string Foo::PI), |
116 | '<?xml version="1.0" encoding="UTF-8"?>', |
117 | 'XML processing instruction' |
118 | ); |
119 | |
120 | is( |
4882e90f |
121 | join('', HTML::Tags::to_html_string Foo::DTD), |
122 | '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', |
123 | 'DTD ok' |
124 | ); |
125 | |
126 | is( |
43a70ddb |
127 | join(', ', Foo::globbery), |
724b3136 |
128 | $globbery, |
43a70ddb |
129 | 'real glob re-installed ok' |
130 | ); |