File: plaintext.t

package info (click to toggle)
libhtml-parser-perl 3.55-1%2Betch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 528 kB
  • ctags: 192
  • sloc: ansic: 1,986; perl: 1,935; makefile: 43
file content (45 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (3)
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
44
45
use Test::More tests => 2;

use strict;
use HTML::Parser;

my @a;
my $p = HTML::Parser->new(api_version => 3);
$p->handler(default => \@a, '@{event, text, is_cdata}');
$p->parse(<<EOT)->eof;
<xmp><foo></xmp>x<plaintext><foo>
</plaintext>
foo
EOT

for (@a) {
    $_ = "" unless defined;
}

my $doc = join(":", @a);

#diag $doc;

is($doc, "start_document:::start:<xmp>::text:<foo>:1:end:</xmp>::text:x::start:<plaintext>::text:<foo>
</plaintext>
foo
:1:end_document::");

@a = ();
$p->closing_plaintext('yep, emulate gecko');
$p->parse(<<EOT)->eof;
<plaintext><foo>
</plaintext>foo<b></b>
EOT

for (@a) {
    $_ = "" unless defined;
}

$doc = join(":", @a);

#diag $doc;

is($doc, "start_document:::start:<plaintext>::text:<foo>
:1:end:</plaintext>::text:foo::start:<b>::end:</b>::text:
::end_document::");