Test/MetaSyntactic.pm

filter: Statementstmt 92.6% 238 / 257 Branchbran 48.6% 35 / 72 Conditioncond 35.7% 10 / 28 MC/DCmcdc 0.0% 0 / 17 Subroutinesub 100% 53 / 53 Podpod 100% 13 / 13 totaltotal 79.3% 349 / 440 CC 62 SCAR 27.2
CC
62
Cov
79%
subtest_remote
87.0
subtest_length
7.9
_check_file_lines
7.5
CRAP 15.2
↑ Summary Acme/MetaSyntactic/Locale.pm »
1 package Test::MetaSyntactic;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Acme::MetaSyntactic ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 ▶use base 'Test::Builder::Module';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 our @EXPORT = qw( all_themes_ok theme_ok );
10 3 our $VERSION = '1.005';
11  
12 #
13 # exported functions
14 #
15  
16 sub all_themes_ok {
17 1 ▶ my (@lib) = @_;
Subroutine all_themes_ok: called CC=6 SCAR=18.3
Pod documented
18 1 ▶ @lib = _starting_points() if !@lib;
Branch: 1 branch
BranchTrueFalseTotal
unless @lib 1 0 1
19 1 my %source = Acme::MetaSyntactic->_find_themes(@lib);
20  
21 1 my $tb = __PACKAGE__->builder;
22 1 local $Test::Builder::Level = $Test::Builder::Level + 1;
23 1 $tb->plan( tests => scalar keys %source );
24 1 my @fail;
25 1 ▶ theme_ok( $_, $source{$_} ) or push @fail, $_ for sort keys %source;
Branch: 1 branch
BranchTrueFalseTotal
theme_ok($_, $source{$_}) or push @fail, $_ 0 3 3
26 1 ▶ $tb->diag("Test suite failed for the following:") if @fail;
Branch: 1 branch
BranchTrueFalseTotal
if @fail 0 1 1
27 1 $tb->diag("- $_") for @fail;
28 }
29  
30 sub theme_ok {
31 3 ▶ my @args = @_;
Subroutine theme_ok: called CC=1 SCAR=0.0
Pod documented
32 3 my $tb = __PACKAGE__->builder;
33 3 local $Test::Builder::Level = $Test::Builder::Level + 1;
34  
35 # all subtests
36 3 my $theme = $args[0];
37 $tb->subtest(
38 $theme,
39 sub {
40 3 ▶ $tb->subtest( "$theme fixme", sub { subtest_fixme(@args); } );
Subroutine __ANON__: called CC=2 SCAR=6.9
41 3 ▶ $tb->subtest( "$theme encoding", sub { subtest_encoding(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
42 3 ▶ $tb->subtest( "$theme load", sub { subtest_load(@args); } )
Subroutine __ANON__: called CC=1 SCAR=0.0
43 3 ▶ or return;
Branch: 1 branch
BranchTrueFalseTotal
$tb->subtest("$theme load", sub { subtest_load(@args); } ) or return 0 3 3
44 3 ▶ $tb->subtest( "$theme version", sub { subtest_version(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
45 3 ▶ $tb->subtest( "$theme data", sub { subtest_data(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
46 3 ▶ $tb->subtest( "$theme format", sub { subtest_format(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
47 3 ▶ $tb->subtest( "$theme length", sub { subtest_length(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
48 3 ▶ $tb->subtest( "$theme import", sub { subtest_import(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
49 3 ▶ $tb->subtest( "$theme noimport", sub { subtest_noimport(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
50 3 ▶ $tb->subtest( "$theme theme", sub { subtest_theme(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
51 3 ▶ $tb->subtest( "$theme remote", sub { subtest_remote(@args); } );
Subroutine __ANON__: called CC=1 SCAR=0.0
52 3 $tb->done_testing;
53 }
54 3 );
55 }
56  
57 #
58 # useful internal functions
59 #
60  
61 # some starting points to look for theme modules
62 sub _starting_points {
63 1 ▶ return 'blib/lib' if -e 'blib/lib';
Subroutine _starting_points: called CC=2 SCAR=9.2
Branch: 1 branch
BranchTrueFalseTotal
if -e "blib/lib" 1 0 1
64 0 return 'lib';
65 }
66  
67 # load the theme in a random namespace
68 {
69 3 my $num = 0;
70  
71 sub _load {
72 8 ▶ my ( $theme, $do_import ) = @_;
Subroutine _load: called CC=3 SCAR=11.0
73 8 my $module = "Acme::MetaSyntactic::$theme";
74 8 my $pkg = sprintf "Acme::MetaSyntactic::SCRATCH_%04d", $num++;
75 8 ▶ my $code = $do_import
Branch: 1 branch
BranchTrueFalseTotal
$do_import ? : 5 3 8
76 ? "package $pkg; use $module; 1;"
77 : "package $pkg; use $module (); 1;";
78 8 ▶ my $ok = eval $code;
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
79 8 ▶ return ( $pkg, !$ok && $@ );
Condition33%1/3
!$ok && $@
!ll&&!rl&&r
800
MC/DC0%0/2
!$ok && $@
!$ok $@
Truth table33%1/3
not(A) && B
A= !$okB= $@
ABresult
0X0
100
111
80 }
81 }
82  
83 # return a list of [ AMS object, details ]
84 3 sub _theme_sublists {
85 9 ▶ my ($theme) = @_;
Subroutine _theme_sublists: called CC=5 SCAR=16.4
86 9 my @metas;
87  
88 # assume the module has already been loaded
89 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
90 9 my $class = "Acme::MetaSyntactic::$theme";
91  
92 9 ▶ if( $class->isa('Acme::MetaSyntactic::Locale') ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($class->isa('Acme::MetaSyntactic::Locale')) { } 3 6 9
elsif ($class->isa('Acme::MetaSyntactic::MultiList')) { } 0 6 6
93 3 for my $lang ( "Acme::MetaSyntactic::$theme"->languages() ) {
94 9 push @metas,
95 [ "Acme::MetaSyntactic::$theme"->new( lang => $lang ),
96 "$theme, $lang locale" ];
97 }
98 }
99 elsif( $class->isa('Acme::MetaSyntactic::MultiList') ) {
100 0 for my $cat ( "Acme::MetaSyntactic::$theme"->categories() ) {
101 0 push @metas,
102 [ "Acme::MetaSyntactic::$theme"->new( category => $cat ),
103 "$theme, $cat category" ];
104 }
105 }
106 else {
107 6 push @metas, [ "Acme::MetaSyntactic::$theme"->new(), $theme ];
108 }
109  
110 9 return @metas;
111 }
112  
113 # return the list of all theme items
114 sub _theme_items {
115 2 ▶ my ($theme) = @_;
Subroutine _theme_items: called CC=3 SCAR=11.0
116  
117 # assume the module has already been loaded
118 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
119 2 my $class = "Acme::MetaSyntactic::$theme";
120 my @items
121 = $class->isa('Acme::MetaSyntactic::List')
122 1 ▶ ? @{"$class\::List"}
Branch: 1 branch
BranchTrueFalseTotal
$class->isa('Acme::MetaSyntactic::MultiList') ? : 1 0 1
123 : $class->isa('Acme::MetaSyntactic::MultiList')
124 2 ▶ ? map @$_, values %{"$class\::MultiList"}
Branch: 1 branch
BranchTrueFalseTotal
$class->isa('Acme::MetaSyntactic::List') ? : 1 1 2
125 : ();
126 2 return @items;
127 }
128  
129 sub _check_file_lines {
130 9 ▶ my ($theme, $file, $mesg, $cb ) = @_;
Subroutine _check_file_lines: called CC=6 SCAR=20.1
131 9 my $tb = __PACKAGE__->builder;
132 9 $tb->plan( tests => 1 );
133 9 local $Test::Builder::Level = $Test::Builder::Level + 1;
134  
135 # try to find a source file if none given
136 9 ▶ $file ||= { Acme::MetaSyntactic->_find_themes(_starting_points) }->{$theme};
Condition33%1/3
$file ||= {"Acme::MetaSyntactic"->_find_themes(_starting_points())}->{$theme}
l!l&&r!l&&!r
900
MC/DC0%0/2
$file ||= {"Acme::MetaSyntactic"->_find_themes(_starting_points())}->{$theme}
$file {"Acme::MetaSyntactic"->_find_themes(_starting_points())}->{$theme}
Truth table33%1/3
A ||= B
A= $fileB= {"Acme::MetaSyntactic"->_find_themes(_starting_points())}->{$theme}
ABresult
1X1
011
000
137  
138 SKIP: {
139 9 my ($fh, $skip);
140 9 ▶ if ( $file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($file) { } 9 0 9
141 9 ▶ open $fh, $file or do { $skip = "Can't open $file: $!"; };
Branch: 1 branch
BranchTrueFalseTotal
open $fh, $file or do { $skip = "Can't open ${file}: $!" } 0 9 9
142 }
143 else {
144 0 $skip = "This test needs the source file for $theme";
145 }
146 9 ▶ if( $skip ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($skip) 0 9 9
147 0 $tb->skip($skip);
148 0 last SKIP;
149 }
150  
151 9 my @lines = $cb->( <$fh> );
152 9 $tb->is_num( scalar @lines, 0, sprintf $mesg, $file );
153 9 ▶ map $tb->diag( $_ ), "Failed lines:\n", map " $_", @lines if @lines;
Branch: 1 branch
BranchTrueFalseTotal
if @lines 0 9 9
154 9 close $fh;
155 }
156 }
157  
158 #
159 # individual subtest functions
160 #
161  
162 # t/01load.t
163 # t/51useall.t
164 sub subtest_load {
165 3 ▶ my ($theme) = @_;
Subroutine subtest_load: called CC=3 SCAR=11.1
Pod documented
166 3 my $tb = __PACKAGE__->builder;
167  
168 3 $tb->plan( tests => 2 );
169  
170 # load in the current process
171 3 my ( $pkg, $error ) = _load( $theme, 1 );
172 3 $tb->ok( !$error, "use Acme::MetaSyntactic::$theme;" );
173 3 ▶ $tb->diag($error) if $error;
Branch: 1 branch
BranchTrueFalseTotal
if $error 0 3 3
174  
175 # load in isolation
176 3 ▶ local $ENV{PERL5LIB} = join $Config::Config{path_sep} || ';', @INC;
Condition50%1/2
$Config::Config{'path_sep'} || ';'
l!l
30
MC/DC0%0/1
$Config::Config{'path_sep'} || ';'
$Config::Config{'path_sep'}
Truth table50%1/2
A
A= $Config::Config{'path_sep'}
Aresult
11
00
177 3 `$^X -MAcme::MetaSyntactic::$theme -e1`;
178 3 $tb->is_eq( $? >> 8, 0, "perl -MAcme::MetaSyntactic::$theme -e1" );
179 }
180  
181 # t/02fixme.t
182 sub subtest_fixme {
183 3 ▶ my ( $theme, $file ) = @_;
Subroutine subtest_fixme: called CC=2 SCAR=7.0
Pod documented
184 3 ▶ $file = '' if !defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 3 3
185 _check_file_lines(
186 $theme, $file,
187 "No FIXME found in %s",
188 3 ▶ sub { grep /\bFIXME\b/, @_ }
Subroutine __ANON__: called CC=1 SCAR=0.0
189 3 );
190 }
191  
192 sub subtest_encoding {
193 3 ▶ my ( $theme, $file ) = @_;
Subroutine subtest_encoding: called CC=2 SCAR=7.1
Pod documented
194 3 ▶ $file = '' if !defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 3 3
195 _check_file_lines(
196 $theme, $file,
197 "%s should have an =encoding line if it contains non-us-ascii characters",
198 sub {
199 3 ▶ my @non_ascii = grep /[^\x00-\x7f]/, @_;
Subroutine __ANON__: called CC=2 SCAR=7.1
200 3 my @encoding = grep /^=encoding \S+/, @_;
201 3 ▶ return @encoding ? () : @non_ascii;
Branch: 1 branch
BranchTrueFalseTotal
@encoding ? : 3 0 3
202 }
203 3 );
204 }
205  
206 # t/08theme.t
207 sub subtest_theme {
208 3 ▶ my ($theme) = @_;
Subroutine subtest_theme: called CC=1 SCAR=0.0
Pod documented
209 3 my $tb = __PACKAGE__->builder;
210 3 $tb->plan( tests => 2 );
211  
212 3 $tb->is_eq( eval { "Acme::MetaSyntactic::$theme"->theme },
213 $theme, "theme() for Acme::MetaSyntactic::$theme" );
214 3 $tb->is_eq( eval { "Acme::MetaSyntactic::$theme"->new->theme },
215 $theme, "theme() for Acme::MetaSyntactic::$theme" );
216 }
217  
218 # t/17import.t
219 sub subtest_import {
220 3 ▶ my ($theme) = @_;
Subroutine subtest_import: called CC=3 SCAR=11.0
Pod documented
221 3 my $tb = __PACKAGE__->builder;
222 3 $tb->plan( tests => my $tests = 2 );
223  
224 SKIP: {
225 3 ▶ if ( $theme =~ /^(?:any|random)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($theme =~ /^(?:any|random)$/) { } 1 2 3
226 1 $tb->skip("Not testing import for theme $theme") for 1 .. $tests;
227 1 last SKIP;
228 }
229 else {
230 2 my ($pkg) = _load( $theme, 1 );
231 2 my %seen = map { $_ => 1 } _theme_items($theme);
232  
233 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
234 2 $tb->ok( exists ${"$pkg\::"}{"meta$theme"},
235 "meta$theme exported" );
236  
237 my @names
238 2 ▶ = eval qq{package $pkg; no strict 'refs'; "meta$theme"->();};
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
239 2 $tb->ok( exists $seen{ $names[0] }, "meta$theme -> $names[0]" );
240 }
241 }
242 }
243  
244 # t/18import.t
245 sub subtest_noimport {
246 3 ▶ my ($theme) = @_;
Subroutine subtest_noimport: called CC=1 SCAR=0.0
Pod documented
247 3 my $tb = __PACKAGE__->builder;
248 3 $tb->plan( tests => 1 );
249  
250 3 my ($pkg) = _load($theme);
251  
252 # meta$theme should not exist
253 3 eval "package $pkg; meta$theme(1);";
254 3 $tb->ok( $@ =~ /^Undefined subroutine &$pkg\::meta$theme called/,
255 "meta$theme function not exported" );
256 }
257  
258 # t/21format.t
259 sub subtest_format {
260 3 ▶ my ($theme) = @_;
Subroutine subtest_format: called CC=6 SCAR=18.5
Pod documented
261 3 my $tb = __PACKAGE__->builder;
262  
263 3 my @metas = _theme_sublists($theme);
264 3 $tb->plan( tests => scalar @metas );
265  
266 3 for my $test (@metas) {
267 5 my ( $ams, $theme ) = @$test;
268 5 my @items = $ams->name(0);
269 5 my @failed;
270 5 my $ok = 0;
271 5 ▶ ( /^[A-Za-z_]\w*$/ && ++$ok ) || push @failed, $_ for @items;
Branch: 1 branch
BranchTrueFalseTotal
/^[A-Za-z_]\w*$/ and ++$ok or push @failed, $_ 0 106 106
Condition33%1/3
/^[A-Za-z_]\w*$/ and ++$ok
!ll&&!rl&&r
00106
MC/DC0%0/2
/^[A-Za-z_]\w*$/ and ++$ok
/^[A-Za-z_]\w*$/ ++$ok
Truth table33%1/3
A and B
A= /^[A-Za-z_]\w*$/B= ++$ok
ABresult
0X0
100
111
272 5 $tb->is_num( $ok, scalar @items, "All names correct for $theme" );
273 5 ▶ $tb->diag("Bad names: @failed") if @failed;
Branch: 1 branch
BranchTrueFalseTotal
if @failed 0 5 5
274 }
275 }
276  
277 # t/23length.t
278 sub subtest_length {
279 3 ▶ my ($theme) = @_;
Subroutine subtest_length: called CC=7 SCAR=20.6
Pod documented
280 3 my $tb = __PACKAGE__->builder;
281  
282 3 my @metas = _theme_sublists($theme);
283 3 $tb->plan( tests => 2 * @metas );
284  
285 3 for my $t (@metas) {
286 5 my ( $ams, $theme ) = @$t;
287  
288 # no empty themes
289 5 my @items = $ams->name(0);
290 5 $tb->cmp_ok( 0 + @items, '>=', 1, "$theme has at least one item" );
291  
292 # no empty names
293 5 my @failed;
294 5 my $ok = 0;
295 ( length($_) >= 1 && length($_) <= 251 && ++$ok ) || push @failed, $_
296 5 ▶ for @items;
Branch: 1 branch
BranchTrueFalseTotal
length $_ >= 1 and length $_ <= 251 and ++$ok or push @failed, $_ 0 106 106
Condition33%2/6
length $_ >= 1 and length $_ <= 251 and ++$ok
!ll&&!rl&&r
00106
length $_ >= 1 and length $_ <= 251
!ll&&!rl&&r
00106
MC/DC0%0/3
length $_ >= 1 and length $_ <= 251 and ++$ok
length $_ >= 1 length $_ <= 251 ++$ok
Truth table25%1/4
A and B and C
A= length $_ >= 1B= length $_ <= 251C= ++$ok
ABCresult
0XX0
10X0
1100
1111
297 5 $tb->is_num( $ok, scalar @items, "All names correct for $theme" );
298 5 ▶ $tb->diag("Names too long: @failed") if @failed;
Branch: 1 branch
BranchTrueFalseTotal
if @failed 0 5 5
299 }
300 }
301  
302 # t/24data.t
303 sub subtest_data {
304 3 ▶ my ( $theme, $file ) = @_;
Subroutine subtest_data: called CC=2 SCAR=7.1
Pod documented
305 3 ▶ $file = '' if !defined $file;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 0 3 3
306 _check_file_lines(
307 $theme, $file,
308 "__DATA__ section for %s",
309 sub {
310 3 ▶ my @lines;
Subroutine __ANON__: called CC=6 SCAR=18.4
311 my $in_data;
312 3 for my $line (@_) {
313 528 ▶ $in_data++ if $line =~ /^__DATA__$/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^__DATA__$/ 1 527 528
314 528 ▶ next if !$in_data;
Branch: 1 branch
BranchTrueFalseTotal
unless $in_data 514 14 528
315 14 ▶ push @lines, $line
Branch: 1 branch
BranchTrueFalseTotal
if /^#/ and not /^# ?(?:names(?: +[-\w]+)*|default)\s*$/ 0 14 14
Condition33%1/3
/^#/ and not /^# ?(?:names(?: +[-\w]+)*|default)\s*$/
!ll&&!rl&&r
1400
MC/DC0%0/2
/^#/ and not /^# ?(?:names(?: +[-\w]+)*|default)\s*$/
/^#/ not /^# ?(?:names(?: +[-\w]+)*|default)\s*$/
Truth table33%1/3
A and not(B)
A= /^#/B= not /^# ?(?:names(?: +[-\w]+)*|default)\s*$/
ABresult
0X0
100
111
316 if /^#/ && !/^# ?(?:names(?: +[-\w]+)*|default)\s*$/;
317 }
318 3 return @lines;
319 }
320 3 );
321 }
322  
323 sub subtest_version {
324 3 ▶ my ($theme) = @_;
Subroutine subtest_version: called CC=2 SCAR=7.0
Pod documented
325 3 my $tb = __PACKAGE__->builder;
326 3 $tb->plan( tests => 1 );
327 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
328 3 ▶ my $version = "Acme::MetaSyntactic::$theme"->VERSION || '';
Condition50%1/2
("Acme::MetaSyntactic::$theme")->VERSION || ''
l!l
30
MC/DC0%0/1
("Acme::MetaSyntactic::$theme")->VERSION || ''
("Acme::MetaSyntactic::$theme")->VERSION
Truth table50%1/2
A
A= ("Acme::MetaSyntactic::$theme")->VERSION
Aresult
11
00
329 3 $tb->ok( $version, "$theme version $version" );
330 }
331  
332 # t/90up2date.t
333 3 my ($has_lwp, $has_test_diff, $has_network);
334 BEGIN {
335 3 ▶ $has_lwp = eval { require LWP::UserAgent; 1; };
Subroutine BEGIN: called CC=2 SCAR=7.4
336 3 ▶ $has_network = $has_lwp
Condition33%1/3
$has_lwp && 'LWP::UserAgent'->new('timeout', 5, 'env_proxy', 1)->get('http://www.google.com/intl/en/')->is_success
!ll&&!rl&&r
003
MC/DC0%0/2
$has_lwp && 'LWP::UserAgent'->new('timeout', 5, 'env_proxy', 1)->get('http://www.google.com/intl/en/')->is_success
$has_lwp 'LWP::UserAgent'->new('timeout', 5, 'env_proxy', 1)->get('http://www.google.com/intl/en/')->is_success
Truth table33%1/3
A && B
A= $has_lwpB= 'LWP::UserAgent'->new('timeout', 5, 'env_proxy', 1)->get('http://www.google.com/intl/en/')->is_success
ABresult
0X0
100
111
337 && LWP::UserAgent->new( timeout => 5, env_proxy => 1 )
338 ->get('http://www.google.com/intl/en/')
339 ->is_success;
340 };
341  
342 sub subtest_remote {
343 3 ▶ my ($theme) = @_;
Subroutine subtest_remote: called CC=16 SCAR=44.7
Pod documented
344 3 my $class = "Acme::MetaSyntactic::$theme";
345  
346 # find out if we're in one of the many cases for skipping
347 my $why
348 = !$ENV{RELEASE_TESTING}
349 && !$ENV{AUTHOR_TESTING} ? 'Remote list test is RELEASE_TESTING'
350 3 ▶ : $ENV{AUTOMATED_TESTING} ? "Remote list test isn't AUTOMATED_TESTING"
Branch: 5 branches
BranchTrueFalseTotal
!($ENV{'RELEASE_TESTING'} || $ENV{'AUTHOR_TESTING'}) ? : 3 0 3
$ENV{'AUTOMATED_TESTING'} ? : 0 0 0
!$class->has_remotelist ? : 0 0 0
!$has_lwp ? : 0 0 0
!$has_network ? : 0 0 0
Condition33%1/3
$ENV{'RELEASE_TESTING'} || $ENV{'AUTHOR_TESTING'}
l!l&&r!l&&!r
003
MC/DC0%0/2
$ENV{'RELEASE_TESTING'} || $ENV{'AUTHOR_TESTING'}
$ENV{'RELEASE_TESTING'} $ENV{'AUTHOR_TESTING'}
Truth table33%1/3
A || B
A= $ENV{'RELEASE_TESTING'}B= $ENV{'AUTHOR_TESTING'}
ABresult
1X1
011
000
351 : !$class->has_remotelist ? "Theme $theme does not have a remote list"
352 : !$has_lwp ? 'Remote list test needs LWP::UserAgent'
353 : !$has_network ? 'Remote list test needs network'
354 : '';
355  
356 3 my $tb = __PACKAGE__->builder;
357 3 my @metas = _theme_sublists($theme);
358 3 $tb->plan( tests => scalar @metas );
359  
360 SKIP: {
361 3 ▶ if ($why) {
Branch: 1 branch
BranchTrueFalseTotal
if ($why) 3 0 3
362 3 $tb->skip($why) for 1 .. @metas;
363 3 last SKIP;
364 }
365  
366  
367 0 for my $test (@metas) {
368 0 my ( $ams, $theme ) = @$test;
369  
370 3 ▶ no warnings 'utf8';
Subroutine BEGIN: called CC=1 SCAR=0.0
371 0 my $current = [ sort $ams->name(0) ];
372 0 my $remote = [ sort $ams->remote_list() ];
373  
374 0 ▶ if ( !@$remote ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@$remote) 0 0 0
375 0 $tb->skip("Fetching remote items for $theme probably failed");
376 0 next;
377 }
378  
379 # compare both lists
380 0 my %seen;
381 0 $seen{$_}++ for @$remote;
382 0 $seen{$_}-- for @$current;
383 0 ▶ $tb->ok( !grep( $_, values %seen ),
Branch: 1 branch
BranchTrueFalseTotal
$tb->ok(!grep($_, values %seen), "Local and remote lists are identical for $theme") or $tb->diag("Differences between local and remote list:") 0 0 0
384 "Local and remote lists are identical for $theme" )
385 or $tb->diag("Differences between local and remote list:");
386 $tb->diag( $seen{$_} > 0 ? "+ $_" : "- $_" )
387 0 ▶ for grep $seen{$_}, sort keys %seen;
Branch: 1 branch
BranchTrueFalseTotal
$seen{$_} > 0 ? : 0 0 0
388 }
389 }
390 }
391  
392 3 1;
393  
394 __END__
↑ Summary Acme/MetaSyntactic/Locale.pm »