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