| 20 |
} |
} |
| 21 |
|
|
| 22 |
use Test; |
use Test; |
| 23 |
BEGIN { plan tests => 410 } |
BEGIN { plan tests => 422 } |
| 24 |
|
|
| 25 |
use Data::Dumper; |
use Data::Dumper; |
| 26 |
$Data::Dumper::Useqq = 1; |
$Data::Dumper::Useqq = 1; |
| 55 |
} elsif (/^#document$/) { |
} elsif (/^#document$/) { |
| 56 |
$test->{document} = ''; |
$test->{document} = ''; |
| 57 |
$mode = 'document'; |
$mode = 'document'; |
| 58 |
|
} elsif (/^#document-fragment (\S+)$/) { |
| 59 |
|
$test->{document} = ''; |
| 60 |
|
$mode = 'document'; |
| 61 |
|
$test->{element} = $1; |
| 62 |
} elsif (defined $test->{document} and /^$/) { |
} elsif (defined $test->{document} and /^$/) { |
| 63 |
test ($test); |
test ($test); |
| 64 |
undef $test; |
undef $test; |
| 88 |
exit; |
exit; |
| 89 |
}; |
}; |
| 90 |
|
|
| 91 |
Whatpm::HTML->parse_string |
my $onerror = sub { |
| 92 |
($test->{data} => $doc, sub { |
my %opt = @_; |
| 93 |
my $msg = shift; |
push @errors, join ':', $opt{line}, $opt{column}, $opt{type}; |
| 94 |
push @errors, $msg; |
}; |
| 95 |
}); |
my $result; |
| 96 |
|
unless (defined $test->{element}) { |
| 97 |
|
Whatpm::HTML->parse_string ($test->{data} => $doc, $onerror); |
| 98 |
|
$result = serialize ($doc); |
| 99 |
|
} else { |
| 100 |
|
my $el = $doc->create_element_ns |
| 101 |
|
('http://www.w3.org/1999/xhtml', [undef, $test->{element}]); |
| 102 |
|
Whatpm::HTML->set_inner_html ($el, $test->{data}, $onerror); |
| 103 |
|
$result = serialize ($el); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
ok scalar @errors, scalar @{$test->{errors}}, |
ok scalar @errors, scalar @{$test->{errors}}, |
| 107 |
'Parse error: ' . $test->{data} . '; ' . |
'Parse error: ' . $test->{data} . '; ' . |
| 108 |
join (', ', @errors) . ';' . join (', ', @{$test->{errors}}); |
join (', ', @errors) . ';' . join (', ', @{$test->{errors}}); |
| 109 |
|
|
| 110 |
my $doc_s = serialize ($doc); |
ok $result, $test->{document}, 'Document tree: ' . $test->{data}; |
|
ok $doc_s, $test->{document}, 'Document tree: ' . $test->{data}; |
|
| 111 |
} # test |
} # test |
| 112 |
|
|
| 113 |
sub serialize ($) { |
sub serialize ($) { |