Venus/Test.pm

filter: Statementstmt 95.8% 953 / 994 Branchbran 51.5% 101 / 196 Conditioncond 24.4% 22 / 90 MC/DCmcdc 1.8% 1 / 54 Subroutinesub 100% 265 / 265 Podpod 6.8% 7 / 102 totaltotal 79.3% 1349 / 1701 CC 178 SCAR 6.3
CC
178
Cov
84%
test_for_version
12.0
pdml_for_function
8.5
pdml_for_method
8.5
CRAP 1.9
« Venus/Regexp.pm ↑ Summary Venus/Role/Catchable.pm »
1 package Venus::Test;
2  
3 77 ▶use 5.018;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 77 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 76 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 75 ▶use Venus::Class 'base', 'with';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 61 base 'Venus::Data';
11  
12 61 with 'Venus::Role::Buildable';
13  
14 75 ▶use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 75 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 61 our @EXPORT = 'test';
19  
20 # EXPORTS
21  
22 sub test {
23 85 ▶ __PACKAGE__->new($_[0]);
Subroutine test: called CC=1 SCAR=0.0
Pod documented
24 }
25  
26 # BUILDERS
27  
28 sub build_self {
29 85 ▶ my ($self, $data) = @_;
Subroutine build_self: called CC=3 SCAR=11.0
Pod undocumented
30  
31 85 $self->SUPER::build_self($data);
32 85 for my $item (qw(name abstract tagline synopsis description)) {
33 385 ▶ @{$self->find(undef, $item)} || $self->throw->error({
Branch: 1 branch
BranchTrueFalseTotal
@{$self->find(undef, $item);} or $self->throw->error({"message", "Test missing pod section =$item"}) 0 378 378
34 message => "Test missing pod section =$item",
35 });
36 }
37  
38 85 return $self;
39 };
40  
41 # METHODS
42  
43 sub data {
44 2983 ▶ my ($self, $name, @args) = @_;
Subroutine data: called CC=3 SCAR=11.0
Pod documented
45  
46 2983 my $method = "data_for_$name";
47  
48 2983 ▶ $self->throw->error if !$self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 1 2975 2976
49  
50 2982 ▶ wantarray ? ($self->$method(@args)) : $self->$method(@args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 543 2432 2975
51 }
52  
53 sub data_for_abstract {
54 72 ▶ my ($self) = @_;
Subroutine data_for_abstract: called CC=2 SCAR=7.0
Pod undocumented
55  
56 72 my $data = $self->find(undef, 'abstract');
57  
58 72 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 64 64
59  
60 72 return join "\n\n", @{$data->[0]{data}};
61 }
62  
63 sub data_for_attributes {
64 26 ▶ my ($self) = @_;
Subroutine data_for_attributes: called CC=2 SCAR=6.9
Pod undocumented
65  
66 26 my $data = $self->find(undef, 'attributes');
67  
68 26 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 2 15 17
69  
70 24 return join "\n\n", @{$data->[0]{data}};
71 }
72  
73 sub data_for_authors {
74 11 ▶ my ($self) = @_;
Subroutine data_for_authors: called CC=2 SCAR=6.9
Pod undocumented
75  
76 11 my $data = $self->find(undef, 'authors');
77  
78 11 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 1 1 2
79  
80 10 return join "\n\n", @{$data->[0]{data}};
81 }
82  
83 sub data_for_description {
84 71 ▶ my ($self) = @_;
Subroutine data_for_description: called CC=2 SCAR=7.0
Pod undocumented
85  
86 71 my $data = $self->find(undef, 'description');
87  
88 71 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 62 62
89  
90 71 return join "\n\n", @{$data->[0]{data}};
91 }
92  
93 sub data_for_example {
94 1847 ▶ my ($self, $number, $name) = @_;
Subroutine data_for_example: called CC=4 SCAR=13.9
Pod undocumented
95  
96 1847 my $data = $self->search({
97 list => "example-$number",
98 name => quotemeta($name),
99 });
100  
101 1847 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 1838 1838
102  
103 1847 my $example = join "\n\n", @{$data->[0]{data}};
104  
105 1847 my @includes;
106  
107 1847 ▶ if ($example =~ /# given: synopsis/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($example =~ /# given: synopsis/u) 500 1338 1838
108 510 push @includes, $self->data('synopsis');
109 }
110  
111 1847 ▶ if (my ($number, $name) = $example =~ /# given: example-(\d+) (\w+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $example =~ /# given: example-(\d+) (\w+)/u) 0 1838 1838
112 10 push @includes, $self->data('example', $number, $name);
113 }
114  
115 1847 $example =~ s/.*# given: .*//g;
116  
117 1847 return join "\n\n", @includes, $example;
118 }
119  
120 sub data_for_feature {
121 19 ▶ my ($self, $name) = @_;
Subroutine data_for_feature: called CC=2 SCAR=7.0
Pod undocumented
122  
123 19 my $data = $self->search({
124 list => 'feature',
125 name => $name,
126 });
127  
128 19 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 10 10
129  
130 19 return join "\n\n", @{$data->[0]{data}};
131 }
132  
133 sub data_for_function {
134 11 ▶ my ($self, $name) = @_;
Subroutine data_for_function: called CC=2 SCAR=7.0
Pod undocumented
135  
136 11 my $data = $self->search({
137 list => 'function',
138 name => $name,
139 });
140  
141 11 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 2 2
142  
143 11 return join "\n\n", @{$data->[0]{data}};
144 }
145  
146 sub data_for_includes {
147 72 ▶ my ($self) = @_;
Subroutine data_for_includes: called CC=2 SCAR=7.0
Pod undocumented
148  
149 72 my $data = $self->find(undef, 'includes');
150  
151 72 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 63 63
152  
153 72 return join "\n\n", @{$data->[0]{data}};
154 }
155  
156 sub data_for_inherits {
157 48 ▶ my ($self) = @_;
Subroutine data_for_inherits: called CC=2 SCAR=7.0
Pod undocumented
158  
159 48 my $data = $self->find(undef, 'inherits');
160  
161 48 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 39 39
162  
163 48 return join "\n\n", @{$data->[0]{data}};
164 }
165  
166 sub data_for_integrates {
167 37 ▶ my ($self) = @_;
Subroutine data_for_integrates: called CC=2 SCAR=7.0
Pod undocumented
168  
169 37 my $data = $self->find(undef, 'integrates');
170  
171 37 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 28 28
172  
173 37 return join "\n\n", @{$data->[0]{data}};
174 }
175  
176 sub data_for_libraries {
177 12 ▶ my ($self) = @_;
Subroutine data_for_libraries: called CC=2 SCAR=6.9
Pod undocumented
178  
179 12 my $data = $self->find(undef, 'libraries');
180  
181 12 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 2 1 3
182  
183 10 return join "\n\n", @{$data->[0]{data}};
184 }
185  
186 sub data_for_license {
187 11 ▶ my ($self) = @_;
Subroutine data_for_license: called CC=2 SCAR=6.9
Pod undocumented
188  
189 11 my $data = $self->find(undef, 'license');
190  
191 11 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 1 1 2
192  
193 10 return join "\n\n", @{$data->[0]{data}};
194 }
195  
196 sub data_for_metadata {
197 16 ▶ my ($self, $name) = @_;
Subroutine data_for_metadata: called CC=2 SCAR=7.0
Pod undocumented
198  
199 16 my $data = $self->search({
200 list => 'metadata',
201 name => $name,
202 });
203  
204 16 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 7 7
205  
206 16 return join "\n\n", @{$data->[0]{data}};
207 }
208  
209 sub data_for_method {
210 15 ▶ my ($self, $name) = @_;
Subroutine data_for_method: called CC=2 SCAR=7.0
Pod undocumented
211  
212 15 my $data = $self->search({
213 list => 'method',
214 name => $name,
215 });
216  
217 15 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 6 6
218  
219 15 return join "\n\n", @{$data->[0]{data}};
220 }
221  
222 sub data_for_name {
223 152 ▶ my ($self) = @_;
Subroutine data_for_name: called CC=2 SCAR=7.0
Pod undocumented
224  
225 152 my $data = $self->find(undef, 'name');
226  
227 152 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 143 143
228  
229 152 return join "\n\n", @{$data->[0]{data}};
230 }
231  
232 sub data_for_operator {
233 78 ▶ my ($self, $name) = @_;
Subroutine data_for_operator: called CC=2 SCAR=7.0
Pod undocumented
234  
235 78 my $data = $self->search({
236 list => 'operator',
237 name => quotemeta($name),
238 });
239  
240 78 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 69 69
241  
242 78 return join "\n\n", @{$data->[0]{data}};
243 }
244  
245 sub data_for_project {
246 11 ▶ my ($self) = @_;
Subroutine data_for_project: called CC=2 SCAR=6.9
Pod undocumented
247  
248 11 my $data = $self->find(undef, 'project');
249  
250 11 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 1 1 2
251  
252 10 return join "\n\n", @{$data->[0]{data}};
253 }
254  
255 sub data_for_signature {
256 16 ▶ my ($self, $name) = @_;
Subroutine data_for_signature: called CC=2 SCAR=7.0
Pod undocumented
257  
258 16 my $data = $self->search({
259 list => 'signature',
260 name => $name,
261 });
262  
263 16 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 6 6
264  
265 16 return join "\n\n", @{$data->[0]{data}};
266 }
267  
268 sub data_for_synopsis {
269 573 ▶ my ($self) = @_;
Subroutine data_for_synopsis: called CC=2 SCAR=7.0
Pod undocumented
270  
271 573 my $data = $self->find(undef, 'synopsis');
272  
273 573 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 563 563
274  
275 573 return join "\n\n", @{$data->[0]{data}};
276 }
277  
278 sub data_for_tagline {
279 73 ▶ my ($self) = @_;
Subroutine data_for_tagline: called CC=2 SCAR=7.0
Pod undocumented
280  
281 73 my $data = $self->find(undef, 'tagline');
282  
283 73 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 0 63 63
284  
285 73 return join "\n\n", @{$data->[0]{data}};
286 }
287  
288 sub data_for_version {
289 11 ▶ my ($self) = @_;
Subroutine data_for_version: called CC=2 SCAR=7.0
Pod undocumented
290  
291 11 my $data = $self->find(undef, 'version');
292  
293 11 ▶ $self->throw->error if !@$data;
Branch: 1 branch
BranchTrueFalseTotal
unless @$data 1 0 1
294  
295 10 return join "\n\n", @{$data->[0]{data}};
296 }
297  
298 sub default {
299 10 ▶ my ($self) = @_;
Subroutine default: called CC=1 SCAR=0.0
Pod documented
300  
301 10 return '';
302 }
303  
304 sub eval {
305 1891 ▶ my ($self, $perl) = @_;
Subroutine eval: called CC=3 SCAR=11.0
Pod undocumented
306  
307 1891 local $@;
308  
309 75 ▶ my @result = CORE::eval(join("\n\n", "no warnings q(redefine);", $perl));
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine execute: called CC=1 SCAR=0.0
Subroutine execute: called CC=1 SCAR=0.0
Subroutine new: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Branch: 6 branches
BranchTrueFalseTotal
unless $from->can("startup") 2 6 8
if not $from->can("shutdown") 0 5 5
if $_[1]->isa("Example") 1 3 4
unless $from->can("login") 2 4 6
if not $from->can("password") 0 2 2
$self->login && $self->password ? : 1 3 4
Condition27%3/11
$self->login and $self->password
!ll&&!rl&&r
401
@args == 1 and not ref $args[0]
!ll&&!rl&&r
000
$data->{"x"} ||= int($data->{"x"} || 100)
l!l&&r!l&&!r
100
$data->{'x'} || 100
l!l
00
MC/DC50%1/2
$self->login and $self->password
$self->login $self->password
MC/DC0%0/2
@args == 1 and not ref $args[0]
@args == 1 not ref $args[0]
MC/DC0%0/2
$data->{"x"} ||= int($data->{"x"} || 100)
$data->{"x"} $data->{'x'}
Truth table66%2/3
A and B
A= $self->loginB= $self->password
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= @args == 1B= not ref $args[0]
ABresult
0X0
100
111
Truth table33%1/3
A ||= B
A= $data->{"x"}B= $data->{'x'}
ABresult
1X1
011
000
310  
311 1891 ▶ die $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 39 1842 1881
312  
313 1852 ▶ return wantarray ? (@result) : $result[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1842 0 1842
314 }
315  
316 sub for {
317 2363 ▶ my ($self, $name, @args) = @_;
Subroutine for: called CC=2 SCAR=7.0
Pod documented
318  
319 2364 my $result;
320  
321 2364 my $method = "test_for_$name";
322  
323 2362 ▶ $self->throw->error if !$self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 0 2352 2352
324  
325 subtest(join(' ', $method, grep !ref, @args), sub {
326 2362 ▶ $result = $self->$method(@args);
Subroutine __ANON__: called CC=1 SCAR=0.0
327 2363 });
328  
329 2360 return $result;
330 }
331  
332 sub head1 {
333 20 ▶ my ($self, $name, @data) = @_;
Subroutine head1: called CC=1 SCAR=0.0
Pod undocumented
334  
335 20 return join("\n", "", "=head1 \U$name", "", grep(defined, @data), "", "=cut");
336 }
337  
338 sub head2 {
339 16 ▶ my ($self, $name, @data) = @_;
Subroutine head2: called CC=1 SCAR=0.0
Pod undocumented
340  
341 16 return join("\n", "", "=head2 \L$name", "", grep(defined, @data), "", "=cut");
342 }
343  
344 sub item {
345 25 ▶ my ($self, $name, $data) = @_;
Subroutine item: called CC=1 SCAR=0.0
Pod undocumented
346  
347 25 return ("=item $name\n", "$data\n");
348 }
349  
350 sub link {
351 12 ▶ my ($self, @data) = @_;
Subroutine link: called CC=1 SCAR=0.0
Pod undocumented
352  
353 12 return ("L<@{[join('|', @data)]}>");
354 }
355  
356 sub over {
357 25 ▶ my ($self, @data) = @_;
Subroutine over: called CC=1 SCAR=0.0
Pod undocumented
358  
359 25 return join("\n", "", "=over 4", "", grep(defined, @data), "=back");
360 }
361  
362 sub pdml {
363 49 ▶ my ($self, $name, @args) = @_;
Subroutine pdml: called CC=3 SCAR=11.0
Pod documented
364  
365 49 my $method = "pdml_for_$name";
366  
367 49 ▶ $self->throw->error if !$self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 0 39 39
368  
369 49 ▶ wantarray ? ($self->$method(@args)) : $self->$method(@args);
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 36 3 39
370 }
371  
372 sub pdml_for_abstract {
373 11 ▶ my ($self) = @_;
Subroutine pdml_for_abstract: called CC=2 SCAR=7.0
Pod undocumented
374  
375 11 my $output;
376  
377 11 my $text = $self->text('abstract');
378  
379 11 ▶ return $text ? ($self->head1('abstract', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 1 0 1
380 }
381  
382 sub pdml_for_attribute {
383 10 ▶ my ($self, $name, $is, $pre, $isa, $def) = @_;
Subroutine pdml_for_attribute: called CC=4 SCAR=17.2
Pod undocumented
384  
385 9 my @output;
386  
387 9 ▶ $is = $is eq 'ro' ? 'read-only' : 'read-write';
Branch: 1 branch
BranchTrueFalseTotal
$is eq 'ro' ? : 0 0 0
388 9 ▶ $pre = $pre eq 'req' ? 'required' : 'optional';
Branch: 1 branch
BranchTrueFalseTotal
$pre eq 'req' ? : 0 0 0
389  
390 9 push @output, " $name($isa)\n";
391 9 ▶ push @output, "This attribute is $is, accepts C<($isa)> values, ". (
Branch: 1 branch
BranchTrueFalseTotal
$def ? : 0 0 0
392 $def ? "is $pre, and defaults to $def." : "and is $pre."
393 );
394  
395 9 return ($self->head2($name, @output));
396 }
397  
398 sub pdml_for_attributes {
399 10 ▶ my ($self) = @_;
Subroutine pdml_for_attributes: called CC=5 SCAR=17.3
Pod undocumented
400  
401 10 my @output;
402  
403 10 my $text = $self->text('attributes');
404  
405 10 ▶ return () if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 1 0 1
406  
407 9 for my $line (split /\n/, $text) {
408 push @output, $self->pdml('attribute', (
409 9 map { split /,\s*/ } split /:\s*/, $line, 2
410 ));
411 }
412  
413 7 ▶ return () if !@output;
Branch: 1 branch
BranchTrueFalseTotal
unless @output 0 0 0
414  
415 7 ▶ if (@output) {
Branch: 1 branch
BranchTrueFalseTotal
if (@output) 0 0 0
416 7 unshift @output, $self->head1('attributes',
417 "This package has the following attributes:",
418 );
419 }
420  
421 7 return join "\n", @output;
422 }
423  
424 sub pdml_for_authors {
425 8 ▶ my ($self) = @_;
Subroutine pdml_for_authors: called CC=2 SCAR=7.0
Pod undocumented
426  
427 8 my $output;
428  
429 8 my $text = $self->text('authors');
430  
431 8 ▶ return $text ? ($self->head1('authors', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 0 1 1
432 }
433  
434 sub pdml_for_description {
435 8 ▶ my ($self) = @_;
Subroutine pdml_for_description: called CC=2 SCAR=7.0
Pod undocumented
436  
437 8 my $output;
438  
439 8 my $text = $self->text('description');
440  
441 8 ▶ return $text ? ($self->head1('description', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 1 0 1
442 }
443  
444 sub pdml_for_example {
445 22 ▶ my ($self, $number, $name) = @_;
Subroutine pdml_for_example: called CC=2 SCAR=7.0
Pod undocumented
446  
447 22 my @output;
448  
449 22 my $text = $self->text('example', $number, $name);
450  
451 22 ▶ return $text ? ($self->over($self->item("$name example $number", $text))) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 15 0 15
452 }
453  
454 sub pdml_for_feature {
455 7 ▶ my ($self, $name) = @_;
Subroutine pdml_for_feature: called CC=5 SCAR=18.1
Pod undocumented
456  
457 7 my @output;
458  
459 7 my $signature = $self->text('signature', $name);
460  
461 7 ▶ push @output, ($signature, '') if $signature;
Branch: 1 branch
BranchTrueFalseTotal
if $signature 0 0 0
462  
463 7 my $text = $self->text('feature', $name);
464  
465 7 ▶ return () if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 0 0
466  
467 7 my @results = $self->search({name => $name});
468  
469 7 ▶ for my $i (1..(int grep {($$_{list} || '') =~ /^example-\d+/} @results)) {
Condition0%0/2
$_->{'list'} || ''
l!l
00
MC/DC0%0/1
$_->{'list'} || ''
$_->{'list'}
Truth table0%0/2
A
A= $_->{'list'}
Aresult
11
00
470 7 push @output, "B<example $i>", $self->text('example', $i, $name);
471 }
472  
473 7 return ($self->over($self->item($name, join "\n\n", $text, @output)));
474 }
475  
476 sub pdml_for_features {
477 8 ▶ my ($self) = @_;
Subroutine pdml_for_features: called CC=3 SCAR=11.0
Pod undocumented
478  
479 8 my @output;
480  
481 8 for my $list ($self->search({list => 'feature'})) {
482 7 push @output, $self->pdml('feature', $list->{name});
483 }
484  
485 8 ▶ if (@output) {
Branch: 1 branch
BranchTrueFalseTotal
if (@output) 0 1 1
486 7 unshift @output, $self->head1('features',
487 "This package provides the following features:",
488 );
489 }
490  
491 8 return join "\n", @output;
492 }
493  
494 sub pdml_for_function {
495 8 ▶ my ($self, $name) = @_;
Subroutine pdml_for_function: called CC=8 SCAR=21.4
Pod undocumented
496  
497 8 my @output;
498  
499 8 my $metadata = $self->text('metadata', $name);
500 8 my $signature = $self->text('signature', $name);
501  
502 8 ▶ push @output, ($signature, '') if $signature;
Branch: 1 branch
BranchTrueFalseTotal
if $signature 1 0 1
503  
504 8 my $text = $self->text('function', $name);
505  
506 8 ▶ return () if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 1 1
507  
508 7 push @output, $text;
509  
510 7 ▶ if ($metadata) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metadata) 1 0 1
511 7 local $@;
512 7 ▶ if ($metadata = eval $metadata) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metadata = eval $metadata) 1 0 1
513 7 ▶ if (my $since = $metadata->{since}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $since = $metadata->{"since"}) 1 0 1
514 7 push @output, "", "I<Since C<$since>>";
515 }
516 }
517 }
518  
519 6 my @results = $self->search({name => $name});
520  
521 6 ▶ for my $i (1..(int grep {($$_{list} || '') =~ /^example-\d+/} @results)) {
Condition50%1/2
$_->{'list'} || ''
l!l
40
MC/DC0%0/1
$_->{'list'} || ''
$_->{'list'}
Truth table50%1/2
A
A= $_->{'list'}
Aresult
11
00
522 6 push @output, $self->pdml('example', $i, $name),
523 }
524  
525 6 return ($self->head2($name, @output));
526 }
527  
528 sub pdml_for_functions {
529 6 ▶ my ($self) = @_;
Subroutine pdml_for_functions: called CC=3 SCAR=11.0
Pod undocumented
530  
531 6 my @output;
532  
533 6 my $type = 'function';
534 6 my $text = $self->text('includes');
535  
536 6 for my $name (sort map /:\s*(\w+)$/, grep /^$type/, split /\n/, $text) {
537 6 push @output, $self->pdml($type, $name);
538 }
539  
540 6 ▶ if (@output) {
Branch: 1 branch
BranchTrueFalseTotal
if (@output) 1 0 1
541 6 unshift @output, $self->head1('functions',
542 "This package provides the following functions:",
543 );
544 }
545  
546 6 return join "\n", @output;
547 }
548  
549 sub pdml_for_include {
550 5 ▶ my ($self) = @_;
Subroutine pdml_for_include: called CC=1 SCAR=0.0
Pod undocumented
551  
552 5 my $output;
553  
554 5 my $text = $self->text('include');
555  
556 5 return $output;
557 }
558  
559 sub pdml_for_includes {
560 5 ▶ my ($self) = @_;
Subroutine pdml_for_includes: called CC=1 SCAR=0.0
Pod undocumented
561  
562 5 my $output;
563  
564 5 my $text = $self->text('includes');
565  
566 5 return $output;
567 }
568  
569 sub pdml_for_inherits {
570 6 ▶ my ($self) = @_;
Subroutine pdml_for_inherits: called CC=2 SCAR=7.0
Pod undocumented
571  
572 6 my $text = $self->text('inherits');
573  
574 6 my @output = map +($self->link($_), ""), grep defined,
575 split /\n/, $self->text('inherits');
576  
577 6 ▶ return '' if !@output;
Branch: 1 branch
BranchTrueFalseTotal
unless @output 0 1 1
578  
579 6 pop @output;
580  
581 6 return $self->head1('inherits',
582 "This package inherits behaviors from:",
583 "",
584 @output,
585 );
586 }
587  
588 sub pdml_for_integrates {
589 6 ▶ my ($self) = @_;
Subroutine pdml_for_integrates: called CC=2 SCAR=7.0
Pod undocumented
590  
591 6 my $text = $self->text('integrates');
592  
593 6 my @output = map +($self->link($_), ""), grep defined,
594 split /\n/, $self->text('integrates');
595  
596 6 ▶ return '' if !@output;
Branch: 1 branch
BranchTrueFalseTotal
unless @output 0 1 1
597  
598 6 pop @output;
599  
600 6 return $self->head1('integrates',
601 "This package integrates behaviors from:",
602 "",
603 @output,
604 );
605 }
606  
607 sub pdml_for_libraries {
608 6 ▶ my ($self) = @_;
Subroutine pdml_for_libraries: called CC=2 SCAR=7.0
Pod undocumented
609  
610 6 my $text = $self->text('libraries');
611  
612 6 my @output = map +($self->link($_), ""), grep defined,
613 split /\n/, $self->text('libraries');
614  
615 6 ▶ return '' if !@output;
Branch: 1 branch
BranchTrueFalseTotal
unless @output 1 0 1
616  
617 5 pop @output;
618  
619 5 return $self->head1('libraries',
620 "This package uses type constraints from:",
621 "",
622 @output,
623 );
624 }
625  
626 sub pdml_for_license {
627 6 ▶ my ($self) = @_;
Subroutine pdml_for_license: called CC=2 SCAR=7.0
Pod undocumented
628  
629 6 my $output;
630  
631 6 my $text = $self->text('license');
632  
633 6 ▶ return $text ? ($self->head1('license', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 0 1 1
634 }
635  
636 sub pdml_for_method {
637 10 ▶ my ($self, $name) = @_;
Subroutine pdml_for_method: called CC=8 SCAR=21.4
Pod undocumented
638  
639 10 my @output;
640  
641 10 my $metadata = $self->text('metadata', $name);
642 10 my $signature = $self->text('signature', $name);
643  
644 10 ▶ push @output, ($signature, '') if $signature;
Branch: 1 branch
BranchTrueFalseTotal
if $signature 5 0 5
645  
646 10 my $text = $self->text('method', $name);
647  
648 10 ▶ return () if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 5 5
649  
650 10 push @output, $text;
651  
652 10 ▶ if ($metadata) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metadata) 5 0 5
653 10 local $@;
654 10 ▶ if ($metadata = eval $metadata) {
Branch: 1 branch
BranchTrueFalseTotal
if ($metadata = eval $metadata) 5 0 5
655 10 ▶ if (my $since = $metadata->{since}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $since = $metadata->{"since"}) 5 0 5
656 10 push @output, "", "I<Since C<$since>>";
657 }
658 }
659 }
660  
661 10 my @results = $self->search({name => $name});
662  
663 10 ▶ for my $i (1..(int grep {($$_{list} || '') =~ /^example-\d+/} @results)) {
Condition50%1/2
$_->{'list'} || ''
l!l
280
MC/DC0%0/1
$_->{'list'} || ''
$_->{'list'}
Truth table50%1/2
A
A= $_->{'list'}
Aresult
11
00
664 18 push @output, $self->pdml('example', $i, $name),
665 }
666  
667 10 return ($self->head2($name, @output));
668 }
669  
670 sub pdml_for_methods {
671 6 ▶ my ($self) = @_;
Subroutine pdml_for_methods: called CC=3 SCAR=11.0
Pod undocumented
672  
673 6 my @output;
674  
675 6 my $type = 'method';
676 6 my $text = $self->text('includes');
677  
678 6 for my $name (sort map /:\s*(\w+)$/, grep /^$type/, split /\n/, $text) {
679 10 push @output, $self->pdml($type, $name);
680 }
681  
682 6 ▶ if (@output) {
Branch: 1 branch
BranchTrueFalseTotal
if (@output) 1 0 1
683 6 unshift @output, $self->head1('methods',
684 "This package provides the following methods:",
685 );
686 }
687  
688 6 return join "\n", @output;
689 }
690  
691 sub pdml_for_name {
692 7 ▶ my ($self) = @_;
Subroutine pdml_for_name: called CC=2 SCAR=7.0
Pod undocumented
693  
694 7 my $output;
695  
696 7 my $name = join ' - ', map $self->text($_), 'name', 'tagline';
697  
698 7 ▶ return $name ? ($self->head1('name', $name)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 2 0 2
699 }
700  
701 sub pdml_for_operator {
702 5 ▶ my ($self, $name) = @_;
Subroutine pdml_for_operator: called CC=4 SCAR=15.0
Pod undocumented
703  
704 5 my @output;
705  
706 5 my $text = $self->text('operator', $name);
707  
708 5 ▶ return () if !$text;
Branch: 1 branch
BranchTrueFalseTotal
unless $text 0 0 0
709  
710 5 my @results = $self->search({name => quotemeta($name)});
711  
712 5 ▶ for my $i (1..(int grep {($$_{list} || '') =~ /^example-\d+/} @results)) {
Condition0%0/2
$_->{'list'} || ''
l!l
00
MC/DC0%0/1
$_->{'list'} || ''
$_->{'list'}
Truth table0%0/2
A
A= $_->{'list'}
Aresult
11
00
713 5 push @output, "B<example $i>", $self->text('example', $i, $name);
714 }
715  
716 5 return ($self->over($self->item("operation: C<$name>", join "\n\n", $text, @output)));
717 }
718  
719 sub pdml_for_operators {
720 6 ▶ my ($self) = @_;
Subroutine pdml_for_operators: called CC=3 SCAR=11.0
Pod undocumented
721  
722 6 my @output;
723  
724 6 for my $list ($self->search({list => 'operator'})) {
725 5 push @output, $self->pdml('operator', $list->{name});
726 }
727  
728 6 ▶ if (@output) {
Branch: 1 branch
BranchTrueFalseTotal
if (@output) 0 1 1
729 5 unshift @output, $self->head1('operators',
730 "This package overloads the following operators:",
731 );
732 }
733  
734 6 return join "\n", @output;
735 }
736  
737 sub pdml_for_project {
738 6 ▶ my ($self) = @_;
Subroutine pdml_for_project: called CC=2 SCAR=7.0
Pod undocumented
739  
740 6 my $output;
741  
742 6 my $text = $self->text('project');
743  
744 6 ▶ return $text ? ($self->head1('project', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 0 1 1
745 }
746  
747 sub pdml_for_synopsis {
748 7 ▶ my ($self) = @_;
Subroutine pdml_for_synopsis: called CC=2 SCAR=7.0
Pod undocumented
749  
750 7 my $output;
751  
752 7 my $text = $self->text('synopsis');
753  
754 7 ▶ return $text ? ($self->head1('synopsis', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 2 0 2
755 }
756  
757 sub pdml_for_tagline {
758 5 ▶ my ($self) = @_;
Subroutine pdml_for_tagline: called CC=2 SCAR=7.6
Pod undocumented
759  
760 5 my $output;
761  
762 5 my $text = $self->text('tagline');
763  
764 4 ▶ return $text ? ($self->head1('tagline', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 0 0 0
765 }
766  
767 sub pdml_for_version {
768 5 ▶ my ($self) = @_;
Subroutine pdml_for_version: called CC=2 SCAR=7.0
Pod undocumented
769  
770 5 my $output;
771  
772 5 my $text = $self->text('version');
773  
774 5 ▶ return $text ? ($self->head1('version', $text)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$text ? : 0 1 1
775 }
776  
777 sub render {
778 5 ▶ my ($self, $file) = @_;
Subroutine render: called CC=1 SCAR=0.0
Pod documented
779  
780 5 require Venus::Path;
781  
782 5 my $path = Venus::Path->new($file);
783  
784 5 $path->parent->mkdirs;
785  
786 5 $path->write(join "\n", grep !!$_, map $self->pdml($_), qw(
787 name
788 abstract
789 version
790 synopsis
791 description
792 attributes
793 inherits
794 integrates
795 libraries
796 functions
797 methods
798 features
799 operators
800 authors
801 license
802 project
803 ));
804  
805 5 return $path;
806 }
807  
808 sub test_for_abstract {
809 65 ▶ my ($self, $code) = @_;
Subroutine test_for_abstract: called CC=2 SCAR=7.1
Pod undocumented
810  
811 65 my $data = $self->data('abstract');
812  
813 $code ||= sub {
814 65 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
815 65 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0610
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
816  
817 65 my $result = $code->();
818  
819 65 ok($result, '=abstract');
820  
821 65 return $result;
822 }
823  
824 sub test_for_attributes {
825 17 ▶ my ($self, $code) = @_;
Subroutine test_for_attributes: called CC=2 SCAR=7.6
Pod undocumented
826  
827 17 my $data = $self->data('attributes');
828 17 my $package = $self->data('name');
829  
830 $code ||= sub {
831 17 ▶ for my $line (split /\n/, $data) {
Subroutine __ANON__: called CC=6 SCAR=21.4
832 44 my ($name, $is, $pre, $isa, $def) = map { split /,\s*/ } split /:\s*/,
833 $line, 2;
834 44 ok($package->can($name), "$package has $name");
835 44 ▶ ok((($is eq 'ro' || $is eq 'rw')
Condition41%5/12
($is eq 'ro' || $is eq 'rw') && ($pre eq 'opt' || $pre eq 'req') && $isa
!ll&&!rl&&r
0041
$is eq "ro" || $is eq "rw" and $pre eq "opt" || $pre eq "req"
!ll&&!rl&&r
0041
$is eq "ro" or $is eq "rw"
l!l&&r!l&&!r
5360
$pre eq "opt" or $pre eq "req"
l!l&&r!l&&!r
4100
MC/DC0%0/5
($is eq 'ro' || $is eq 'rw') && ($pre eq 'opt' || $pre eq 'req') && $isa
$is eq "ro" $is eq "rw" $pre eq "opt" $pre eq "req" $isa
Truth table18%2/11
A or B and C or D && E
A= $is eq "ro"B= $is eq "rw"C= $pre eq "opt"D= $pre eq "req"E= $isa
ABCDEresult
00XXX0
1X00X0
0100X0
1X1X00
1X0100
011X00
010100
1X1X11
1X0111
011X11
010111
836 && ($pre eq 'opt' || $pre eq 'req')
837 && $isa), $line);
838 }
839 $data
840 17 ▶ };
Condition33%1/3
$code ||= sub { foreach my $line (split(/\n/u, $data, 0)) { my($name, $is, $pre, $isa, $def) = map({split(/,\s*/u, $_, 0);} split(/:\s*/u, $line, 2)); &ok(scalar $package->can($name), "$package has $name"); &ok(scalar(($is eq "ro" || $is eq "rw") && ($pre eq "opt" || $pre eq "req") && $isa), $line); } ; $data; }
l!l&&r!l&&!r
0140
MC/DC0%0/2
$code ||= sub { foreach my $line (split(/\n/u, $data, 0)) { my($name, $is, $pre, $isa, $def) = map({split(/,\s*/u, $_, 0);} split(/:\s*/u, $line, 2)); &ok(scalar $package->can($name), "$package has $name"); &ok(scalar(($is eq "ro" || $is eq "rw") && ($pre eq "opt" || $pre eq "req") && $isa), $line); } ; $data; }
$code sub { foreach my $line (split(/\n/u, $data, 0)) { my($name, $is, $pre, $isa, $def) = map({split(/,\s*/u, $_, 0);} split(/:\s*/u, $line, 2)); &ok(scalar $package->can($name), "$package has $name"); &ok(scalar(($is eq "ro" || $is eq "rw") && ($pre eq "opt" || $pre eq "req") && $isa), $line); } ; $data; }
Truth table33%1/3
A ||= B
A= $codeB= sub { foreach my $line (split(/\n/u, $data, 0)) { my($name, $is, $pre, $isa, $def) = map({split(/,\s*/u, $_, 0);} split(/:\s*/u, $line, 2)); &ok(scalar $package->can($name), "$package has $name"); &ok(scalar(($is eq "ro" || $is eq "rw") && ($pre eq "opt" || $pre eq "req") && $isa), $line); } ; $data; }
ABresult
1X1
011
000
841  
842 17 my $result = $code->();
843  
844 17 ok($result, "=attributes");
845  
846 17 return $result;
847 }
848  
849 sub test_for_authors {
850 3 ▶ my ($self, $code) = @_;
Subroutine test_for_authors: called CC=2 SCAR=7.5
Pod undocumented
851  
852 3 my $data = $self->data('author');
853  
854 $code ||= sub {
855 3 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
856 3 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
857  
858 3 my $result = $code->();
859  
860 3 ok($result, '=author');
861  
862 3 return $result;
863 }
864  
865 sub test_for_description {
866 63 ▶ my ($self, $code) = @_;
Subroutine test_for_description: called CC=2 SCAR=7.1
Pod undocumented
867  
868 63 my $data = $self->data('description');
869  
870 $code ||= sub {
871 63 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
872 63 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0600
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
873  
874 63 my $result = $code->();
875  
876 63 ok($result, '=description');
877  
878 63 return $result;
879 }
880  
881 sub test_for_example {
882 1840 ▶ my ($self, $number, $name, $code) = @_;
Subroutine test_for_example: called CC=2 SCAR=7.1
Pod undocumented
883  
884 1840 my $data = $self->data('example', $number, $name);
885  
886 1840 ▶ $code ||= sub{1};
Subroutine __ANON__: called CC=1 SCAR=0.6
Condition33%1/3
$code ||= sub { 1; }
l!l&&r!l&&!r
183700
MC/DC0%0/2
$code ||= sub { 1; }
$code sub { 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { 1; }
ABresult
1X1
011
000
887  
888 1840 my $result = $code->($self->try('eval', $data));
889  
890 1839 ok($data, "=example-$number $name");
891 1839 ok($result, "=example-$number $name returns ok");
892  
893 1839 return $result;
894 }
895  
896 sub test_for_feature {
897 12 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_feature: called CC=2 SCAR=7.1
Pod undocumented
898  
899 12 my $data = $self->data('feature', $name);
900  
901 $code ||= sub {
902 12 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
903 12 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
090
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
904  
905 12 my $result = $code->();
906  
907 12 ok($result, "=feature $name");
908  
909 12 return $result;
910 }
911  
912 sub test_for_function {
913 3 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_function: called CC=2 SCAR=7.5
Pod undocumented
914  
915 3 my $data = $self->data('function', $name);
916  
917 $code ||= sub {
918 3 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
919 3 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
920  
921 3 my $result = $code->();
922  
923 3 ok($result, "=function $name");
924  
925 3 return $result;
926 }
927  
928 sub test_for_include {
929 612 ▶ my ($self, $text) = @_;
Subroutine test_for_include: called CC=1 SCAR=0.0
Pod undocumented
930  
931 612 my ($type, $name) = @$text;
932  
933 612 my $blocks = [$self->search({ list => $type, name => $name })];
934  
935 612 ok(@$blocks, "=$type $name");
936  
937 612 return $blocks;
938 }
939  
940 sub test_for_includes {
941 62 ▶ my ($self, $code) = @_;
Subroutine test_for_includes: called CC=3 SCAR=11.2
Pod undocumented
942  
943 62 my $data = $self->data('includes');
944  
945 62 ▶ $code ||= $self->can('test_for_include');
Condition33%1/3
$code ||= $self->can("test_for_include")
l!l&&r!l&&!r
0590
MC/DC0%0/2
$code ||= $self->can("test_for_include")
$code $self->can("test_for_include")
Truth table33%1/3
A ||= B
A= $codeB= $self->can("test_for_include")
ABresult
1X1
011
000
946  
947 62 ok($data, '=includes');
948  
949 62 my $results = [];
950  
951 62 push @$results, $self->$code($_) for map [split /\:\s*/], split /\n/, $data;
952  
953 61 return $results;
954 }
955  
956 sub test_for_inherits {
957 38 ▶ my ($self, $code) = @_;
Subroutine test_for_inherits: called CC=3 SCAR=11.1
Pod undocumented
958  
959 38 my $data = $self->data('inherits');
960  
961 $code ||= sub {
962 38 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
963 38 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0360
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
964  
965 38 my $result = $code->();
966  
967 38 ok($result, "=inherits");
968  
969 38 my $package = $self->data('name');
970  
971 38 ok($package->isa($_), "$package isa $_") for split /\n/, $data;
972  
973 38 return $result;
974 }
975  
976 sub test_for_integrates {
977 27 ▶ my ($self, $code) = @_;
Subroutine test_for_integrates: called CC=3 SCAR=11.1
Pod undocumented
978  
979 27 my $data = $self->data('integrates');
980  
981 $code ||= sub {
982 27 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
983 27 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0250
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
984  
985 27 my $result = $code->();
986  
987 27 ok($result, "=integrates");
988  
989 27 my $package = $self->data('name');
990  
991 27 ok($package->can('does'), "$package has does");
992 27 ok($package->does($_), "$package does $_") for split /\n/, $data;
993  
994 27 return $result;
995 }
996  
997 sub test_for_libraries {
998 2 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_libraries: called CC=3 SCAR=11.6
Pod undocumented
999  
1000 2 my $data = $self->data('libraries');
1001  
1002 $code ||= sub {
1003 2 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1004 2 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1005  
1006 2 my $result = $code->();
1007  
1008 2 ok($result, "=libraries");
1009 2 ok(eval("require $_"), "$_ ok") for split /\n/, $data;
1010  
1011 2 return $result;
1012 }
1013  
1014 sub test_for_license {
1015 2 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_license: called CC=2 SCAR=7.5
Pod undocumented
1016  
1017 2 my $data = $self->data('license');
1018  
1019 $code ||= sub {
1020 2 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1021 2 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1022  
1023 2 my $result = $code->();
1024  
1025 2 ok($result, "=license");
1026  
1027 2 return $result;
1028 }
1029  
1030 sub test_for_method {
1031 2 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_method: called CC=2 SCAR=7.2
Pod undocumented
1032  
1033 2 my $data = $self->data('method', $name);
1034  
1035 $code ||= sub {
1036 2 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1037 2 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1038  
1039 2 my $result = $code->();
1040  
1041 2 ok($result, "=method $name");
1042  
1043 2 my $package = $self->data('name');
1044  
1045 2 ok($package->can($name), "$package has $name");
1046  
1047 2 return $result;
1048 }
1049  
1050 sub test_for_name {
1051 63 ▶ my ($self, $code) = @_;
Subroutine test_for_name: called CC=2 SCAR=7.1
Pod undocumented
1052  
1053 63 my $data = $self->data('name');
1054  
1055 $code ||= sub {
1056 63 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1057 63 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0610
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1058  
1059 63 my $result = $code->();
1060  
1061 63 ok($result, '=name');
1062 63 ok(eval("require $data"), $data);
1063  
1064 63 return $result;
1065 }
1066  
1067 sub test_for_operator {
1068 70 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_operator: called CC=2 SCAR=7.1
Pod undocumented
1069  
1070 70 my $data = $self->data('operator', $name);
1071  
1072 $code ||= sub {
1073 70 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1074 70 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0680
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1075  
1076 70 my $result = $code->();
1077  
1078 70 ok($result, "=operator $name");
1079  
1080 70 return $result;
1081 }
1082  
1083 sub test_for_project {
1084 2 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_project: called CC=2 SCAR=15.9
Pod undocumented
1085  
1086 0 my $data = $self->data('project');
1087  
1088 $code ||= sub {
1089 0 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=6.9
1090 0 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1091  
1092 0 my $result = $code->();
1093  
1094 0 ok($result, "=project");
1095  
1096 0 return $result;
1097 }
1098  
1099 sub test_for_synopsis {
1100 61 ▶ my ($self, $code) = @_;
Subroutine test_for_synopsis: called CC=2 SCAR=7.3
Pod undocumented
1101  
1102 61 my $data = $self->data('synopsis');
1103  
1104 61 ▶ $code ||= sub{$_[0]->result};
Subroutine __ANON__: called CC=1 SCAR=2.0
Condition33%1/3
$code ||= sub { $_[0]->result; }
l!l&&r!l&&!r
6100
MC/DC0%0/2
$code ||= sub { $_[0]->result; }
$code sub { $_[0]->result; }
Truth table33%1/3
A ||= B
A= $codeB= sub { $_[0]->result; }
ABresult
1X1
011
000
1105  
1106 61 my $result = $code->($self->try('eval', $data));
1107  
1108 60 ok($data, '=synopsis');
1109 60 ok($result, '=synopsis returns ok');
1110  
1111 60 return $result;
1112 }
1113  
1114 sub test_for_tagline {
1115 61 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_tagline: called CC=2 SCAR=7.1
Pod undocumented
1116  
1117 61 my $data = $self->data('tagline');
1118  
1119 $code ||= sub {
1120 61 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=0.0
1121 61 ▶ };
Condition33%1/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
0610
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table33%1/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1122  
1123 61 my $result = $code->();
1124  
1125 61 ok($result, "=tagline");
1126  
1127 61 return $result;
1128 }
1129  
1130 sub test_for_version {
1131 0 ▶ my ($self, $name, $code) = @_;
Subroutine test_for_version: called CC=3 SCAR=24.8
Pod undocumented
1132  
1133 0 my $data = $self->data('version');
1134  
1135 $code ||= sub {
1136 0 ▶ length($data) > 1;
Subroutine __ANON__: called CC=1 SCAR=6.9
1137 0 ▶ };
Condition0%0/3
$code ||= sub { length $data > 1; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$code ||= sub { length $data > 1; }
$code sub { length $data > 1; }
Truth table0%0/3
A ||= B
A= $codeB= sub { length $data > 1; }
ABresult
1X1
011
000
1138  
1139 0 my $result = $code->();
1140  
1141 0 ok($result, "=version");
1142  
1143 0 my $package = $self->data('name');
1144  
1145 0 ▶ ok(($package->VERSION // '') eq $data, "$data matched");
Condition0%0/2
$package->VERSION // ""
l!l
00
MC/DC0%0/1
$package->VERSION // ""
$package->VERSION
Truth table0%0/2
A
A= $package->VERSION
Aresult
11
00
1146  
1147 0 return $result;
1148 }
1149  
1150 sub text {
1151 58 ▶ my ($self, $name, @args) = @_;
Subroutine text: called CC=2 SCAR=6.9
Pod documented
1152  
1153 58 my $method = "text_for_$name";
1154  
1155 58 ▶ $self->throw->error if !$self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 1 57 58
1156  
1157 57 my $result = $self->$method(@args);
1158  
1159 57 return join "\n", @$result;
1160 }
1161  
1162 sub text_for_abstract {
1163 1 ▶ my ($self) = @_;
Subroutine text_for_abstract: called CC=2 SCAR=7.0
Pod undocumented
1164  
1165 1 my ($error, $result) = $self->catch('data', 'abstract');
1166  
1167 1 my $output = [];
1168  
1169 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 1 0 1
1170 1 push @$output, $result;
1171 }
1172  
1173 1 return $output;
1174 }
1175  
1176 sub text_for_attributes {
1177 2 ▶ my ($self) = @_;
Subroutine text_for_attributes: called CC=2 SCAR=7.2
Pod undocumented
1178  
1179 2 my ($error, $result) = $self->catch('data', 'attributes');
1180  
1181 2 my $output = [];
1182  
1183 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 2 2
1184 0 push @$output, $result;
1185 }
1186  
1187 2 return $output;
1188 }
1189  
1190 sub text_for_authors {
1191 1 ▶ my ($self) = @_;
Subroutine text_for_authors: called CC=2 SCAR=7.2
Pod undocumented
1192  
1193 1 my ($error, $result) = $self->catch('data', 'authors');
1194  
1195 1 my $output = [];
1196  
1197 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 1 1
1198 0 push @$output, $result;
1199 }
1200  
1201 1 return $output;
1202 }
1203  
1204 sub text_for_description {
1205 1 ▶ my ($self) = @_;
Subroutine text_for_description: called CC=2 SCAR=7.0
Pod undocumented
1206  
1207 1 my ($error, $result) = $self->catch('data', 'description');
1208  
1209 1 my $output = [];
1210  
1211 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 1 0 1
1212 1 push @$output, $result;
1213 }
1214  
1215 1 return $output;
1216 }
1217  
1218 sub text_for_example {
1219 15 ▶ my ($self, $number, $name) = @_;
Subroutine text_for_example: called CC=2 SCAR=7.0
Pod undocumented
1220  
1221 15 my $output = [];
1222  
1223 15 my $data = $self->search({
1224 list => "example-$number",
1225 name => quotemeta($name),
1226 });
1227  
1228 15 ▶ push @$output, join "\n\n", @{$data->[0]{data}} if @$data;
Branch: 1 branch
BranchTrueFalseTotal
if @$data 15 0 15
1229  
1230 15 return $output;
1231 }
1232  
1233 sub text_for_feature {
1234 0 ▶ my ($self, $name) = @_;
Subroutine text_for_feature: called CC=2 SCAR=17.9
Pod undocumented
1235  
1236 0 my ($error, $result) = $self->catch('data', 'feature', $name);
1237  
1238 0 my $output = [];
1239  
1240 0 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
1241 0 push @$output, $result;
1242 }
1243  
1244 0 return $output;
1245 }
1246  
1247 sub text_for_function {
1248 1 ▶ my ($self, $name) = @_;
Subroutine text_for_function: called CC=2 SCAR=7.0
Pod undocumented
1249  
1250 1 my ($error, $result) = $self->catch('data', 'function', $name);
1251  
1252 1 my $output = [];
1253  
1254 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 1 0 1
1255 1 push @$output, $result;
1256 }
1257  
1258 1 return $output;
1259 }
1260  
1261 sub text_for_include {
1262 0 ▶ my ($self) = @_;
Subroutine text_for_include: called CC=2 SCAR=17.9
Pod undocumented
1263  
1264 0 my ($error, $result) = $self->catch('data', 'include');
1265  
1266 0 my $output = [];
1267  
1268 0 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
1269 0 push @$output, $result;
1270 }
1271  
1272 0 return $output;
1273 }
1274  
1275 sub text_for_includes {
1276 3 ▶ my ($self) = @_;
Subroutine text_for_includes: called CC=2 SCAR=7.0
Pod undocumented
1277  
1278 3 my ($error, $result) = $self->catch('data', 'includes');
1279  
1280 3 my $output = [];
1281  
1282 3 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 3 0 3
1283 3 push @$output, $result;
1284 }
1285  
1286 3 return $output;
1287 }
1288  
1289 sub text_for_inherits {
1290 2 ▶ my ($self) = @_;
Subroutine text_for_inherits: called CC=2 SCAR=7.0
Pod undocumented
1291  
1292 2 my ($error, $result) = $self->catch('data', 'inherits');
1293  
1294 2 my $output = [];
1295  
1296 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 2 0 2
1297 2 push @$output, $result;
1298 }
1299  
1300 2 return $output;
1301 }
1302  
1303 sub text_for_integrates {
1304 2 ▶ my ($self) = @_;
Subroutine text_for_integrates: called CC=2 SCAR=7.0
Pod undocumented
1305  
1306 2 my ($error, $result) = $self->catch('data', 'integrates');
1307  
1308 2 my $output = [];
1309  
1310 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 2 0 2
1311 2 push @$output, $result;
1312 }
1313  
1314 2 return $output;
1315 }
1316  
1317 sub text_for_libraries {
1318 2 ▶ my ($self) = @_;
Subroutine text_for_libraries: called CC=2 SCAR=7.2
Pod undocumented
1319  
1320 2 my ($error, $result) = $self->catch('data', 'libraries');
1321  
1322 2 my $output = [];
1323  
1324 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 2 2
1325 0 push @$output, $result;
1326 }
1327  
1328 2 return $output;
1329 }
1330  
1331 sub text_for_license {
1332 1 ▶ my ($self) = @_;
Subroutine text_for_license: called CC=2 SCAR=7.2
Pod undocumented
1333  
1334 1 my ($error, $result) = $self->catch('data', 'license');
1335  
1336 1 my $output = [];
1337  
1338 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 1 1
1339 0 push @$output, $result;
1340 }
1341  
1342 1 return $output;
1343 }
1344  
1345 sub text_for_metadata {
1346 6 ▶ my ($self, $name) = @_;
Subroutine text_for_metadata: called CC=2 SCAR=7.0
Pod undocumented
1347  
1348 6 my ($error, $result) = $self->catch('data', 'metadata', $name);
1349  
1350 6 my $output = [];
1351  
1352 6 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 6 0 6
1353 6 push @$output, $result;
1354 }
1355  
1356 6 return $output;
1357 }
1358  
1359 sub text_for_method {
1360 5 ▶ my ($self, $name) = @_;
Subroutine text_for_method: called CC=2 SCAR=7.0
Pod undocumented
1361  
1362 5 my ($error, $result) = $self->catch('data', 'method', $name);
1363  
1364 5 my $output = [];
1365  
1366 5 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 5 0 5
1367 5 push @$output, $result;
1368 }
1369  
1370 5 return $output;
1371 }
1372  
1373 sub text_for_name {
1374 4 ▶ my ($self) = @_;
Subroutine text_for_name: called CC=2 SCAR=7.0
Pod undocumented
1375  
1376 4 my ($error, $result) = $self->catch('data', 'name');
1377  
1378 4 my $output = [];
1379  
1380 4 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 4 0 4
1381 4 push @$output, $result;
1382 }
1383  
1384 4 return $output;
1385 }
1386  
1387 sub text_for_operator {
1388 0 ▶ my ($self, $name) = @_;
Subroutine text_for_operator: called CC=2 SCAR=17.9
Pod undocumented
1389  
1390 0 my ($error, $result) = $self->catch('data', 'operator', $name);
1391  
1392 0 my $output = [];
1393  
1394 0 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 0 0
1395 0 push @$output, $result;
1396 }
1397  
1398 0 return $output;
1399 }
1400  
1401 sub text_for_project {
1402 1 ▶ my ($self) = @_;
Subroutine text_for_project: called CC=2 SCAR=7.2
Pod undocumented
1403  
1404 1 my ($error, $result) = $self->catch('data', 'project');
1405  
1406 1 my $output = [];
1407  
1408 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 1 1
1409 0 push @$output, $result;
1410 }
1411  
1412 1 return $output;
1413 }
1414  
1415 sub text_for_signature {
1416 6 ▶ my ($self, $name) = @_;
Subroutine text_for_signature: called CC=2 SCAR=7.0
Pod undocumented
1417  
1418 6 my ($error, $result) = $self->catch('data', 'signature', $name);
1419  
1420 6 my $output = [];
1421  
1422 6 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 6 0 6
1423 6 push @$output, $result;
1424 }
1425  
1426 6 return $output;
1427 }
1428  
1429 sub text_for_synopsis {
1430 2 ▶ my ($self) = @_;
Subroutine text_for_synopsis: called CC=2 SCAR=7.0
Pod undocumented
1431  
1432 2 my ($error, $result) = $self->catch('data', 'synopsis');
1433  
1434 2 my $output = [];
1435  
1436 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 2 0 2
1437 2 push @$output, $result;
1438 }
1439  
1440 2 return $output;
1441 }
1442  
1443 sub text_for_tagline {
1444 2 ▶ my ($self) = @_;
Subroutine text_for_tagline: called CC=2 SCAR=7.0
Pod undocumented
1445  
1446 2 my ($error, $result) = $self->catch('data', 'tagline');
1447  
1448 2 my $output = [];
1449  
1450 2 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 2 0 2
1451 2 push @$output, $result;
1452 }
1453  
1454 2 return $output;
1455 }
1456  
1457 sub text_for_version {
1458 1 ▶ my ($self) = @_;
Subroutine text_for_version: called CC=4 SCAR=15.0
Pod undocumented
1459  
1460 1 my ($error, $result) = $self->catch('data', 'version');
1461  
1462 1 my $output = [];
1463  
1464 1 ▶ if (!$error) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($error) 0 1 1
1465 0 push @$output, $result;
1466 }
1467  
1468 1 ▶ if (!@$output) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$output) 1 0 1
1469 1 my $name = $self->text_for_name;
1470 1 ▶ if (my $version = ($name->[0] =~ m/([:\w]+)/m)[0]->VERSION) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $version = ($name->[0] =~ /([:\w]+)/mu)[0]->VERSION) 0 1 1
1471 0 push @$output, $version;
1472 }
1473 }
1474  
1475 1 return $output;
1476 }
1477  
1478 61 1;
1479  
1480  
1481  
1482 =head1 NAME
1483  
1484 Venus::Test - Test Automation
1485  
1486 =cut
1487  
1488 =head1 ABSTRACT
1489  
1490 Test Automation for Perl 5
1491  
1492 =cut
1493  
1494 =head1 SYNOPSIS
1495  
1496 package main;
1497  
1498 use Venus::Test;
1499  
1500 my $test = test 't/Venus_Test.t';
1501  
1502 # $test->for('name');
1503  
1504 =cut
1505  
1506 =head1 DESCRIPTION
1507  
1508 This package aims to provide a standard for documenting L<Venus> derived
1509 software projects, a framework writing tests, test automation, and
1510 documentation generation.
1511  
1512 =cut
1513  
1514 =head1 INHERITS
1515  
1516 This package inherits behaviors from:
1517  
1518 L<Venus::Data>
1519  
1520 =cut
1521  
1522 =head1 INTEGRATES
1523  
1524 This package integrates behaviors from:
1525  
1526 L<Venus::Role::Buildable>
1527  
1528 =cut
1529  
1530 =head1 FUNCTIONS
1531  
1532 This package provides the following functions:
1533  
1534 =cut
1535  
1536 =head2 test
1537  
1538 test(Str $file) (Test)
1539  
1540 The test function is exported automatically and returns a L<Venus::Test> object
1541 for the test file given.
1542  
1543 I<Since C<0.09>>
1544  
1545 =over 4
1546  
1547 =item test example 1
1548  
1549 package main;
1550  
1551 use Venus::Test;
1552  
1553 my $test = test 't/Venus_Test.t';
1554  
1555 # bless( { ..., 'value' => 't/Venus_Test.t' }, 'Venus::Test' )
1556  
1557 =back
1558  
1559 =cut
1560  
1561 =head1 METHODS
1562  
1563 This package provides the following methods:
1564  
1565 =cut
1566  
1567 =head2 data
1568  
1569 data(Str $name, Any @args) (Str)
1570  
1571 The data method attempts to find and return the POD content based on the name
1572 provided. If the content cannot be found an exception is raised.
1573  
1574 I<Since C<0.09>>
1575  
1576 =over 4
1577  
1578 =item data example 1
1579  
1580 # given: synopsis
1581  
1582 my $data = $test->data('name');
1583  
1584 # Venus::Test
1585  
1586 =back
1587  
1588 =over 4
1589  
1590 =item data example 2
1591  
1592 # given: synopsis
1593  
1594 my $data = $test->data('unknown');
1595  
1596 # Exception!
1597  
1598 =back
1599  
1600 =cut
1601  
1602 =head2 for
1603  
1604 for(Str $name | CodeRef $code, Any @args) Any
1605  
1606 The for method attempts to find the POD content based on the name provided and
1607 executes the corresponding predefined test, optionally accepting a callback
1608 which, if provided, will be passes a L<Venus::Try> object containing the
1609 POD-driven test. The callback, if provided, must always return a true value.
1610 B<Note:> All automated tests disable the I<"redefine"> class of warnings to
1611 prevent warnings when redeclaring packages in examples.
1612  
1613 I<Since C<0.09>>
1614  
1615 =over 4
1616  
1617 =item for example 1
1618  
1619 # given: synopsis
1620  
1621 my $data = $test->for('name');
1622  
1623 # Venus::Test
1624  
1625 =back
1626  
1627 =over 4
1628  
1629 =item for example 2
1630  
1631 # given: synopsis
1632  
1633 my $data = $test->for('synosis');
1634  
1635 # true
1636  
1637 =back
1638  
1639 =over 4
1640  
1641 =item for example 3
1642  
1643 # given: synopsis
1644  
1645 my $data = $test->for('example', 1, 'data', sub {
1646 my ($tryable) = @_;
1647 my $result = $tryable->result;
1648 ok length($result) > 1;
1649  
1650 $result
1651 });
1652  
1653 # Venus::Test
1654  
1655 =back
1656  
1657 =cut
1658  
1659 =head2 pdml
1660  
1661 pdml(Str $name | CodeRef $code, Any @args) Str
1662  
1663 The pdml method attempts to find the POD content based on the name provided and
1664 return a POD string for use in documentation.
1665  
1666 I<Since C<0.09>>
1667  
1668 =over 4
1669  
1670 =item pdml example 1
1671  
1672 # given: synopsis
1673  
1674 my $pdml = $test->pdml('name');
1675  
1676 # =head1 NAME
1677 #
1678 # Venus::Test - Test Automation
1679 #
1680 # =cut
1681  
1682 =back
1683  
1684 =over 4
1685  
1686 =item pdml example 2
1687  
1688 # given: synopsis
1689  
1690 my $pdml = $test->pdml('synopsis');
1691  
1692 # =head1 SYNOPSIS
1693 #
1694 # package main;
1695 #
1696 # use Venus::Test;
1697 #
1698 # my $test = test 't/Venus_Test.t';
1699 #
1700 # # $test->for('name');
1701 #
1702 # =cut
1703  
1704 =back
1705  
1706 =over 4
1707  
1708 =item pdml example 3
1709  
1710 # given: synopsis
1711  
1712 my $pdml = $test->pdml('example', 1, 'data');
1713  
1714 # =over 4
1715 #
1716 # =item data example 1
1717 #
1718 # # given: synopsis
1719 #
1720 # my $data = $test->data(\'name\');
1721 #
1722 # # Venus::Test
1723 #
1724 # =back
1725  
1726 =back
1727  
1728 =cut
1729  
1730 =head2 render
1731  
1732 render(Str $file) Path
1733  
1734 The render method returns a string representation of a valid POD document.
1735  
1736 I<Since C<0.09>>
1737  
1738 =over 4
1739  
1740 =item render example 1
1741  
1742 # given: synopsis
1743  
1744 my $path = $test->render('t/Test_Venus.pod');
1745  
1746 # =over 4
1747 #
1748 # =item data example 1
1749 #
1750 # # given: synopsis
1751 #
1752 # my $data = $test->data(\'name\');
1753 #
1754 # # Venus::Test
1755 #
1756 # =back
1757  
1758 =back
1759  
1760 =cut
1761  
1762 =head2 text
1763  
1764 text(Str $name, Any @args) (Str)
1765  
1766 The text method attempts to find and return the POD content based on the name
1767 provided. If the content cannot be found an empty string is returned. If the
1768 POD block is not recognized, an exception is raised.
1769  
1770 I<Since C<0.09>>
1771  
1772 =over 4
1773  
1774 =item text example 1
1775  
1776 # given: synopsis
1777  
1778 my $text = $test->text('name');
1779  
1780 # Venus::Test
1781  
1782 =back
1783  
1784 =over 4
1785  
1786 =item text example 2
1787  
1788 # given: synopsis
1789  
1790 my $text = $test->text('includes');
1791  
1792 # function: test
1793 # method: data
1794 # method: for
1795 # method: pdml
1796 # method: render
1797 # method: text
1798  
1799 =back
1800  
1801 =over 4
1802  
1803 =item text example 3
1804  
1805 # given: synopsis
1806  
1807 my $text = $test->text('attributes');
1808  
1809 # ''
1810  
1811 =back
1812  
1813 =over 4
1814  
1815 =item text example 4
1816  
1817 # given: synopsis
1818  
1819 my $text = $test->text('unknown');
1820  
1821 # Exception!
1822  
1823 =back
1824  
1825 =cut
« Venus/Regexp.pm ↑ Summary Venus/Role/Catchable.pm »