Add ARM files
[dh-make-perl] / dev / arm / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / unbroken-text.t
1 use strict;
2 use HTML::Parser;
3
4 use Test::More tests => 3;
5
6 my $text = "";
7 sub text
8 {
9     my $cdata = shift() ? "CDATA" : "TEXT";
10     my($offset, $line, $col, $t) = @_;
11     $text .= "[$cdata:$offset:$line.$col:$t]";
12 }
13
14 sub tag
15 {
16     $text .= shift;
17 }
18
19 my $p = HTML::Parser->new(unbroken_text => 1,
20                           text_h =>  [\&text, "is_cdata,offset,line,column,text"],
21                           start_h => [\&tag, "text"],
22                           end_h   => [\&tag, "text"],
23                          );
24
25 $p->parse("foo ");
26 $p->parse("bar ");
27 $p->parse("<foo>");
28 $p->parse("bar\n");
29 $p->parse("</foo>");
30 $p->parse("<xmp>xmp</xmp>");
31 $p->parse("atend");
32
33 #diag $text;
34 is($text, "[TEXT:0:1.0:foo bar ]<foo>[TEXT:13:1.13:bar\n]</foo><xmp>[CDATA:28:2.11:xmp]</xmp>");
35
36 $text = "";
37 $p->eof;
38
39 #diag $text;
40 is($text, "[TEXT:37:2.20:atend]");
41
42
43 $p = HTML::Parser->new(unbroken_text => 1,
44                        text_h => [\&text, "is_cdata,offset,line,column,text"],
45                       );
46
47 $text = "";
48 $p->parse("foo");
49 $p->parse("<foo");
50 $p->parse(">bar\n");
51 $p->parse("foo<xm");
52 $p->parse("p>xmp");
53 $p->parse("</xmp");
54 $p->parse(">bar");
55 $p->eof;
56
57 #diag $text;
58 is($text, "[TEXT:0:1.0:foobar\nfoo][CDATA:20:2.8:xmp][TEXT:29:2.17:bar]");
59
60