line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
12
|
|
|
12
|
|
216086
|
use 5.008; # utf8 |
|
12
|
|
|
|
|
46
|
|
|
12
|
|
|
|
|
521
|
|
2
|
12
|
|
|
12
|
|
69
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
2790
|
|
3
|
12
|
|
|
12
|
|
89
|
use warnings; |
|
12
|
|
|
|
|
25
|
|
|
12
|
|
|
|
|
472
|
|
4
|
12
|
|
|
12
|
|
2307
|
use utf8; |
|
12
|
|
|
|
|
44
|
|
|
12
|
|
|
|
|
86
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Test::CPAN::Changes::ReallyStrict::Object; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.000001'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Object Oriented Guts to ::ReallyStrict |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
13
|
|
|
|
|
|
|
|
14
|
12
|
|
|
12
|
|
1044
|
use Test::Builder; |
|
12
|
|
|
|
|
22
|
|
|
12
|
|
|
|
|
406
|
|
15
|
12
|
|
|
12
|
|
15847
|
use Try::Tiny qw( try catch ); |
|
12
|
|
|
|
|
29235
|
|
|
12
|
|
|
|
|
11357
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $TEST = Test::Builder->new(); |
18
|
|
|
|
|
|
|
my $version_re = '^[._\-[:alnum:]]+$'; # "Looks like" a version |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Class::Tiny { |
21
|
1
|
|
|
|
|
31
|
testbuilder => sub { $TEST }, |
22
|
0
|
|
|
|
|
0
|
filename => sub { 'Changes' }, |
23
|
|
|
|
|
|
|
next_token => sub { |
24
|
7
|
50
|
|
|
|
341
|
return unless defined $_[0]->next_style; |
25
|
0
|
0
|
|
|
|
0
|
return qr/[{][{]\$NEXT[}][}]/msx if 'dzil' eq $_[0]->next_style; |
26
|
0
|
|
|
|
|
0
|
return; |
27
|
|
|
|
|
|
|
}, |
28
|
7
|
|
|
|
|
226
|
next_style => sub { undef }, |
29
|
|
|
|
|
|
|
changes => sub { |
30
|
10
|
|
|
|
|
103
|
my ($self) = @_; |
31
|
10
|
|
|
|
|
5782
|
require CPAN::Changes; |
32
|
10
|
|
|
|
|
64355
|
my @extra; |
33
|
10
|
100
|
|
|
|
408
|
push @extra, ( next_token => $self->next_token ) if defined $self->next_token; |
34
|
10
|
|
|
|
|
628
|
return CPAN::Changes->load( $self->filename, @extra ); |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
normalised_lines => sub { |
37
|
10
|
|
|
|
|
107
|
my ($self) = @_; |
38
|
10
|
50
|
|
|
|
258
|
if ( $self->delete_empty_groups ) { |
39
|
0
|
|
|
|
|
0
|
$self->changes->delete_empty_groups; |
40
|
|
|
|
|
|
|
} |
41
|
10
|
|
|
|
|
340
|
my $string = $self->changes->serialize; |
42
|
10
|
|
|
|
|
277509
|
return [ split /\n/msx, $string ]; |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
source_lines => sub { |
45
|
10
|
|
|
|
|
105
|
my ($self) = @_; |
46
|
10
|
|
|
|
|
22
|
my $fh; |
47
|
|
|
|
|
|
|
## no critic (ProhibitPunctuationVars) |
48
|
|
|
|
|
|
|
|
49
|
10
|
50
|
|
|
|
372
|
if ( not open $fh, '<', $self->filename ) { |
50
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, $self->filename . ' failed to open' ); |
51
|
0
|
|
|
|
|
0
|
$self->testbuilder->diag( 'Error ' . $! ); |
52
|
0
|
|
|
|
|
0
|
return; |
53
|
|
|
|
|
|
|
} |
54
|
10
|
|
|
|
|
1014
|
my $str = do { |
55
|
10
|
|
|
|
|
67
|
local $/ = undef; |
56
|
10
|
|
|
|
|
431
|
scalar <$fh>; |
57
|
|
|
|
|
|
|
}; |
58
|
10
|
50
|
|
|
|
174
|
close $fh or $self->testbuilder->diag( 'Warning: Error Closing ' . $self->filename ); |
59
|
10
|
|
|
|
|
1351
|
return [ split /\n/msx, $str ]; |
60
|
|
|
|
|
|
|
}, |
61
|
2
|
|
|
|
|
67
|
delete_empty_groups => sub { }, |
62
|
0
|
|
|
|
|
0
|
keep_comparing => sub { }, |
63
|
12
|
|
|
12
|
|
4778
|
}; |
|
12
|
|
|
|
|
17420
|
|
|
12
|
|
|
|
|
478
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub changes_ok { |
70
|
10
|
|
|
10
|
1
|
5608
|
my ( $self, ) = @_; |
71
|
10
|
|
|
|
|
19
|
my $exi; |
72
|
|
|
|
|
|
|
$self->testbuilder->subtest( |
73
|
|
|
|
|
|
|
'changes_ok' => sub { |
74
|
10
|
50
|
|
10
|
|
3315
|
return unless $self->loads_ok; |
75
|
10
|
50
|
|
|
|
56
|
return unless $self->has_releases; |
76
|
10
|
50
|
|
|
|
77
|
return unless $self->valid_releases; |
77
|
10
|
100
|
|
|
|
60
|
return unless $self->compare_lines; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#$self->testbuilder->ok(1, 'All Subtests for ' . $self->filename . ' done' ); |
80
|
6
|
|
|
|
|
31
|
$exi = 1; |
81
|
|
|
|
|
|
|
}, |
82
|
10
|
|
|
|
|
504
|
); |
83
|
10
|
100
|
|
|
|
2315
|
return unless $exi; |
84
|
6
|
|
|
|
|
70
|
return 1; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub loads_ok { |
96
|
10
|
|
|
10
|
1
|
27
|
my ($self) = @_; |
97
|
10
|
|
|
|
|
19
|
my ( $error, $success ); |
98
|
|
|
|
|
|
|
try { |
99
|
10
|
|
|
10
|
|
768
|
$self->changes(); |
100
|
10
|
|
|
|
|
116505
|
$success = 1; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
catch { |
103
|
0
|
|
|
0
|
|
0
|
undef $success; |
104
|
0
|
|
|
|
|
0
|
$error = $_; |
105
|
10
|
|
|
|
|
125
|
}; |
106
|
10
|
50
|
33
|
|
|
446
|
if ( not $error and $success ) { |
107
|
10
|
|
|
|
|
296
|
$self->testbuilder->ok( 1, $self->filename . ' is loadable' ); |
108
|
10
|
|
|
|
|
1986
|
return 1; |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, $self->filename . ' is loadable' ); |
111
|
0
|
|
|
|
|
0
|
$self->testbuilder->diag($error); |
112
|
0
|
|
|
|
|
0
|
return; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub has_releases { |
124
|
10
|
|
|
10
|
1
|
24
|
my ($self) = @_; |
125
|
10
|
|
|
|
|
252
|
my (@releases) = $self->changes->releases; |
126
|
10
|
50
|
|
|
|
31404
|
if (@releases) { |
127
|
10
|
|
|
|
|
370
|
$self->testbuilder->ok( 1, $self->filename . ' contains at least one release' ); |
128
|
10
|
|
|
|
|
1495
|
return 1; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, $self->filename . ' does not contain any release' ); |
131
|
0
|
|
|
|
|
0
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub valid_release_date { |
143
|
238
|
|
|
238
|
1
|
842
|
my ( $self, $release, $release_id ) = @_; |
144
|
238
|
100
|
66
|
|
|
686
|
if ( not defined $release->date and defined $self->next_token ) { |
145
|
2
|
|
|
|
|
126
|
$self->testbuilder->ok( 1, "release $release_id has valid date (none|next_token)" ); |
146
|
2
|
|
|
|
|
84
|
return 1; |
147
|
|
|
|
|
|
|
} |
148
|
236
|
50
|
|
|
|
2099
|
if ( $release->date =~ m/\A${CPAN::Changes::W3CDTF_REGEX}\s*\z/msx ) { |
149
|
236
|
|
|
|
|
9449
|
$self->testbuilder->ok( 1, "release $release_id has valid date (regexp match)" ); |
150
|
236
|
|
|
|
|
17895
|
return 1; |
151
|
|
|
|
|
|
|
} |
152
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, "release $release_id has an invalid release date" ); |
153
|
0
|
|
|
|
|
0
|
$self->testbuilder->diag( ' ERR:' . $release->date ); |
154
|
0
|
|
|
|
|
0
|
return; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub valid_release_version { |
166
|
238
|
|
|
238
|
1
|
394
|
my ( $self, $release, $release_id ) = @_; |
167
|
238
|
50
|
33
|
|
|
635
|
if ( not defined $release->version and defined $self->next_token ) { |
168
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 1, "release $release_id has valid version (none|next_token)" ); |
169
|
0
|
|
|
|
|
0
|
return 1; |
170
|
|
|
|
|
|
|
} |
171
|
238
|
100
|
100
|
|
|
8013
|
if ( defined $self->next_token and $release->version =~ $self->next_token ) { |
172
|
2
|
|
|
|
|
131
|
$self->testbuilder->ok( 1, "release $release_id has valid version (regexp match on next_token)" ); |
173
|
2
|
|
|
|
|
91
|
return 1; |
174
|
|
|
|
|
|
|
} |
175
|
236
|
50
|
|
|
|
5061
|
if ( $release->version =~ m/$version_re/msx ) { |
176
|
236
|
|
|
|
|
21965
|
$self->testbuilder->ok( 1, "release $release_id has valid version (regexp match version re)" ); |
177
|
236
|
|
|
|
|
17596
|
return 1; |
178
|
|
|
|
|
|
|
} |
179
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, "release $release_id has valid version." ); |
180
|
0
|
|
|
|
|
0
|
$self->testbuilder->diag( ' ERR:' . $release->version ); |
181
|
0
|
|
|
|
|
0
|
return; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub valid_releases { |
193
|
10
|
|
|
10
|
1
|
25
|
my ($self) = @_; |
194
|
10
|
|
|
|
|
46
|
my $top_exit = 1; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
$self->testbuilder->subtest( |
197
|
|
|
|
|
|
|
'valid releases' => sub { |
198
|
10
|
|
|
10
|
|
2464
|
my (@releases) = $self->changes->releases; |
199
|
10
|
|
|
|
|
37159
|
for my $id ( 0 .. $#releases ) { |
200
|
238
|
|
|
|
|
562
|
my ($release) = $releases[$id]; |
201
|
238
|
|
|
|
|
326
|
my $sub_exit; |
202
|
|
|
|
|
|
|
$self->testbuilder->subtest( |
203
|
|
|
|
|
|
|
'valid release: ' . $id => sub { |
204
|
238
|
50
|
|
|
|
27999
|
return unless $self->valid_release_date( $release, $id ); |
205
|
238
|
50
|
|
|
|
679
|
return unless $self->valid_release_version( $release, $id ); |
206
|
238
|
|
|
|
|
9720
|
$sub_exit = 1; |
207
|
|
|
|
|
|
|
}, |
208
|
238
|
|
|
|
|
5798
|
); |
209
|
238
|
50
|
|
|
|
29394
|
undef $top_exit unless $sub_exit; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
}, |
212
|
10
|
|
|
|
|
269
|
); |
213
|
10
|
50
|
|
|
|
2556
|
return 1 if $top_exit; |
214
|
0
|
|
|
|
|
0
|
return; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
sub compare_line { |
226
|
2150
|
|
|
2150
|
1
|
4010
|
my ( $self, $source, $normalised, $line_number, $failed_before ) = @_; |
227
|
2150
|
0
|
33
|
|
|
4215
|
if ( not defined $source and not defined $normalised ) { |
228
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 1, "source($line_number) == normalised($line_number) : undef vs undef" ); |
229
|
0
|
|
|
|
|
0
|
return 1; |
230
|
|
|
|
|
|
|
} |
231
|
2150
|
50
|
33
|
|
|
11355
|
if ( defined $source and not defined $normalised ) { |
232
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, "source($line_number) != normalised($line_number) : defined vs undef" ); |
233
|
0
|
|
|
|
|
0
|
return; |
234
|
|
|
|
|
|
|
} |
235
|
2150
|
50
|
33
|
|
|
4681
|
if ( not defined $source and defined $normalised ) { |
236
|
0
|
|
|
|
|
0
|
$self->testbuilder->ok( 0, "source($line_number) != normalised($line_number) : undef vs defined" ); |
237
|
0
|
|
|
|
|
0
|
return; |
238
|
|
|
|
|
|
|
} |
239
|
2150
|
100
|
|
|
|
9335
|
if ( $source eq $normalised ) { |
240
|
1574
|
|
|
|
|
43066
|
$self->testbuilder->ok( 1, "source($line_number) == normalised($line_number) : val eq val" ); |
241
|
1574
|
|
|
|
|
194354
|
return 1; |
242
|
|
|
|
|
|
|
} |
243
|
576
|
100
|
|
|
|
976
|
if ( not $failed_before ) { |
244
|
4
|
|
|
|
|
89
|
$self->testbuilder->ok( 0, "Lines differ at $line_number" ); |
245
|
|
|
|
|
|
|
} |
246
|
576
|
|
|
|
|
12228
|
$self->testbuilder->diag( sprintf q{[%s] Expected: >%s<}, $line_number, $normalised ); |
247
|
576
|
|
|
|
|
30879
|
$self->testbuilder->diag( sprintf q{[%s] Got : >%s<}, $line_number, $source ); |
248
|
576
|
|
|
|
|
20160
|
return; |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
sub compare_lines { |
261
|
10
|
|
|
10
|
1
|
28
|
my ($self) = @_; |
262
|
|
|
|
|
|
|
|
263
|
10
|
|
|
|
|
22
|
my (@source) = @{ $self->source_lines }; |
|
10
|
|
|
|
|
278
|
|
264
|
10
|
|
|
|
|
481
|
my (@normalised) = @{ $self->normalised_lines }; |
|
10
|
|
|
|
|
279
|
|
265
|
|
|
|
|
|
|
|
266
|
10
|
|
|
|
|
493
|
my $all_lines_passed = 1; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
$self->testbuilder->subtest( |
269
|
|
|
|
|
|
|
'compare lines source vs normalised' => sub { |
270
|
10
|
|
|
10
|
|
2779
|
$self->testbuilder->note( sprintf q[Source: %s, Normalised: %s], $#source, $#normalised ); |
271
|
10
|
|
|
|
|
735
|
my $failed_already; |
272
|
10
|
|
|
|
|
51
|
for ( 0 .. $#source ) { |
273
|
2150
|
|
|
|
|
8921
|
my $line_passed = $self->compare_line( $source[$_], $normalised[$_], $_, $failed_already ); |
274
|
2150
|
100
|
|
|
|
5351
|
if ( not $line_passed ) { |
275
|
576
|
|
|
|
|
667
|
$failed_already = 1; |
276
|
576
|
|
|
|
|
581
|
undef $all_lines_passed; |
277
|
576
|
100
|
|
|
|
11041
|
if ( not $self->keep_comparing ) { |
278
|
2
|
|
|
|
|
34
|
last; |
279
|
|
|
|
|
|
|
} |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
}, |
283
|
10
|
|
|
|
|
285
|
); |
284
|
10
|
100
|
|
|
|
2924
|
return 1 if $all_lines_passed; |
285
|
4
|
|
|
|
|
201
|
return; |
286
|
|
|
|
|
|
|
} |
287
|
|
|
|
|
|
|
1; |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
__END__ |