line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Venus::Role::Testable; |
2
|
|
|
|
|
|
|
|
3
|
96
|
|
|
96
|
|
1750
|
use 5.018; |
|
96
|
|
|
|
|
357
|
|
4
|
|
|
|
|
|
|
|
5
|
96
|
|
|
96
|
|
516
|
use strict; |
|
96
|
|
|
|
|
215
|
|
|
96
|
|
|
|
|
2075
|
|
6
|
96
|
|
|
96
|
|
519
|
use warnings; |
|
96
|
|
|
|
|
261
|
|
|
96
|
|
|
|
|
3091
|
|
7
|
|
|
|
|
|
|
|
8
|
96
|
|
|
96
|
|
574
|
use Venus::Role 'with'; |
|
96
|
|
|
|
|
283
|
|
|
96
|
|
|
|
|
667
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# METHODS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub is_false { |
13
|
3
|
|
|
3
|
1
|
9
|
my ($self, $code, @args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
3
|
0
|
33
|
0
|
|
8
|
$code ||= $self->can('value') ? 'value' : sub{}; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
582
|
require Venus::Boolean; |
18
|
|
|
|
|
|
|
|
19
|
3
|
100
|
|
|
|
69
|
return $self->$code(@args) ? Venus::Boolean::FALSE() : Venus::Boolean::TRUE(); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub is_true { |
23
|
3
|
|
|
3
|
1
|
11
|
my ($self, $code, @args) = @_; |
24
|
|
|
|
|
|
|
|
25
|
3
|
0
|
33
|
0
|
|
9
|
$code ||= $self->can('value') ? 'value' : sub{}; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
13
|
require Venus::Boolean; |
28
|
|
|
|
|
|
|
|
29
|
3
|
100
|
|
|
|
56
|
return $self->$code(@args) ? Venus::Boolean::TRUE() : Venus::Boolean::FALSE(); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# EXPORTS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub EXPORT { |
35
|
97
|
|
|
97
|
0
|
380
|
['is_false', 'is_true'] |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Venus::Role::Testable - Testable Role |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ABSTRACT |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Testable Role for Perl 5 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 SYNOPSIS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
package Example; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use Venus::Class; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
with 'Venus::Role::Testable'; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
attr 'value'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub execute { |
65
|
|
|
|
|
|
|
return pop; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
package main; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $example = Example->new; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# $example->is_true(sub{0}); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
This package modifies the consuming package and provides methods for |
79
|
|
|
|
|
|
|
dispatching method calls and returning truthy returns as true and falsy returns |
80
|
|
|
|
|
|
|
as false boolean values. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 METHODS |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This package provides the following methods: |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 is_false |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
is_false(string | coderef $method, any @args) (boolean) |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
The is_false method dispatches the method call or executes the callback and |
95
|
|
|
|
|
|
|
returns truthy returns as C and falsy returns as C |
96
|
|
|
|
|
|
|
L<"boolean"|Venus::Boolean> values. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
I> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=over 4 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item is_false example 1 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
package main; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
my $example = Example->new; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $true = $example->is_false(execute => 0); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# 1 |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=over 4 |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item is_false example 2 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
package main; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $example = Example->new; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
my $true = $example->is_false(sub{0}); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# 1 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item is_false example 3 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
package main; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
my $example = Example->new; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
my $false = $example->is_false(execute => 1); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# 0 |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=back |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 is_true |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
is_true(string | coderef $method, any @args) (boolean) |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
The is_true method dispatches the method call or executes the callback and |
149
|
|
|
|
|
|
|
returns truthy returns as C and falsy returns as C |
150
|
|
|
|
|
|
|
L<"boolean"|Venus::Boolean> values. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
I> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over 4 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item is_true example 1 |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
package main; |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
my $example = Example->new; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $true = $example->is_true(execute => 1); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
# 1 |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=back |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=over 4 |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item is_true example 2 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
package main; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
my $example = Example->new; |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my $true = $example->is_true(sub{1}); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# 1 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=back |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=over 4 |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item is_true example 3 |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
package main; |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
my $example = Example->new; |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
my $false = $example->is_true(execute => 0); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# 0 |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=head1 AUTHORS |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
Awncorp, C |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=cut |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 LICENSE |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Copyright (C) 2000, Awncorp, C. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
209
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |