Commit | Line | Data |
e1b4b35c |
1 | use strictures 1; |
2 | use Test::More; |
3 | use HTML::String; |
4 | |
5 | my $hi = 'Hi <bob>'; |
6 | |
7 | my $one = html('<tag>').$hi.html('</tag>'); |
8 | |
9 | is("$one", '<tag>Hi <bob></tag>'); |
10 | |
11 | my $two = do { |
12 | use HTML::String::Overload; |
13 | |
ed99cbb4 |
14 | "<tag>${hi}</tag>"; |
e1b4b35c |
15 | }; |
16 | |
17 | is("$two", '<tag>Hi <bob></tag>'); |
18 | |
f27b509e |
19 | my $three = html('<tag>'); |
20 | |
21 | $three .= $hi; |
22 | |
23 | $three .= html('</tag>'); |
24 | |
25 | is("$three", '<tag>Hi <bob></tag>'); |
26 | |
27 | my $four; { |
f554c1ff |
28 | use HTML::String::Overload { ignore => { non_existant_package_name => 1 } }; |
f27b509e |
29 | |
30 | #$four = "<tag>".$hi."</tag>\n"; |
31 | $four = "<tag>$hi</tag>"."\n"; |
32 | }; |
33 | |
34 | chomp($four); |
35 | |
36 | is("$four", '<tag>Hi <bob></tag>'); |
37 | |
b8aaa17d |
38 | { |
39 | package MyPkg; |
40 | |
41 | sub new { 'foo' } |
42 | |
43 | sub load { 'bar' } |
44 | } |
45 | |
46 | is(html('MyPkg')->new, 'foo'); |
47 | |
48 | is(html('MyPkg')->load, 'bar'); |
49 | |
fc076557 |
50 | # Test that all characters that should be escaped are escaped |
51 | |
52 | my $raw_characters = q{<>&"'}; |
53 | my $expected_output = q{<tag><>&"'</tag>}; |
54 | my $html = html('<tag>').$raw_characters.html('</tag>'); |
55 | is($html, $expected_output); |
56 | |
ac4c210b |
57 | ok(HTML::String::Value->isa('HTML::String::Value'), 'isa on class ok'); |
58 | |
59 | is($@, '', '$@ not set by check'); |
fc076557 |
60 | |
cb4648fa |
61 | is do { |
62 | use HTML::String::Overload; |
63 | '' . '0' |
64 | }, '0', 'concatenating strings which are false in boolean context'; |
65 | |
e1b4b35c |
66 | done_testing; |