summaryrefslogtreecommitdiff
path: root/t/process.t
blob: 9d27250a92fcdc067e3b0554405ee96bdac69b1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use strict;

use Test::More tests => 12;

my $pi;
my $orig;

use HTML::Parser ();
my $p = HTML::Parser->new(process_h => [sub { $pi = shift; $orig = shift; },
				        "token0,text"]
	                 );

$p->parse("<a><?foo><a>");

is($pi, "foo");
is($orig, "<?foo>");

$p->parse("<a><?><a>");
is($pi, "");
is($orig, "<?>");

$p->parse("<a><?
foo
><a>");
is($pi, "\nfoo\n");
is($orig, "<?\nfoo\n>");

for (qw(< a > < ? b a r > < a >)) {
   $p->parse($_);
}

is($pi, "bar");
is($orig, "<?bar>");

$p->xml_mode(1);

$p->parse("<a><?foo>bar??><a>");
is($pi, "foo>bar?");
is($orig, "<?foo>bar??>");

$p->parse("<a><??></a>");
is($pi, "");
is($orig, "<??>");