1## skip Test::Tabs
2use Test::More tests => 5;
3use HTML::HTML5::Parser;
4
5my $parser = HTML::HTML5::Parser->new;
6my $input  = "<b>Hello</b></td></tr> <i>World</i>";
7my $NS     = 'xmlns="http://www.w3.org/1999/xhtml"';
8
9can_ok $parser => 'parse_balanced_chunk';
10
11is(
12	$parser->parse_balanced_chunk($input, {within=>'div'})->toString,
13	"<b $NS>Hello</b> <i $NS>World</i>",
14	'within div',
15	);
16
17is(
18	$parser->parse_balanced_chunk($input, {within=>'td'})->toString,
19	"<i $NS>World</i><b $NS>Hello</b> ",
20	'within td',
21	);
22
23is(
24	$parser->parse_balanced_chunk($input, {force_within=>'td'})->toString,
25	"<b $NS>Hello</b>",
26	'force within td',
27	);
28
29my $list = $parser->parse_balanced_chunk($input, {mark_outliers=>1, within=>'td', as=>'list'});
30ok(
31	$list->get_node(1)->hasAttribute('data-perl-html-html5-parser-outlier'),
32	'mark outliers',
33	);
34
35=head1 PURPOSE
36
37Test C<parse_balanced_chunk> method.
38
39=head1 AUTHOR
40
41Toby Inkster, E<lt>tobyink@cpan.orgE<gt>
42
43=head1 COPYRIGHT AND LICENCE
44
45Copyright (C) 2012 by Toby Inkster
46
47This library is free software; you can redistribute it and/or modify
48it under the same terms as Perl itself.
49