blib/lib/Warnings/Version.pm

filter: Statementstmt 94.9% 56 / 59 Branchbran 66.6% 4 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 88.3% 68 / 77 CC 4 SCAR 5.6
CC
4
Cov
92%
get_warnings
3.0
import
2.0
unimport
2.0
CRAP 1.8
↑ Summary
1 46 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 46 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Warnings::Version;
4 46 $Warnings::Version::VERSION = '0.003002';
5 # ABSTRACT: Load warnings from a specific version of perl
6  
7 46 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 46 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 46 my %warnings;
12 46 $warnings{ categories } = [ qw/ all io severe syntax utf8 experimental / ];
13 46 $warnings{ all } = [ qw/ closure exiting glob io closed exec newline
14 pipe unopened misc numeric once overflow pack portable recursion redefine
15 regexp debugging inplace internal malloc signal substr syntax ambiguous
16 bareword deprecated digit parenthesis precedence printf prototype qw
17 reserved semicolon taint uninitialized unpack untie utf8 void / ];
18 46 $warnings{ '5.6' } = [ @{ $warnings{all} }, qw/ chmod umask y2k / ];
19 46 $warnings{ '5.8' } = [ @{ $warnings{all} }, qw/ layer threads y2k / ];
20 46 $warnings{ '5.10' } = [ @{ $warnings{all} }, qw/ layer threads / ];
21 46 $warnings{ '5.12' } = [ @{ $warnings{all} }, qw/ layer imprecision
22 illegalproto threads / ];
23 46 $warnings{ '5.14' } = [ @{ $warnings{all} }, qw/ layer imprecision
24 illegalproto threads surrogate non_unicode nonchar / ];
25 46 $warnings{ '5.16' } = [ @{ $warnings{all} }, qw/ layer imprecision
26 illegalproto threads surrogate non_unicode nonchar / ];
27 46 $warnings{ '5.18' } = [ @{ $warnings{all} }, qw/ experimental::lexical_subs
28 imprecision layer illegalproto threads non_unicode nonchar surrogate / ];
29 46 $warnings{ '5.20' } = [ @{ $warnings{all} }, qw/ experimental::autoderef
30 experimental::lexical_subs experimental::lexical_topic
31 experimental::postderef experimental::regex_sets experimental::signatures
32 experimental::smartmatch imprecision layer syscalls illegalproto threads
33 non_unicode nonchar surrogate / ];
34 46 $warnings{ '5.22' } = [ @{ $warnings{all} }, qw/ experimental::autoderef
35 experimental::bitwise experimental::const_attr experimental::lexical_subs
36 experimental::lexical_topic experimental::postderef experimental::re_strict
37 experimental::refaliasing experimental::regex_sets experimental::signatures
38 experimental::smartmatch experimental::win32_perlio imprecision layer
39 syscalls locale missing redundant illegalproto threads non_unicode nonchar
40 surrogate /];
41  
42  
43 45 ▶sub import {
Subroutine import: called CC=2 SCAR=7.0
44 45 my $package = shift;
45 45 my $version = shift;
46 45 ▶ $version = 'all' if not defined $version;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $version 0 45 45
47 45 warnings->import::into(scalar caller, get_warnings($version, $]));
48 }
49  
50 0 ▶sub unimport {
Subroutine unimport: not called CC=1 SCAR=6.9
51 0 my $package = shift;
52 0 my $version = shift;
53 0 warnings->unimport::from(scalar caller, get_warnings($version, $]));
54 }
55  
56 119 ▶sub get_warnings {
Subroutine get_warnings: called CC=3 SCAR=11.0
Pod undocumented
57 119 my $version = massage_version(shift);
58 119 my $perl_version = massage_version(shift);
59  
60 die "Unknown version: $version\n" unless defined
61 119 ▶ $warnings{ $version };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $warnings{$version} 0 119 119
62 die "Unknown perl version: $perl_version\n" unless defined
63 119 ▶ $warnings{ $perl_version };
Branch: 1 branch
BranchTrueFalseTotal
unless defined $warnings{$perl_version} 45 74 119
64  
65 74 my $wanted = $warnings{ $version };
66 74 my $available = $warnings{ $perl_version };
67  
68 74 return intersection( $wanted, $available );
69 }
70  
71 239 ▶sub massage_version {
Subroutine massage_version: called CC=1 SCAR=0.0
Pod undocumented
72 239 local $_ = shift;
73  
74 239 s/(5\.\d+)\..*/$1/;
75 239 s/(5\.\d\d\d).*/$1/;
76 239 s/(5\.)0*/$1/;
77  
78 239 return $_;
79 }
80  
81 74 ▶sub intersection {
Subroutine intersection: called CC=1 SCAR=0.0
Pod undocumented
82 74 my ($a1, $a2) = @_;
83 74 my %count;
84  
85 74 return grep { $count{$_}++ == 1 } @{ $a1 }, @{ $a2 };
86 }
87  
88  
89 46 1;
90  
91 __END__
↑ Summary