File: largetags.t

package info (click to toggle)
libhtml-parser-perl 3.56-1%2Blenny1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 536 kB
  • ctags: 192
  • sloc: ansic: 1,985; perl: 1,935; makefile: 43
file content (38 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (7)
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
# Exercise the tokenpos buffer allocation routines by feeding it
# very large tags.

use Test::More tests => 2;

use strict;
use HTML::Parser ();

my $p = HTML::Parser->new(api_version => 3);

$p->handler("start" =>
	    sub {
		my $tp = shift;
		#diag int(@$tp), " - ", join(", ", @$tp);
		is(@$tp, 2 + 26 * 6 * 4);
	    }, "tokenpos");

$p->handler("declaration" =>
	    sub {
		my $t = shift;
		#diag int(@$t), " - @$t";
		is(@$t, 26 * 6 * 2 + 1);
	    }, "tokens");

$p->parse("<a ");
for ("aa" .. "fz") {
    $p->parse("$_=1 ");
}
$p->parse(">");

$p->parse("<!DOCTYPE ");
for ("aa" .. "fz") {
    $p->parse("$_ -- $_ -- ");
}
$p->parse(">");
$p->eof;
exit;