Debian lenny version packages
[pkg-perl] / deb-src / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / body.t
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5
6 use Test::More tests => 11;
7
8 BEGIN {
9         use_ok('HTML::TreeBuilder');
10 }
11
12 EMPTY: {
13         my $root = HTML::TreeBuilder->new();
14         $root->implicit_body_p_tag(1);
15         $root->xml_mode(1);
16         $root->parse('');
17         $root->eof();
18
19         is($root->as_HTML(),"<html><head></head><body></body></html>\n");
20 }
21
22 BR_ONLY: {
23         my $root = HTML::TreeBuilder->new();
24         $root->implicit_body_p_tag(1);
25         $root->xml_mode(1);
26         $root->parse('<br />');
27         $root->eof();
28
29         is($root->as_HTML(),"<html><head></head><body><p><br /></body></html>\n");
30 }
31
32 TEXT_ONLY: {
33         my $root = HTML::TreeBuilder->new();
34         $root->implicit_body_p_tag(1);
35         $root->xml_mode(1);
36         $root->parse('text');
37         $root->eof();
38
39         is($root->as_HTML(),"<html><head></head><body><p>text</body></html>\n");
40 }
41
42 EMPTY_TABLE: {
43         my $root = HTML::TreeBuilder->new();
44         $root->implicit_body_p_tag(1);
45         $root->xml_mode(1);
46         $root->parse('<table></table>');
47         $root->eof();
48
49         is($root->as_HTML(),"<html><head></head><body><table></table></body></html>\n");
50 }
51
52 ESCAPES: {
53         my $root = HTML::TreeBuilder->new();
54         my $escape = 'This &#x17f;oftware has &#383;ome bugs';
55         my $html = $root->parse($escape)->eof->elementify();
56         TODO: {
57                 local $TODO = 'HTML::Parser::parse mucks with our escapes';
58                 is($html->as_HTML(),"<html><head></head><body>$escape</body></html>\n");
59         }
60 }
61
62 OTHER_LANGUAGES: {
63         my $root = HTML::TreeBuilder->new();
64         my $escape = 'Geb&uuml;hr vor Ort von &euro; 30,- pro Woche'; # RT 14212
65         my $html = $root->parse($escape)->eof;
66         is($html->as_HTML(),"<html><head></head><body>Geb&uuml;hr vor Ort von &euro; 30,- pro Woche</body></html>\n");
67 }
68
69 RT_18570: {
70         my $root = HTML::TreeBuilder->new();
71         my $escape = 'This &sim; is a twiddle';
72         my $html = $root->parse($escape)->eof->elementify();
73         is($html->as_HTML(),"<html><head></head><body>$escape</body></html>\n");
74 }
75
76 RT_18571: {
77         my $root = HTML::TreeBuilder->new();
78         my $html = $root->parse('<b>$self->escape</b>')->eof->elementify();
79         is($html->as_HTML(),"<html><head></head><body><b>\$self-&gt;escape</b></body></html>\n");
80         is($html->as_HTML(''),"<html><head></head><body><b>\$self->escape</b></body></html>\n");
81         is($html->as_HTML("\0"),"<html><head></head><body><b>\$self->escape</b></body></html>\n"); # 3.22 compatability
82 }