3 # RT 21114 test case. Thanks Andrew Suhachov for finding it.
8 use Test::More tests=>4;
11 use_ok('HTML::TreeBuilder');
14 my $root = HTML::TreeBuilder->new();
15 my $escape = '<table><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></table>';
16 my $html = $root->parse($escape)->eof;
18 my $child = $root->look_down( _tag=>'tr', sub { my $tr = shift; $tr->look_down( _tag=>'td', _parent=>$tr) ? 1 : 0; } );
19 isa_ok( $child, 'HTML::Element', "Child found");
21 my @children = $root->look_down( _tag=>'tr', sub { my $tr = shift; $tr->look_down( _tag=>'td', _parent=>$tr) ? 1 : 0; } );
22 cmp_ok( scalar(@children), '==', '2', "2 total children found");
24 my $none = $root->look_down( _tag=>'tr', sub { 0 } );
25 ok(!defined($none),'No children found');