line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Chai::Core::Assertions::Length; |
2
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
55
|
|
3
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
51
|
|
4
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
11
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
80
|
use Exporter qw/import/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
191
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/assert_length assert_length_chain/; |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
11
|
use Test::Chai::Util::Flag qw/flag/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
110
|
|
10
|
2
|
|
|
2
|
|
12
|
use Test::Chai::Util::GenericLength qw/generic_length/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
382
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub assert_length { |
13
|
5
|
|
|
5
|
0
|
7
|
my ($self, $n, $msg) = @_; |
14
|
|
|
|
|
|
|
|
15
|
5
|
50
|
|
|
|
12
|
flag($self, 'message', $msg) if defined $msg; |
16
|
5
|
|
|
|
|
12
|
my $obj = flag($self, 'object'); |
17
|
5
|
|
|
|
|
14
|
my $len = generic_length($obj); |
18
|
|
|
|
|
|
|
|
19
|
5
|
|
|
|
|
16
|
return $self->assert( |
20
|
|
|
|
|
|
|
$len == $n, |
21
|
|
|
|
|
|
|
'expected #{this} to have a length of #{exp} but got #{act}', |
22
|
|
|
|
|
|
|
'expected #{this} to not have a length of #{act}', |
23
|
|
|
|
|
|
|
$n, |
24
|
|
|
|
|
|
|
$len |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub assert_length_chain { |
29
|
25
|
|
|
25
|
0
|
71
|
flag(shift, 'do_length', 1); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |