Add ARM files
[dh-make-perl] / dev / arm / libhtml-parser-perl / libhtml-parser-perl-3.56 / t / pullparser.t
1 use Test::More tests => 3;
2
3 use HTML::PullParser;
4
5 my $doc = <<'EOT';
6 <title>Title</title>
7 <style> h1 { background: white }
8 <foo>
9 </style>
10 <H1 ID="3">Heading</H1>
11 <!-- ignore this -->
12
13 This is a text with a <A HREF="http://www.sol.no" name="l1">link</a>.
14 EOT
15
16 my $p = HTML::PullParser->new(doc   => $doc,
17                               start => 'event,tagname,@attr',
18                               end   => 'event,tagname',
19                               text  => 'event,dtext',
20
21                               ignore_elements         => [qw(script style)],
22                               unbroken_text           => 1,
23                               boolean_attribute_value => 1,
24                              );
25
26 my $t = $p->get_token;
27 is($t->[0], "start");
28 is($t->[1], "title");
29 $p->unget_token($t);
30
31 my @a;
32 while (my $t = $p->get_token) {
33     for (@$t) {
34         s/\s/./g;
35     }
36     push(@a, join("|", @$t));
37 }
38
39 my $res = join("\n", @a, "");
40 #diag $res;
41 is($res, <<'EOT');
42 start|title
43 text|Title
44 end|title
45 text|..
46 start|h1|id|3
47 text|Heading
48 end|h1
49 text|...This.is.a.text.with.a.
50 start|a|href|http://www.sol.no|name|l1
51 text|link
52 end|a
53 text|..
54 EOT
55