line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mockery; |
2
|
2
|
|
|
2
|
|
135931
|
use 5.006; use strict; use warnings; |
|
2
|
|
|
2
|
|
17
|
|
|
2
|
|
|
2
|
|
10
|
|
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
65
|
|
|
2
|
|
|
|
|
11
|
|
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
209
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
1
|
|
50
|
1
|
0
|
978
|
return bless $_[1] || {}, $_[0]; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub action { |
10
|
4
|
|
|
4
|
0
|
22
|
my ($self, %mockery) = @_; |
11
|
|
|
|
|
|
|
{ |
12
|
2
|
|
|
2
|
|
17
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
76
|
|
|
4
|
|
|
|
|
6
|
|
13
|
2
|
|
|
2
|
|
11
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
817
|
|
14
|
4
|
|
|
|
|
6
|
for (keys %{ $mockery{methods} }) { |
|
4
|
|
|
|
|
14
|
|
15
|
4
|
|
|
|
|
8
|
*{"$mockery{class}::$_"} = $mockery{methods}{$_}; |
|
4
|
|
|
|
|
32
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub fake { |
22
|
1
|
|
|
1
|
0
|
515
|
my ($self, %mockery) = @_; |
23
|
1
|
|
|
|
|
5
|
my $module = qq{ |
24
|
|
|
|
|
|
|
package $mockery{class}; |
25
|
|
|
|
|
|
|
use strict; |
26
|
|
|
|
|
|
|
use warnings; |
27
|
|
|
|
|
|
|
sub new { |
28
|
|
|
|
|
|
|
bless \$_[1] || {}, \$_[0]; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
1; |
31
|
|
|
|
|
|
|
}; |
32
|
1
|
|
50
|
1
|
|
82
|
eval $module; |
|
1
|
|
|
1
|
|
8
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
69
|
|
33
|
1
|
50
|
|
|
|
9
|
die $@ if $@; |
34
|
1
|
|
|
|
|
5
|
$self->action(%mockery); |
35
|
1
|
|
|
|
|
22
|
return $mockery{class}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub true { |
39
|
2
|
|
|
2
|
0
|
637
|
my ($self, %mockery) = @_; |
40
|
1
|
|
|
|
|
4
|
my @methods = @{$mockery{methods}}; |
|
1
|
|
|
|
|
3
|
|
41
|
1
|
|
|
|
|
4
|
$mockery{methods} = {}; |
42
|
1
|
|
|
1
|
|
6
|
my $sub = sub { return 1; }; |
|
1
|
|
|
|
|
7
|
|
43
|
1
|
|
|
|
|
3
|
for (@methods) { |
44
|
1
|
|
|
|
|
3
|
$mockery{methods}{$_} = $sub; |
45
|
|
|
|
|
|
|
} |
46
|
1
|
|
|
|
|
6
|
$_[0]->action(%mockery); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub false { |
50
|
1
|
|
|
1
|
0
|
5
|
my ($self, %mockery) = @_; |
51
|
1
|
|
|
|
|
3
|
my @methods = @{$mockery{methods}}; |
|
1
|
|
|
|
|
4
|
|
52
|
1
|
|
|
|
|
3
|
$mockery{methods} = {}; |
53
|
1
|
|
|
1
|
|
5
|
my $sub = sub { return 0; }; |
|
1
|
|
|
|
|
3
|
|
54
|
1
|
|
|
|
|
3
|
for (@methods) { |
55
|
1
|
|
|
|
|
2
|
$mockery{methods}{$_} = $sub; |
56
|
|
|
|
|
|
|
} |
57
|
1
|
|
|
|
|
4
|
$_[0]->action(%mockery); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |