blib/lib/Math/Factor/XS.pm

filter: Statementstmt 93.0% 40 / 43 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 92.3% 12 / 13 Podpod 100% 1 / 1 totaltotal 92.0% 58 / 63 CC 4 SCAR 3.8
CC
4
Cov
92%
__ANON__
2.1
__ANON__
2.0
__ANON__
2.0
CRAP 1.5
↑ Summary lib/Math/Factor/XS.xs »
1 package Math::Factor::XS;
2  
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use boolean qw(true);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use List::MoreUtils qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use Params::Validate ':all';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 our ($VERSION, @EXPORT_OK, %EXPORT_TAGS);
14 3 $VERSION = '0.40';
15 3 @EXPORT_OK = qw(factors matches prime_factors count_prime_factors);
16 3 %EXPORT_TAGS = (all => \@EXPORT_OK);
17  
18 validation_options(
19 on_fail => sub
20 0 ▶{
Subroutine __ANON__: not called CC=1 SCAR=6.9
21 0 my ($error) = @_;
22 0 chomp $error;
23 0 croak $error;
24 3 });
25  
26 my $positive_nums = sub
27 5 ▶{
Subroutine __ANON__: called CC=2 SCAR=7.0
28 31 ▶ all { looks_like_number($_) && ($_ >= 0) }
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
&looks_like_number($_) and $_ >= 0 31 0 31
29 5 ▶ ref $_[0] ? @{$_[0]} : ($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 2 3 5
30 3 };
31  
32 sub matches
33 3 ▶{
Subroutine matches: called CC=1 SCAR=0.0
Pod documented
34 validate_pos(@_,
35 { type => SCALAR,
36 callbacks => {
37 'is a positive number' =>
38 $positive_nums,
39 },
40 },
41 { type => ARRAYREF,
42 callbacks => {
43 'factors are positive numbers' => sub
44 3 ▶ {
Subroutine __ANON__: called CC=2 SCAR=6.9
45 3 my $factors = shift;
46 3 ▶ !@$factors or $positive_nums->($factors);
Branch: 1 branch
BranchTrueFalseTotal
not @$factors or &$positive_nums($factors) 1 2 3
47 },
48 },
49 },
50 3 { type => HASHREF,
51 optional => true,
52 },
53 );
54 3 return xs_matches(@_);
55 }
56  
57 3 require XSLoader;
58 3 XSLoader::load(__PACKAGE__, $VERSION);
59  
60 3 1;
61 __END__
↑ Summary lib/Math/Factor/XS.xs »