line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Deep::Matcher; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
21544641
|
use 5.008001; |
|
12
|
|
|
|
|
45
|
|
|
12
|
|
|
|
|
441
|
|
4
|
12
|
|
|
12
|
|
65
|
use strict; |
|
12
|
|
|
|
|
21
|
|
|
12
|
|
|
|
|
361
|
|
5
|
12
|
|
|
12
|
|
61
|
use warnings; |
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
328
|
|
6
|
12
|
|
|
12
|
|
9817
|
use parent 'Exporter'; |
|
12
|
|
|
|
|
3961
|
|
|
12
|
|
|
|
|
64
|
|
7
|
12
|
|
|
12
|
|
6804
|
use Test::Deep::Matcher::DataUtil; |
|
12
|
|
|
|
|
35
|
|
|
12
|
|
|
|
|
363
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
10
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @RefMatchers = qw( |
13
|
|
|
|
|
|
|
is_scalar_ref |
14
|
|
|
|
|
|
|
is_array_ref |
15
|
|
|
|
|
|
|
is_hash_ref |
16
|
|
|
|
|
|
|
is_code_ref |
17
|
|
|
|
|
|
|
is_glob_ref |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
for my $name (@RefMatchers) { |
21
|
12
|
|
|
12
|
|
1199
|
no strict 'refs'; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
1378
|
|
22
|
35
|
|
|
35
|
|
301147
|
*{$name} = sub { Test::Deep::Matcher::DataUtil->new($name, @_) }; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @PrimitiveMatchers = qw( |
26
|
|
|
|
|
|
|
is_value |
27
|
|
|
|
|
|
|
is_string |
28
|
|
|
|
|
|
|
is_number |
29
|
|
|
|
|
|
|
is_integer |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
for my $name (@PrimitiveMatchers) { |
33
|
12
|
|
|
12
|
|
55
|
no strict 'refs'; |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
1541
|
|
34
|
32
|
|
|
32
|
|
169867
|
*{$name} = sub { Test::Deep::Matcher::DataUtil->new($name, @_) }; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our @EXPORT = ( |
38
|
|
|
|
|
|
|
@RefMatchers, |
39
|
|
|
|
|
|
|
@PrimitiveMatchers, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Test::Deep::Matcher - Type check matchers for Test::Deep |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Test::More; |
51
|
|
|
|
|
|
|
use Test::Deep; |
52
|
|
|
|
|
|
|
use Test::Deep::Matcher; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
my $got = +{ |
55
|
|
|
|
|
|
|
foo => 'string', |
56
|
|
|
|
|
|
|
bar => 100, |
57
|
|
|
|
|
|
|
baz => [ 1, 2, 3 ], |
58
|
|
|
|
|
|
|
quux => { foo => 'bar' }, |
59
|
|
|
|
|
|
|
}; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
cmp_deeply($got, +{ |
62
|
|
|
|
|
|
|
foo => is_string, |
63
|
|
|
|
|
|
|
bar => is_integer, |
64
|
|
|
|
|
|
|
baz => is_array_ref, |
65
|
|
|
|
|
|
|
quux => is_hash_ref, |
66
|
|
|
|
|
|
|
}); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
done_testing; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Test::Deep::Matcher is a collection of Test::Deep type check matchers. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 Reference Matchers |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over 4 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item is_scalar_ref |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Checks the value type is SCALAR reference. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item is_array_ref |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Checks the value type is ARRAY reference. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item is_hash_ref |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Checks the value type is HASH reference. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item is_code_ref |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Checks the value type is CODE reference. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item is_glob_ref |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Checks the value type is GLOB reference. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=back |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 Primitive Matchers |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item is_value |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Checks the value is primitive, is B. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item is_string |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Checks the value is string, has length. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item is_number |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Checks the value is number. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item is_integer |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Checks the value is integer, is also number. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=back |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 AUTHOR |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
NAKAGAWA Masaki Emasaki@cpan.orgE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 LICENSE |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
131
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SEE ALSO |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L, |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |