line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
979
|
use v5.14; |
|
1
|
|
|
|
|
4
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Modulino::Demo2; |
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
10
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
24
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
489
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.003'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
UNITCHECK { |
12
|
|
|
|
|
|
|
sub _running_under_docreader { |
13
|
|
|
|
|
|
|
!! $ENV{PERLDOC} |
14
|
1
|
|
|
1
|
|
6
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _running_under_tester { |
17
|
|
|
|
|
|
|
!! $ENV{HARNESS_ACTIVE} |
18
|
1
|
|
|
1
|
|
4
|
} |
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::Demo2 - A demonstration of modulino 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
|
|
5
|
require Test::More; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
7
|
Test::More::pass(); |
60
|
1
|
|
|
|
|
352
|
Test::More::pass(); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
SKIP: { |
63
|
1
|
|
|
|
|
341
|
Test::More::skip( "These tests don't work", 2 ); |
|
1
|
|
|
|
|
7
|
|
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
|
37
|
say "Running as test"; |
84
|
|
|
|
|
|
|
|
85
|
1
|
|
|
|
|
5
|
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
|
|
1525
|
my $rc = eval { $class->$test(); 1 }; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
3539
|
|
93
|
2
|
50
|
|
|
|
8
|
Test::More::diag( $@ ) unless defined $rc; |
94
|
2
|
|
|
|
|
1329
|
} ); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _get_tests { |
99
|
1
|
|
|
1
|
|
2
|
my( $class ) = @_; |
100
|
1
|
|
|
1
|
|
9
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
354
|
|
101
|
1
|
|
|
|
|
3
|
my $stub = $class . '::'; |
102
|
|
|
|
|
|
|
my @tests = |
103
|
2
|
|
|
|
|
3
|
grep { defined &{"$stub$_"} } |
|
2
|
|
|
|
|
10
|
|
104
|
14
|
|
|
|
|
28
|
grep { 0 == index $_, '_test_' } |
105
|
1
|
|
|
|
|
2
|
keys %{ "$stub" }; |
|
1
|
|
|
|
|
7
|
|
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
12
|
say "Tests are @tests"; |
108
|
1
|
|
|
|
|
5
|
@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
|
0
|
|
|
|
|
0
|
require Pod::Perldoc; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
*Pod::Perldoc::program_name = sub { |
126
|
0
|
|
|
0
|
|
0
|
'perldoc'; |
127
|
0
|
|
|
|
|
0
|
}; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
0
|
Pod::Perldoc->new( args => [ __FILE__ ] )->process(); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub _test_doc { |
133
|
1
|
|
|
1
|
|
7
|
require Test::More; |
134
|
1
|
|
|
|
|
4
|
require Test::Pod; |
135
|
1
|
|
|
|
|
3
|
require Test::Pod::Coverage; |
136
|
1
|
|
|
|
|
2
|
our $TODO; |
137
|
|
|
|
|
|
|
|
138
|
1
|
|
|
|
|
4
|
Test::Pod::pod_file_ok( __FILE__ ); |
139
|
|
|
|
|
|
|
TODO: { |
140
|
1
|
|
|
|
|
9958
|
local $TODO = "Pod::Coverage can't find the pod"; |
|
1
|
|
|
|
|
3
|
|
141
|
1
|
|
|
|
|
3
|
Test::Pod::Coverage::pod_coverage_ok( __PACKAGE__ ); |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 TO DO |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 SEE ALSO |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SOURCE AVAILABILITY |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
This source is in Github: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
https://github.com/briandfoy/modulino-demo/ |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
brian d foy, C<< >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Copyright © 2012-2021, brian d foy . All rights reserved. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
You may redistribute this under the terms of the Artistic License 2.0. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
1; |