line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mock::Test; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
70430
|
use 5.006001; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
98
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$VERSION = 0.01; |
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
71
|
|
8
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
120
|
|
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
173
|
|
11
|
2
|
|
|
2
|
|
12
|
use Scalar::Util 1.11 'set_prototype'; |
|
2
|
|
|
|
|
53
|
|
|
2
|
|
|
|
|
207
|
|
12
|
2
|
|
|
2
|
|
2122
|
use Symbol qw/ qualify_to_ref qualify /; |
|
2
|
|
|
|
|
2259
|
|
|
2
|
|
|
|
|
565
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Test::More; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $no_test_builder = 0; |
17
|
|
|
|
|
|
|
our $builder = Test::More->builder; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my %mocks = ( |
20
|
|
|
|
|
|
|
"Test::More" => { |
21
|
|
|
|
|
|
|
proto_S_S => [qw( ok )], |
22
|
|
|
|
|
|
|
proto_SS_S => [qw( is isnt like unlike isa_ok )], |
23
|
|
|
|
|
|
|
proto_SSS_S => [qw( cmp_ok )], |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
noproto_2 => [qw( is_deeply )], |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
can_ok => [qw( can_ok )], |
28
|
|
|
|
|
|
|
fail => [qw( fail )], |
29
|
|
|
|
|
|
|
use_ok => [qw( use_ok )], |
30
|
|
|
|
|
|
|
require_ok => [qw( require_ok )], |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
"Test::Deep" => { |
33
|
|
|
|
|
|
|
noproto_2 => [qw( cmp_bag cmp_deeply )], |
34
|
|
|
|
|
|
|
}, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub import { |
38
|
2
|
|
|
2
|
|
19
|
foreach (@_) { |
39
|
2
|
50
|
|
|
|
43
|
$no_test_builder = 1 if /no_test_builder/; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
## no critic (ProhibitStringyEval) |
43
|
|
|
|
|
|
|
## needed for sub prototypes |
44
|
2
|
50
|
|
|
|
9
|
if ($no_test_builder) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
0
|
eval ' |
47
|
|
|
|
|
|
|
sub proto_S_S ($;$) { 1 }; |
48
|
|
|
|
|
|
|
sub proto_SS_S ($$;$) { 1 }; |
49
|
|
|
|
|
|
|
sub proto_SSS_S ($$$;$) { 1 }; |
50
|
|
|
|
|
|
|
sub fail (;$) { 1 }; |
51
|
|
|
|
|
|
|
sub can_ok ($@) { 1 }; |
52
|
|
|
|
|
|
|
sub use_ok ($;@) { 1 }; |
53
|
|
|
|
|
|
|
sub require_ok ($) { 1 }; |
54
|
|
|
|
|
|
|
sub noproto_2 ($$;$) { 1 }; |
55
|
|
|
|
|
|
|
'; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
else |
58
|
|
|
|
|
|
|
{ |
59
|
2
|
|
|
1
|
0
|
1647
|
eval ' |
|
1
|
|
|
1
|
0
|
5
|
|
|
1
|
|
|
4
|
0
|
5
|
|
|
4
|
|
|
0
|
0
|
18
|
|
|
0
|
|
|
16
|
0
|
0
|
|
|
16
|
|
|
4
|
0
|
56
|
|
|
4
|
|
|
1
|
0
|
22
|
|
|
1
|
|
|
1
|
0
|
7
|
|
|
1
|
|
|
|
|
7
|
|
60
|
|
|
|
|
|
|
sub proto_S_S ($;$) { $builder->ok( 1, $_[1] ) }; |
61
|
|
|
|
|
|
|
sub proto_SS_S ($$;$) { $builder->ok( 1, $_[2] ) }; |
62
|
|
|
|
|
|
|
sub proto_SSS_S ($$$;$) { $builder->ok( 1, $_[3] ) }; |
63
|
|
|
|
|
|
|
sub fail (;$) { $builder->ok( 1, @_ ) }; |
64
|
|
|
|
|
|
|
sub can_ok ($@) { $builder->ok( 1, "class->can(...)") }; |
65
|
|
|
|
|
|
|
sub use_ok ($;@) { $builder->ok( 1, "use ".$_[0].";" ) }; |
66
|
|
|
|
|
|
|
sub require_ok ($) { $builder->ok( 1, "require ".$_[0].";" ) }; |
67
|
|
|
|
|
|
|
sub noproto_2 ($$;$) { $builder->ok( 1, $_[2] ) }; |
68
|
|
|
|
|
|
|
'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
CHECK { |
74
|
2
|
|
|
2
|
|
14
|
no strict "refs"; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
460
|
|
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
2
|
|
3893
|
for my $module (keys %mocks) { |
77
|
4
|
|
|
|
|
8
|
for my $mocksub (keys %{$mocks{$module}}) { |
|
4
|
|
|
|
|
18
|
|
78
|
18
|
|
|
|
|
23
|
for my $sub (@{$mocks{$module}{$mocksub}}) { |
|
18
|
|
|
|
|
44
|
|
79
|
28
|
|
|
|
|
84
|
my $glob = qualify_to_ref($sub => $module); |
80
|
28
|
|
|
28
|
|
621
|
my $mocksub_proto = set_prototype(sub { &{$mocksub} }, prototype \&$glob); |
|
28
|
|
|
|
|
7164
|
|
|
28
|
|
|
|
|
1193
|
|
81
|
|
|
|
|
|
|
{ |
82
|
2
|
|
|
2
|
|
13
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
470
|
|
|
28
|
|
|
|
|
45
|
|
83
|
28
|
|
|
|
|
30
|
*{$module."::".$sub} = $mocksub_proto; |
|
28
|
|
|
|
|
161
|
|
84
|
28
|
50
|
|
|
|
39
|
*{"main" ."::".$sub} = $mocksub_proto if *{"main" ."::".$sub}; |
|
28
|
|
|
|
|
3452
|
|
|
28
|
|
|
|
|
93
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |