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
|
#!perl -w
use Test;
plan tests => 6;
use HTML::Parser;
use File::Spec;
my $events;
my $p = HTML::Parser->new(default_h => [sub { $events .= "$_[0]\n";}, "event"]);
$events = "";
$p->eof;
ok($events, "start_document\nend_document\n");
$events = "";
$p->parse_file(File::Spec->devnull);
ok($events, "start_document\nend_document\n");
$events = "";
$p->parse("");
$p->eof;
ok($events, "start_document\nend_document\n");
$events = "";
$p->parse("");
$p->parse("");
$p->eof;
ok($events, "start_document\nend_document\n");
$events = "";
$p->parse("");
$p->parse("<a>");
$p->eof;
ok($events, "start_document\nstart\nend_document\n");
$events = "";
$p->parse("<a> ");
$p->eof;
ok($events, "start_document\nstart\ntext\nend_document\n");
|