| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
735
|
use v5.14; |
|
|
1
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Modulino::Demo; |
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
20
|
|
|
5
|
1
|
|
|
1
|
|
681
|
use utf8; |
|
|
1
|
|
|
|
|
14
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
32
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
454
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
UNITCHECK { |
|
12
|
|
|
|
|
|
|
sub _running_under_docreader { |
|
13
|
|
|
|
|
|
|
!! $ENV{PERLDOC} |
|
14
|
1
|
|
|
1
|
|
5
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _running_under_tester { |
|
17
|
|
|
|
|
|
|
!! $ENV{HARNESS_ACTIVE} |
|
18
|
1
|
|
|
1
|
|
5
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _running_as_app { |
|
21
|
|
|
|
|
|
|
defined scalar caller |
|
22
|
0
|
|
|
0
|
|
0
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $method = do { |
|
25
|
|
|
|
|
|
|
if( _running_under_docreader() ) { 'doc' } # reading docs |
|
26
|
|
|
|
|
|
|
elsif( _running_under_tester() ) { 'test' } # testing |
|
27
|
|
|
|
|
|
|
elsif( _running_as_app() ) { 'run' } # running the application |
|
28
|
|
|
|
|
|
|
else { undef } # everything else |
|
29
|
|
|
|
|
|
|
}; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->$method(@ARGV) if defined $method; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding utf8 |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Modulino::Demo - A demonstration of module ideas |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
use Modulino::Demo; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item run |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub run { |
|
53
|
0
|
|
|
0
|
1
|
0
|
say "Running as program"; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _test_run { |
|
57
|
1
|
|
|
1
|
|
7
|
require Test::More; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
4
|
Test::More::pass(); |
|
60
|
1
|
|
|
|
|
344
|
Test::More::pass(); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
SKIP: { |
|
63
|
1
|
|
|
|
|
390
|
Test::More::skip( "These tests don't work", 2 ); |
|
|
1
|
|
|
|
|
11
|
|
|
64
|
0
|
|
|
|
|
0
|
Test::More::fail(); |
|
65
|
0
|
|
|
|
|
0
|
Test::More::fail(); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=back |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 Testing |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=over 4 |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item test |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Run all of the subroutines that start with C<_test_>. Each subroutine |
|
78
|
|
|
|
|
|
|
is wrapped in a C subtest. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub test { |
|
83
|
1
|
|
|
1
|
1
|
89
|
say "Running as test"; |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
6
|
my( $class ) = @_; |
|
86
|
1
|
|
|
|
|
4
|
my @tests = $class->_get_tests; |
|
87
|
|
|
|
|
|
|
|
|
88
|
1
|
|
|
|
|
6
|
require Test::More; |
|
89
|
|
|
|
|
|
|
|
|
90
|
1
|
|
|
|
|
3
|
foreach my $test ( @tests ) { |
|
91
|
|
|
|
|
|
|
Test::More::subtest( $test => sub { |
|
92
|
2
|
|
|
2
|
|
1890
|
my $rc = eval { $class->$test(); 1 }; |
|
|
2
|
|
|
|
|
19
|
|
|
|
2
|
|
|
|
|
4095
|
|
|
93
|
2
|
50
|
|
|
|
10
|
Test::More::diag( $@ ) unless defined $rc; |
|
94
|
2
|
|
|
|
|
1852
|
} ); |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _get_tests { |
|
99
|
1
|
|
|
1
|
|
2
|
my( $class ) = @_; |
|
100
|
1
|
|
|
1
|
|
9
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
341
|
|
|
101
|
1
|
|
|
|
|
5
|
my $stub = $class . '::'; |
|
102
|
|
|
|
|
|
|
my @tests = |
|
103
|
2
|
|
|
|
|
3
|
grep { defined &{"$stub$_"} } |
|
|
2
|
|
|
|
|
9
|
|
|
104
|
14
|
|
|
|
|
30
|
grep { 0 == index $_, '_test_' } |
|
105
|
1
|
|
|
|
|
2
|
keys %{ "$stub" }; |
|
|
1
|
|
|
|
|
7
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
12
|
say "Tests are @tests"; |
|
108
|
1
|
|
|
|
|
6
|
@tests; |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=back |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 Reading the docs |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=over 4 |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item doc |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub doc { |
|
122
|
0
|
|
|
0
|
1
|
0
|
say "Running as docs"; |
|
123
|
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
my $data = do { |
|
125
|
0
|
|
|
|
|
0
|
local( @ARGV, $/ ) = __FILE__; |
|
126
|
0
|
|
|
|
|
0
|
<>; |
|
127
|
|
|
|
|
|
|
}; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
my $package = __PACKAGE__; |
|
130
|
0
|
|
|
|
|
0
|
$data =~ s/__PACKAGE__/$package/; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
0
|
say $data; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _test_doc { |
|
136
|
1
|
|
|
1
|
|
7
|
require Test::More; |
|
137
|
1
|
|
|
|
|
510
|
require Test::Pod; |
|
138
|
1
|
|
|
|
|
32500
|
require Test::Pod::Coverage; |
|
139
|
1
|
|
|
|
|
1282
|
our $TODO; |
|
140
|
|
|
|
|
|
|
|
|
141
|
1
|
|
|
|
|
8
|
Test::Pod::pod_file_ok( __FILE__ ); |
|
142
|
|
|
|
|
|
|
TODO: { |
|
143
|
1
|
|
|
|
|
26035
|
local $TODO = "Pod::Coverage can't find the pod"; |
|
|
1
|
|
|
|
|
2
|
|
|
144
|
1
|
|
|
|
|
4
|
Test::Pod::Coverage::pod_coverage_ok( __PACKAGE__ ); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 TO DO |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This source is in Github: |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
https://github.com/briandfoy/modulino-demo/ |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 AUTHOR |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
brian d foy, C<< >> |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Copyright © 2012-2021, brian d foy . All rights reserved. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You may redistribute this under the terms as the Artistic License 2.0. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |