]>
Commit | Line | Data |
---|---|---|
aa016126 MG |
1 | #!/usr/bin/perl |
2 | use t::lib tests => 3; | |
67e78ff2 | 3 | |
4 | # a - default table_ld | |
5 | ||
aa016126 | 6 | my $tree = mktree 't/html/table2.html'; |
67e78ff2 | 7 | |
8 | my @tr = HTML::Element::Library::ref_or_ld( | |
aa016126 MG |
9 | $tree, |
10 | ['_tag' => 'tr'] | |
11 | ); | |
67e78ff2 | 12 | |
aa016126 | 13 | is (scalar @tr, 16, 'table2 tr look_down (default)'); |
67e78ff2 | 14 | |
15 | # b - arrayref tr_ld | |
16 | ||
aa016126 | 17 | $tree = mktree 't/html/table2-tr_ld-arrayref.html'; |
67e78ff2 | 18 | |
19 | my $tr = HTML::Element::Library::ref_or_ld( | |
aa016126 MG |
20 | $tree, |
21 | [class => 'findMe'] | |
22 | ); | |
67e78ff2 | 23 | |
aa016126 | 24 | isxml $tr, 't/html/table2-tr_ld-arrayref.exp', 'table2 tr look_down (arrayref)'; |
67e78ff2 | 25 | |
26 | # c - coderef tr_ld | |
27 | # removes windows listings before returning @tr | |
28 | ||
aa016126 | 29 | $tree = mktree 't/html/table2.html'; |
67e78ff2 | 30 | |
31 | @tr = HTML::Element::Library::ref_or_ld( | |
aa016126 MG |
32 | $tree, |
33 | sub { | |
34 | my ($t) = @_; | |
35 | my @tr = $t->look_down('_tag' => 'tr'); | |
36 | my @keep; | |
37 | for my $tr (@tr) { | |
38 | ||
39 | my @td = $tr->look_down ('_tag' => 'td') ; | |
40 | my $detached; | |
41 | for my $td (@td) { | |
42 | if (grep { $_ =~ /Windows/ } $td->content_list) { | |
43 | $tr->detach; | |
44 | ++$detached; | |
45 | last; | |
46 | } | |
47 | } | |
48 | push @keep, $tr unless $detached; | |
49 | } | |
50 | @keep; | |
67e78ff2 | 51 | } |
aa016126 | 52 | ); |
67e78ff2 | 53 | |
aa016126 | 54 | isxml $tree, 't/html/table2-tr_ld-coderef.exp', 'table2 tr look_down (coderef)'; |