1 use Test::More tests => 6;
6 my $p = HTML::Parser->new(api_version => 3);
8 $p->handler(start => sub { my $attr = shift; is($attr->{testno}, 1) },
10 $p->handler(end => sub { shift->eof }, "self");
12 $p->handler(text => sub { $text = shift }, "text");
14 is($p->parse("<foo testno=1>"), $p);
17 ok(!$p->parse("</foo><foo testno=999>"));
20 $p->handler(end => sub { $p->parse("foo"); }, "");
24 like($@, qr/Parse loop not allowed/);
26 # We used to get into an infinite loop if the eof triggered
27 # handler called ->eof
30 $p = HTML::Parser->new(api_version => 3);
33 $p->handler("default" =>
42 # We used to sometimes trigger events after a handler signaled eof
44 $p = HTML::Parser->new(api_version => 3,);
45 $p->handler(start=> \&title_handler, 'tagname, self');
46 $p->parse("<head><title>foo</title>\n</head>");
50 return if shift ne 'title';
52 $self->handler(text => sub { $title .= shift}, 'dtext');
53 $self->handler(end => sub { shift->eof if shift eq 'title' }, 'tagname, self');