Debian lenny version packages
[pkg-perl] / deb-src / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / msie-compat.t
1 #!perl -w
2
3 use strict;
4 use HTML::Parser;
5
6 use Test::More tests => 2;
7
8 my $TEXT = "";
9 sub h
10 {
11     my($event, $tagname, $text) = @_;
12     for ($event, $tagname, $text) {
13         if (defined) {
14             s/([\n\r\t])/sprintf "\\%03o", ord($1)/ge;
15         }
16         else {
17             $_ = "<undef>";
18         }
19     }
20
21     $TEXT .= "[$event,$tagname,$text]\n";
22 }
23
24 my $p = HTML::Parser->new(default_h => [\&h, "event,tagname,text"]);
25 $p->parse("<a>");
26 $p->parse("</a f>");
27 $p->parse("</a 'foo<>' 'bar>' x>");
28 $p->parse("</a \"foo<>\"");
29 $p->parse(" \"bar>\" x>");
30 $p->parse("</ foo bar>");
31 $p->parse("</ \"<>\" >");
32 $p->parse("<!--comment>text<!--comment><p");
33 $p->eof;
34
35 is($TEXT, <<'EOT');
36 [start_document,<undef>,]
37 [start,a,<a>]
38 [end,a,</a f>]
39 [end,a,</a 'foo<>' 'bar>' x>]
40 [end,a,</a "foo<>" "bar>" x>]
41 [comment, foo bar,</ foo bar>]
42 [comment, "<>" ,</ "<>" >]
43 [comment,comment,<!--comment>]
44 [text,<undef>,text]
45 [comment,comment,<!--comment>]
46 [comment,p,<p]
47 [end_document,<undef>,]
48 EOT
49
50 $TEXT = "";
51 $p->parse("<!comment>");
52 $p->eof;
53
54 is($TEXT, <<'EOT');
55 [start_document,<undef>,]
56 [comment,comment,<!comment>]
57 [end_document,<undef>,]
58 EOT