line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::EasyMock::ExpectationSetters; |
2
|
9
|
|
|
9
|
|
46
|
use strict; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
285
|
|
3
|
9
|
|
|
9
|
|
44
|
use warnings; |
|
9
|
|
|
|
|
14
|
|
|
9
|
|
|
|
|
5586
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Test::EasyMock::ExpectationSetters - Allows setting expectations for an associated expected invocation. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=cut |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 new($expectation) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Create a instance. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
sub new { |
19
|
52
|
|
|
52
|
1
|
87
|
my ($class, $expectation) = @_; |
20
|
52
|
|
|
|
|
391
|
return bless { |
21
|
|
|
|
|
|
|
_expectaion => $expectation, |
22
|
|
|
|
|
|
|
}, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 METHOD |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 and_scalar_return($value) |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Add scalar result to the expectation. |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
sub and_scalar_return { |
33
|
18
|
|
|
18
|
1
|
31
|
my ($self, $scalar) = @_; |
34
|
18
|
|
|
18
|
|
109
|
$self->{_expectaion}->push_result(sub { $scalar }); |
|
18
|
|
|
|
|
345
|
|
35
|
18
|
|
|
|
|
41
|
return $self; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 and_array_return(@values) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Add array result to the expectation. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
sub and_array_return { |
44
|
3
|
|
|
3
|
1
|
8
|
my ($self, @array) = @_; |
45
|
3
|
|
|
3
|
|
24
|
$self->{_expectaion}->push_result(sub { @array }); |
|
3
|
|
|
|
|
34
|
|
46
|
3
|
|
|
|
|
16
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 and_list_return(@values) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Add list result to the expectation. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
sub and_list_return { |
55
|
3
|
|
|
3
|
1
|
6
|
my ($self, @list) = @_; |
56
|
3
|
100
|
|
3
|
|
21
|
$self->{_expectaion}->push_result(sub { wantarray ? @list : $list[-1] }); |
|
3
|
|
|
|
|
32
|
|
57
|
3
|
|
|
|
|
7
|
return $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 and_answer($code) |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Add a code to the expectation, it calculate an answer. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
65
|
|
|
|
|
|
|
sub and_answer { |
66
|
2
|
|
|
2
|
1
|
5
|
my ($self, $code) = @_; |
67
|
2
|
|
|
|
|
10
|
$self->{_expectaion}->push_result($code); |
68
|
2
|
|
|
|
|
5
|
return $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 and_die([$message]) |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Add I behavior to the expectation. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
sub and_die { |
77
|
2
|
|
|
2
|
1
|
7
|
my ($self, @args) = @_; |
78
|
2
|
|
|
2
|
|
14
|
$self->{_expectaion}->push_result(sub { die @args }); |
|
2
|
|
|
|
|
37
|
|
79
|
2
|
|
|
|
|
4
|
return $self; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 and_stub_scalar_return($value) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Set scalar result as a stub to the expectation. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
sub and_stub_scalar_return { |
88
|
10
|
|
|
10
|
1
|
23
|
my ($self, $scalar) = @_; |
89
|
10
|
|
|
3
|
|
93
|
$self->{_expectaion}->set_stub_result(sub { $scalar }); |
|
3
|
|
|
|
|
19
|
|
90
|
10
|
|
|
|
|
21
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 and_stub_array_return(@values) |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Set array result as a stub to the expectation. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
sub and_stub_array_return { |
99
|
3
|
|
|
3
|
1
|
7
|
my ($self, @array) = @_; |
100
|
3
|
|
|
3
|
|
18
|
$self->{_expectaion}->set_stub_result(sub { @array }); |
|
3
|
|
|
|
|
20
|
|
101
|
3
|
|
|
|
|
8
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 and_stub_list_return(@values) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Set list result as a stub to the expectation. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
sub and_stub_list_return { |
110
|
3
|
|
|
3
|
1
|
9
|
my ($self, @list) = @_; |
111
|
3
|
100
|
|
3
|
|
20
|
$self->{_expectaion}->set_stub_result(sub { wantarray ? @list : $list[-1] }); |
|
3
|
|
|
|
|
27
|
|
112
|
3
|
|
|
|
|
7
|
return $self; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 and_stub_answer($code) |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Add a code as a stub to the expectation, it calculate an answer. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
sub and_stub_answer { |
121
|
2
|
|
|
2
|
1
|
4
|
my ($self, $code) = @_; |
122
|
2
|
|
|
|
|
7
|
$self->{_expectaion}->set_stub_result($code); |
123
|
2
|
|
|
|
|
5
|
return $self; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 and_stub_die([$message]) |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Set I behavior as as stub to the expectation. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
sub and_stub_die { |
132
|
3
|
|
|
3
|
1
|
8
|
my ($self, @args) = @_; |
133
|
3
|
|
|
3
|
|
17
|
$self->{_expectaion}->set_stub_result(sub { die @args }); |
|
3
|
|
|
|
|
42
|
|
134
|
3
|
|
|
|
|
8
|
return $self; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
1; |