Debian lenny version packages
[pkg-perl] / deb-src / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / textarea.t
1 use Test::More tests => 1;
2
3 use strict;
4 use HTML::Parser;
5
6 my $html = <<'EOT';
7 <html>
8 <title>This is a <nice> title</title>
9 <!--comment-->
10 <script language="perl">while (<DATA>) { &amp; }</script>
11
12 <FORM>
13
14 <textarea name="foo" cols=50 rows=10>
15
16 foo
17 <foo>
18 <!--comment-->
19 &amp;
20 foo
21 </FORM>
22
23 </textarea>
24
25 </FORM>
26
27 </html>
28 EOT
29
30 my $dump = "";
31 sub tdump {
32    my @a = @_;
33    for (@a) {
34       $_ = "<undef>" unless defined;
35       s/\n/\\n/g;
36    }
37    $dump .= join("|", @a) . "\n";
38 }
39
40 my $p = HTML::Parser->new(default_h => [\&tdump, "event,text,dtext,is_cdata"]);
41 $p->parse($html)->eof;
42
43 #diag $dump;
44
45 is($dump, <<'EOT');
46 start_document||<undef>|<undef>
47 start|<html>|<undef>|<undef>
48 text|\n|\n|
49 start|<title>|<undef>|<undef>
50 text|This is a <nice> title|This is a <nice> title|
51 end|</title>|<undef>|<undef>
52 text|\n|\n|
53 comment|<!--comment-->|<undef>|<undef>
54 text|\n|\n|
55 start|<script language="perl">|<undef>|<undef>
56 text|while (<DATA>) { &amp; }|while (<DATA>) { &amp; }|1
57 end|</script>|<undef>|<undef>
58 text|\n\n|\n\n|
59 start|<FORM>|<undef>|<undef>
60 text|\n\n|\n\n|
61 start|<textarea name="foo" cols=50 rows=10>|<undef>|<undef>
62 text|\n\nfoo\n<foo>\n<!--comment-->\n&amp;\nfoo\n</FORM>\n\n|\n\nfoo\n<foo>\n<!--comment-->\n&\nfoo\n</FORM>\n\n|
63 end|</textarea>|<undef>|<undef>
64 text|\n\n|\n\n|
65 end|</FORM>|<undef>|<undef>
66 text|\n\n|\n\n|
67 end|</html>|<undef>|<undef>
68 text|\n|\n|
69 end_document||<undef>|<undef>
70 EOT