line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Mocha::Verify; |
2
|
|
|
|
|
|
|
# ABSTRACT: Mock wrapper to verify method calls (DEPRECATED) |
3
|
|
|
|
|
|
|
$Test::Mocha::Verify::VERSION = '0.61'; |
4
|
3
|
|
|
3
|
|
13
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
110
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
84
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
12
|
use Test::Mocha::MethodCall; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
70
|
|
8
|
3
|
|
|
3
|
|
13
|
use Test::Mocha::Types qw( Mock NumRange ); |
|
3
|
|
|
|
|
53
|
|
|
3
|
|
|
|
|
42
|
|
9
|
3
|
|
|
3
|
|
1468
|
use Test::Mocha::Util qw( extract_method_name has_caller_package is_called ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
191
|
|
10
|
3
|
|
|
3
|
|
15
|
use Types::Standard qw( Num Str ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
27
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $AUTOLOAD; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
|
|
|
|
|
|
# uncoverable pod |
16
|
43
|
|
|
43
|
0
|
112
|
my ( $class, %args ) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
### assert: defined $args{mock} && Mock->check( $args{mock} ) |
19
|
|
|
|
|
|
|
### assert: !defined $args{ test_name } || Str->check( $args{ test_name } ) |
20
|
|
|
|
|
|
|
### assert: !defined $args{ times } || Num->check( $args{ times } ) |
21
|
|
|
|
|
|
|
### assert: !defined $args{ at_least } || Num->check( $args{ at_least } ) |
22
|
|
|
|
|
|
|
### assert: !defined $args{ at_most } || Num->check( $args{ at_most } ) |
23
|
|
|
|
|
|
|
### assert: !defined $args{ between } || NumRange->check( $args{between} ) |
24
|
|
|
|
|
|
|
### assert: 1 == grep { defined } @args{ times at_least at_most between } |
25
|
|
|
|
|
|
|
|
26
|
43
|
|
|
|
|
323
|
return bless \%args, $class; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub AUTOLOAD { |
30
|
42
|
|
|
42
|
|
14558
|
my ( $self, @args ) = @_; |
31
|
|
|
|
|
|
|
|
32
|
42
|
|
|
|
|
141
|
my $method_call = Test::Mocha::MethodCall->new( |
33
|
|
|
|
|
|
|
invocant => $self->{mock}, |
34
|
|
|
|
|
|
|
name => extract_method_name($AUTOLOAD), |
35
|
|
|
|
|
|
|
args => \@args, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
168
|
|
|
|
|
262
|
my ($class) = |
39
|
42
|
|
|
|
|
83
|
grep { defined $self->{$_} } qw{ times at_least at_most between }; |
40
|
42
|
|
|
|
|
121
|
my %options = ( |
41
|
|
|
|
|
|
|
times => 'Test::Mocha::CalledOk::Times', |
42
|
|
|
|
|
|
|
at_least => 'Test::Mocha::CalledOk::AtLeast', |
43
|
|
|
|
|
|
|
at_most => 'Test::Mocha::CalledOk::AtMost', |
44
|
|
|
|
|
|
|
between => 'Test::Mocha::CalledOk::Between', |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
42
|
|
|
|
|
232
|
$options{$class}->test( $method_call, $self->{$class}, $self->{test_name} ); |
48
|
39
|
|
|
|
|
189
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# Let AUTOLOAD() handle the UNIVERSAL methods |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub isa { |
54
|
|
|
|
|
|
|
# uncoverable pod |
55
|
1
|
|
|
1
|
0
|
2
|
$AUTOLOAD = 'isa'; |
56
|
1
|
|
|
|
|
2
|
goto &AUTOLOAD; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub DOES { |
60
|
|
|
|
|
|
|
# uncoverable pod |
61
|
1
|
|
|
1
|
0
|
1
|
$AUTOLOAD = 'DOES'; |
62
|
1
|
|
|
|
|
2
|
goto &AUTOLOAD; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub can { |
66
|
|
|
|
|
|
|
# Handle can('CARP_TRACE') for internal croak()'s (Carp v1.32+) |
67
|
|
|
|
|
|
|
# uncoverable pod |
68
|
4
|
100
|
|
4
|
0
|
19
|
return if has_caller_package(__PACKAGE__); |
69
|
|
|
|
|
|
|
|
70
|
1
|
|
|
|
|
1
|
$AUTOLOAD = 'can'; |
71
|
1
|
|
|
|
|
3
|
goto &AUTOLOAD; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Don't let AUTOLOAD() handle DESTROY() so that object can be destroyed |
75
|
1
|
|
|
1
|
|
4
|
sub DESTROY { } |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |