rewrite home page redirect
[dh-make-perl] / dev / arm / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / declaration.t
1 use Test::More tests => 2;
2
3 use HTML::Parser;
4 my $res = "";
5
6 sub decl
7 {
8     my $t = shift;
9     $res .= "[" . join("\n", map "<$_>", @$t) . "]";
10 }
11
12 sub text
13 {
14     $res .= shift;
15 }
16
17 my $p = HTML::Parser->new(declaration_h => [\&decl, "tokens"],
18                           default_h     => [\&text, "text"],
19                          );
20
21 $p->parse(<<EOT)->eof;
22 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" --<comment>--
23   "http://www.w3.org/TR/html40/strict.dtd">
24
25 <!ENTITY foo "<!-- foo -->">
26 <!Entity foo "<!-- foo -->">
27
28 <!row --> foo
29 EOT
30
31 is($res, <<EOT);
32 [<DOCTYPE>
33 <HTML>
34 <PUBLIC>
35 <"-//W3C//DTD HTML 4.01//EN">
36 <--<comment>-->
37 <"http://www.w3.org/TR/html40/strict.dtd">]
38
39 [<ENTITY>
40 <foo>
41 <"<!-- foo -->">]
42 [<Entity>
43 <foo>
44 <"<!-- foo -->">]
45
46 <!row --> foo
47 EOT
48
49 $res = "";
50 $p->parse(<<EOT)->eof;
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
52  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"[]>
53 EOT
54 is($res, <<EOT);
55 [<DOCTYPE>
56 <html>
57 <PUBLIC>
58 <"-//W3C//DTD XHTML 1.0 Strict//EN">
59 <"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
60 <[]>]
61 EOT
62