line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Tools to test HTML/XML-based DOM representations |
2
|
|
|
|
|
|
|
package Test2::Tools::DOM; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
417450
|
use v5.20; |
|
2
|
|
|
|
|
19
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
6
|
2
|
|
|
2
|
|
920
|
use experimental qw( lexical_subs signatures ); |
|
2
|
|
|
|
|
5657
|
|
|
2
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
348
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
25
|
|
9
|
2
|
|
|
2
|
|
7
|
use Test2::API (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
30
|
|
10
|
2
|
|
|
2
|
|
10
|
use Test2::Compare (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
32
|
|
11
|
2
|
|
|
2
|
|
9
|
use Test2::Compare::Wildcard (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
38
|
|
12
|
2
|
|
|
2
|
|
784
|
use Test2::Tools::DOM::Check (); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
75
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
13
|
use Exporter 'import'; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
860
|
|
17
|
|
|
|
|
|
|
our @EXPORT = qw( |
18
|
|
|
|
|
|
|
all_text |
19
|
|
|
|
|
|
|
at |
20
|
|
|
|
|
|
|
attr |
21
|
|
|
|
|
|
|
content |
22
|
|
|
|
|
|
|
children |
23
|
|
|
|
|
|
|
dom |
24
|
|
|
|
|
|
|
find |
25
|
|
|
|
|
|
|
tag |
26
|
|
|
|
|
|
|
text |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub dom :prototype(&) { |
30
|
33
|
|
|
33
|
1
|
52003
|
Test2::Compare::build( 'Test2::Tools::DOM::Check', @_ ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
49
|
|
|
49
|
|
54
|
my sub call ( $name, $args, $expect ) { |
|
49
|
|
|
|
|
55
|
|
|
49
|
|
|
|
|
50
|
|
|
49
|
|
|
|
|
55
|
|
|
49
|
|
|
|
|
50
|
|
34
|
49
|
50
|
|
|
|
86
|
Carp::croak 'Missing method name' unless $name; |
35
|
|
|
|
|
|
|
|
36
|
49
|
50
|
|
|
|
83
|
my $build = Test2::Compare::get_build |
37
|
|
|
|
|
|
|
or Carp::croak 'No current build!'; |
38
|
|
|
|
|
|
|
|
39
|
49
|
50
|
|
|
|
197
|
Carp::croak "'$build' is not a Test2::Tools::DOM::Check" |
40
|
|
|
|
|
|
|
unless ref $build eq 'Test2::Tools::DOM::Check'; |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
97
|
my @caller = caller; |
43
|
49
|
|
|
|
|
138
|
$build->add_call( |
44
|
|
|
|
|
|
|
$name => $args, |
45
|
|
|
|
|
|
|
Test2::Compare::Wildcard->new( |
46
|
|
|
|
|
|
|
expect => $expect, |
47
|
|
|
|
|
|
|
file => $caller[1], |
48
|
|
|
|
|
|
|
lines => [ $caller[2] ], |
49
|
|
|
|
|
|
|
), |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# Calls with either only a check, or a key and a check |
54
|
20
|
|
|
20
|
|
27
|
my sub multi ( $method, $want, $check = undef ) { |
|
20
|
|
|
|
|
25
|
|
|
20
|
|
|
|
|
27
|
|
|
20
|
|
|
|
|
24
|
|
|
20
|
|
|
|
|
22
|
|
55
|
20
|
100
|
|
|
|
52
|
$check |
56
|
|
|
|
|
|
|
? call( $method => [ $want ] => $check ) |
57
|
|
|
|
|
|
|
: call( $method => [ ] => $want ) |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
1
|
23
|
sub all_text ( $check ) { call all_text => [ ] => $check } |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
61
|
10
|
|
|
10
|
1
|
301
|
sub at ( $want, $check ) { call at => [ $want ] => $check } |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
21
|
|
62
|
1
|
|
|
1
|
1
|
19
|
sub content ( $check ) { call content => [ ] => $check } |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3
|
|
63
|
3
|
|
|
3
|
1
|
251
|
sub find ( $want, $check ) { call find => [ $want ] => $check } |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
8
|
|
64
|
12
|
|
|
12
|
1
|
199
|
sub tag ( $check ) { call tag => [ ] => $check } |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
26
|
|
65
|
2
|
|
|
2
|
1
|
34
|
sub text ( $check ) { call text => [ ] => $check } |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
23
|
|
|
2
|
|
|
|
|
6
|
|
66
|
|
|
|
|
|
|
|
67
|
15
|
|
|
15
|
1
|
729
|
sub attr { multi attr => @_ } |
68
|
5
|
|
|
5
|
1
|
401
|
sub children { multi children => @_ } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |