Add the original source packages to maemo, source lenny
[dh-make-perl] / dev / i386 / libhtml-tree-perl / libhtml-tree-perl-3.23 / t / children.t
diff --git a/dev/i386/libhtml-tree-perl/libhtml-tree-perl-3.23/t/children.t b/dev/i386/libhtml-tree-perl/libhtml-tree-perl-3.23/t/children.t
new file mode 100644 (file)
index 0000000..0924ecc
--- /dev/null
@@ -0,0 +1,25 @@
+#!/usr/bin/perl
+
+# RT 21114 test case.  Thanks Andrew Suhachov for finding it.
+
+use warnings;
+use strict;
+
+use Test::More tests=>4;
+
+BEGIN {
+       use_ok('HTML::TreeBuilder');
+}
+
+my $root = HTML::TreeBuilder->new();
+my $escape = '<table><tr><td>One</td><td>Two</td></tr><tr><td>Three</td><td>Four</td></tr></table>';
+my $html = $root->parse($escape)->eof;
+
+my $child = $root->look_down( _tag=>'tr', sub { my $tr = shift; $tr->look_down( _tag=>'td', _parent=>$tr) ? 1 : 0; } );
+isa_ok( $child, 'HTML::Element', "Child found");
+
+my @children = $root->look_down( _tag=>'tr', sub { my $tr = shift; $tr->look_down( _tag=>'td', _parent=>$tr) ? 1 : 0; } );
+cmp_ok( scalar(@children), '==', '2', "2 total children found");
+
+my $none = $root->look_down( _tag=>'tr', sub { 0 } );
+ok(!defined($none),'No children found');