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
|
|
398107
|
use v5.20; |
|
2
|
|
|
|
|
16
|
|
5
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
6
|
2
|
|
|
2
|
|
812
|
use experimental qw( lexical_subs signatures ); |
|
2
|
|
|
|
|
5549
|
|
|
2
|
|
|
|
|
9
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
307
|
use Carp (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
24
|
|
9
|
2
|
|
|
2
|
|
7
|
use Test2::API (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
21
|
|
10
|
2
|
|
|
2
|
|
9
|
use Test2::Compare (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
20
|
|
11
|
2
|
|
|
2
|
|
8
|
use Test2::Compare::Wildcard (); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
42
|
|
12
|
2
|
|
|
2
|
|
700
|
use Test2::Tools::DOM::Check (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
15
|
|
|
|
|
|
|
|
16
|
2
|
|
|
2
|
|
12
|
use Exporter 'import'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
880
|
|
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
|
50003
|
Test2::Compare::build( 'Test2::Tools::DOM::Check', @_ ); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
49
|
|
|
49
|
|
52
|
my sub call ( $name, $args, $expect ) { |
|
49
|
|
|
|
|
56
|
|
|
49
|
|
|
|
|
52
|
|
|
49
|
|
|
|
|
51
|
|
|
49
|
|
|
|
|
50
|
|
34
|
49
|
50
|
|
|
|
88
|
Carp::croak 'Missing method name' unless $name; |
35
|
|
|
|
|
|
|
|
36
|
49
|
50
|
|
|
|
69
|
my $build = Test2::Compare::get_build |
37
|
|
|
|
|
|
|
or Carp::croak 'No current build!'; |
38
|
|
|
|
|
|
|
|
39
|
49
|
50
|
|
|
|
200
|
Carp::croak "'$build' is not a Test2::Tools::DOM::Check" |
40
|
|
|
|
|
|
|
unless ref $build eq 'Test2::Tools::DOM::Check'; |
41
|
|
|
|
|
|
|
|
42
|
49
|
|
|
|
|
101
|
my @caller = caller; |
43
|
49
|
|
|
|
|
124
|
$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
|
|
24
|
my sub multi ( $method, $want, $check = undef ) { |
|
20
|
|
|
|
|
24
|
|
|
20
|
|
|
|
|
22
|
|
|
20
|
|
|
|
|
26
|
|
|
20
|
|
|
|
|
19
|
|
55
|
20
|
100
|
|
|
|
46
|
$check |
56
|
|
|
|
|
|
|
? call( $method => [ $want ] => $check ) |
57
|
|
|
|
|
|
|
: call( $method => [ ] => $want ) |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
1
|
26
|
sub all_text ( $check ) { call all_text => [ ] => $check } |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
61
|
10
|
|
|
10
|
1
|
316
|
sub at ( $want, $check ) { call at => [ $want ] => $check } |
|
10
|
|
|
|
|
15
|
|
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
19
|
|
62
|
1
|
|
|
1
|
1
|
17
|
sub content ( $check ) { call content => [ ] => $check } |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
63
|
3
|
|
|
3
|
1
|
244
|
sub find ( $want, $check ) { call find => [ $want ] => $check } |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
8
|
|
64
|
12
|
|
|
12
|
1
|
183
|
sub tag ( $check ) { call tag => [ ] => $check } |
|
12
|
|
|
|
|
16
|
|
|
12
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
26
|
|
65
|
2
|
|
|
2
|
1
|
33
|
sub text ( $check ) { call text => [ ] => $check } |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
4
|
|
66
|
|
|
|
|
|
|
|
67
|
15
|
|
|
15
|
1
|
662
|
sub attr { multi attr => @_ } |
68
|
5
|
|
|
5
|
1
|
380
|
sub children { multi children => @_ } |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |