line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Chai::Util::Assertion; |
2
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
93
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
35
|
|
|
4
|
|
|
|
|
89
|
|
4
|
4
|
|
|
4
|
|
17
|
use utf8; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
101
|
use Exporter qw/import/; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
207
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/ |
8
|
|
|
|
|
|
|
test |
9
|
|
|
|
|
|
|
get_message |
10
|
|
|
|
|
|
|
get_actual |
11
|
|
|
|
|
|
|
/; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
20
|
use Test::Chai::Util::Flag qw/flag/; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
212
|
|
14
|
4
|
|
|
4
|
|
21
|
use Test::Chai::Util::ObjDisplay qw/obj_display/; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
2354
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub test { |
17
|
448
|
|
|
448
|
0
|
674
|
my ($obj, $args) = @_; |
18
|
|
|
|
|
|
|
|
19
|
448
|
|
|
|
|
942
|
my $negate = flag($obj, 'negate'); |
20
|
448
|
|
|
|
|
774
|
my $expr = $args->[0]; |
21
|
|
|
|
|
|
|
|
22
|
448
|
100
|
66
|
|
|
2223
|
return defined $negate && $negate ? !$expr : $expr; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub get_message { |
26
|
448
|
|
|
448
|
0
|
762
|
my ($obj, $args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
448
|
|
|
|
|
917
|
my $negate = flag($obj, 'negate'); |
29
|
448
|
|
|
|
|
925
|
my $val = flag($obj, 'object'); |
30
|
448
|
|
|
|
|
767
|
my $expected = $args->[3]; |
31
|
448
|
|
|
|
|
896
|
my $actual = get_actual($obj, $args); |
32
|
448
|
100
|
66
|
|
|
1582
|
my $msg = defined $negate && $negate ? $args->[2] : $args->[1]; |
33
|
448
|
|
|
|
|
948
|
my $flag_msg = flag($obj, 'message'); |
34
|
|
|
|
|
|
|
|
35
|
448
|
50
|
|
|
|
1001
|
$msg = $msg->() if ref $msg eq 'CODE'; |
36
|
448
|
50
|
|
|
|
953
|
$msg = defined $msg ? $msg : ''; |
37
|
448
|
|
|
|
|
1665
|
$msg =~ s/#{this}/@{[obj_display($val)]}/g; |
|
436
|
|
|
|
|
1380
|
|
38
|
448
|
|
|
|
|
1269
|
$msg =~ s/#{act}/@{[obj_display($actual)]}/g; |
|
90
|
|
|
|
|
267
|
|
39
|
448
|
|
|
|
|
976
|
$msg =~ s/#{exp}/@{[obj_display($expected)]}/g; |
|
88
|
|
|
|
|
248
|
|
40
|
|
|
|
|
|
|
|
41
|
448
|
100
|
|
|
|
1837
|
return defined $flag_msg ? $flag_msg . ': ' . $msg : $msg; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_actual { |
45
|
555
|
|
|
555
|
0
|
726
|
my ($obj, $args) = @_; |
46
|
555
|
100
|
|
|
|
1997
|
return @$args > 4 ? $args->[4] : $obj->_obj; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |