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