line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Chai::Assertion; |
2
|
4
|
|
|
4
|
|
197003
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
114
|
|
3
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
110
|
|
4
|
4
|
|
|
4
|
|
33
|
use utf8; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
27
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
180
|
use parent qw/Test::Builder::Module/; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
31
|
|
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
1819
|
use Test::Chai::AssertionError; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
140
|
|
9
|
4
|
|
|
4
|
|
1580
|
use Test::Chai::Util::Flag qw/flag/; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
247
|
|
10
|
4
|
|
|
|
|
298
|
use Test::Chai::Util::Assertion qw/ |
11
|
|
|
|
|
|
|
test |
12
|
|
|
|
|
|
|
get_message |
13
|
|
|
|
|
|
|
get_actual |
14
|
4
|
|
|
4
|
|
1549
|
/; |
|
4
|
|
|
|
|
8
|
|
15
|
4
|
|
|
|
|
1953
|
use Test::Chai::Util::Reflection qw/ |
16
|
|
|
|
|
|
|
add_method |
17
|
|
|
|
|
|
|
add_property |
18
|
|
|
|
|
|
|
add_chainable_method |
19
|
4
|
|
|
4
|
|
1671
|
/; |
|
4
|
|
|
|
|
10
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# alias |
22
|
|
|
|
|
|
|
sub AssertionError () { 'Test::Chai::AssertionError' } |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
428
|
|
|
428
|
0
|
841
|
my ($class, $obj, $msg, $stack) = @_; |
26
|
|
|
|
|
|
|
|
27
|
428
|
|
|
|
|
626
|
my $self = {}; |
28
|
428
|
|
|
|
|
741
|
bless $self => $class; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# Util->flag($self, 'ssfi' FIXME |
31
|
428
|
|
|
|
|
1025
|
flag($self, 'object', $obj); |
32
|
428
|
|
|
|
|
972
|
flag($self, 'message', $msg); |
33
|
|
|
|
|
|
|
|
34
|
428
|
|
|
|
|
2043
|
return $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub assert { |
38
|
448
|
|
|
448
|
0
|
125122
|
my $self = shift; |
39
|
448
|
|
|
|
|
930
|
my ($expr, $msg, $negateMsg, $expected, $_actual, $show_diff) = @_; |
40
|
|
|
|
|
|
|
|
41
|
448
|
|
|
|
|
1782
|
my $ok = test($self, [@_]); |
42
|
448
|
50
|
66
|
|
|
1718
|
$show_diff = 0 if defined $show_diff && $show_diff != 1; |
43
|
|
|
|
|
|
|
|
44
|
448
|
100
|
|
|
|
910
|
if (!$ok) { |
45
|
107
|
|
|
|
|
420
|
my $msg = get_message($self, [@_]); |
46
|
107
|
|
|
|
|
507
|
my $actual = get_actual($self, [@_]); |
47
|
|
|
|
|
|
|
|
48
|
107
|
|
|
|
|
764
|
my $err = AssertionError->new($msg, { |
49
|
|
|
|
|
|
|
actual => $actual, |
50
|
|
|
|
|
|
|
expected => $expected, |
51
|
|
|
|
|
|
|
show_diff => $show_diff, |
52
|
|
|
|
|
|
|
}, undef); |
53
|
|
|
|
|
|
|
|
54
|
107
|
|
|
|
|
490
|
return $self->_fail($err->message); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
else { |
58
|
341
|
|
|
|
|
1196
|
my $msg = get_message($self, [@_]); |
59
|
341
|
|
|
|
|
1233
|
return $self->_pass($msg); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _fail { |
64
|
1
|
|
|
1
|
|
1338
|
my ($class, $msg) = @_; |
65
|
|
|
|
|
|
|
|
66
|
1
|
|
|
|
|
3
|
my $tb = $class->builder; |
67
|
1
|
|
|
|
|
18
|
return $tb->ok(0, $msg); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _pass { |
71
|
341
|
|
|
341
|
|
580
|
my ($class, $msg) = @_; |
72
|
|
|
|
|
|
|
|
73
|
341
|
|
|
|
|
1146
|
my $tb = $class->builder; |
74
|
341
|
|
|
|
|
3211
|
return $tb->ok(1, $msg); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub _obj { |
78
|
370
|
|
|
370
|
|
21055
|
my ($self, $val) = @_; |
79
|
|
|
|
|
|
|
|
80
|
370
|
100
|
|
|
|
714
|
if (@_ == 1) { |
81
|
369
|
|
|
|
|
796
|
return flag($self, 'object'); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
else { |
85
|
1
|
|
|
|
|
4
|
flag($self, 'object', $val); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
__END__ |