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 | } |
afe60e53 |
27 | } |
28 | |
29 | is( |
cc050137 |
30 | join(', ', XML::Tags::sanitize Foo::foo()), |
afe60e53 |
31 | '<one>, <two>, <three>', |
32 | 'open tags ok' |
33 | ); |
34 | |
35 | ok(!eval { Foo::bar(); 1 }, 'Death on use of unimported tag'); |
36 | |
37 | is( |
cc050137 |
38 | join(', ', XML::Tags::sanitize Foo::baz()), |
afe60e53 |
39 | '</bar>', |
40 | 'close tag ok' |
41 | ); |
cb5717ef |
42 | |
43 | is( |
cc050137 |
44 | join('', XML::Tags::sanitize Foo::quux), |
cb5717ef |
45 | '<html><body id="spoon">YAY</body></html>', |
46 | 'HTML tags ok' |
47 | ); |