blib/lib/Venus/Role/Testable.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 4 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 77.7% 7 / 9 Podpod 66.6% 2 / 3 totaltotal 70.5% 36 / 51 SCAR 20.3
CC
7
Cov
77%
is_false
4.8
is_true
4.8
__ANON__
1.3
CRAP 7.6
« blib/lib/Venus/Name.pm ↑ Summary blib/lib/Venus/Role/Catchable.pm »
1 package Venus::Role::Testable;
2  
3 96 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 96 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 96 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 96 ▶use Venus::Role 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 # METHODS
11  
12 sub is_false {
13 3 ▶ my ($self, $code, @args) = @_;
Subroutine is_false: called CC=4 SCAR=15.6
Pod documented
14  
15 3 ▶ $code ||= $self->can('value') ? 'value' : sub{};
Subroutine __ANON__: not called CC=1 SCAR=2.6
Branch: 1 branch
BranchTrueFalseTotal
$self->can('value') ? : 0 0 0
Condition33%1/3
$code ||= $self->can("value") ? "value" : sub { }
l!l&&r!l&&!r
300
MC/DC0%0/2
$code ||= $self->can("value") ? "value" : sub { }
$code $self->can("value") ? "value" : sub { }
Truth table33%1/3
A ||= B
A= $codeB= $self->can("value") ? "value" : sub { }
ABresult
1X1
011
000
16  
17 3 require Venus::Boolean;
18  
19 3 ▶ return $self->$code(@args) ? Venus::Boolean::FALSE() : Venus::Boolean::TRUE();
Branch: 1 branch
BranchTrueFalseTotal
$self->$code(@args) ? : 1 2 3
20 }
21  
22 sub is_true {
23 3 ▶ my ($self, $code, @args) = @_;
Subroutine is_true: called CC=4 SCAR=15.6
Pod documented
24  
25 3 ▶ $code ||= $self->can('value') ? 'value' : sub{};
Subroutine __ANON__: not called CC=1 SCAR=2.6
Branch: 1 branch
BranchTrueFalseTotal
$self->can('value') ? : 0 0 0
Condition33%1/3
$code ||= $self->can("value") ? "value" : sub { }
l!l&&r!l&&!r
300
MC/DC0%0/2
$code ||= $self->can("value") ? "value" : sub { }
$code $self->can("value") ? "value" : sub { }
Truth table33%1/3
A ||= B
A= $codeB= $self->can("value") ? "value" : sub { }
ABresult
1X1
011
000
26  
27 3 require Venus::Boolean;
28  
29 3 ▶ return $self->$code(@args) ? Venus::Boolean::TRUE() : Venus::Boolean::FALSE();
Branch: 1 branch
BranchTrueFalseTotal
$self->$code(@args) ? : 2 1 3
30 }
31  
32 # EXPORTS
33  
34 sub EXPORT {
35 97 ▶ ['is_false', 'is_true']
Subroutine EXPORT: called CC=1 SCAR=0.0
Pod undocumented
36 }
37  
38 96 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<false> and falsy returns as C<true>
96 L<"boolean"|Venus::Boolean> values.
97  
98 I<Since C<0.08>>
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<true> and falsy returns as C<false>
150 L<"boolean"|Venus::Boolean> values.
151  
152 I<Since C<0.08>>
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<awncorp@cpan.org>
201  
202 =cut
203  
204 =head1 LICENSE
205  
206 Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>.
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
« blib/lib/Venus/Name.pm ↑ Summary blib/lib/Venus/Role/Catchable.pm »