NumSeq/OEIS/Catalogue/Plugin.pm

filter: Statementstmt 100% 36 / 36 Branchbran 100% 6 / 6 Conditioncond 87.5% 14 / 16 MC/DCmcdc 75.0% 6 / 8 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 6 totaltotal 87.6% 71 / 81 CC 13 SCAR 12.7
CC
13
Cov
97%
anum_after
5.0
anum_before
5.0
anum_to_info
4.0
CRAP 3.6
« NumSeq/Xenodromes.pm ↑ Summary NumSeq/ReReplace.pm »
1 # Copyright 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
2  
3 # This file is part of Math-NumSeq.
4 #
5 # Math-NumSeq is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Math-NumSeq is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
17  
18 package Math::NumSeq::OEIS::Catalogue::Plugin;
19 3 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 3 ▶use vars '$VERSION';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 $VERSION = 75;
24  
25 # uncomment this to run the ### lines
26 #use Smart::Comments;
27  
28 3 my %anum_to_info_hashref;
29 3 ▶sub anum_to_info_hashref {
Subroutine anum_to_info_hashref: called CC=2 SCAR=6.9
Pod undocumented
30 3 my ($class) = @_;
31 ### anum_to_info_hashref(): $class
32 return ($anum_to_info_hashref{$class} ||=
33 3 ▶ { map { $_->{'anum'} => $_ } @{$class->info_arrayref} });
Condition100%2/2
$anum_to_info_hashref{$class} ||= {map({$_->{"anum"}, $_;} @{$class->info_arrayref;})}
l!l
21
MC/DC100%1/1
$anum_to_info_hashref{$class} ||= {map({$_->{"anum"}, $_;} @{$class->info_arrayref;})}
$anum_to_info_hashref{$class}
Truth table100%2/2
A
A= $anum_to_info_hashref{$class}
Aresult
11
00
34 }
35  
36 2 ▶sub anum_to_info {
Subroutine anum_to_info: called CC=4 SCAR=13.9
Pod undocumented
37 2 my ($class, $anum) = @_;
38 2 ▶ foreach my $anum ($anum,
Branch: 1 branch
BranchTrueFalseTotal
$anum =~ /A0(\d{6})/ ? : 1 1 2
39 # A0123456 shortened to A123456
40 ($anum =~ /A0(\d{6})/ ? "A$1" : ())) {
41 3 ▶ return ($class->anum_to_info_hashref->{$anum} || next);
Condition100%2/2
$class->anum_to_info_hashref->{$anum} || (next)
l!l
21
MC/DC100%1/1
$class->anum_to_info_hashref->{$anum} || (next)
$class->anum_to_info_hashref->{$anum}
Truth table100%2/2
A
A= $class->anum_to_info_hashref->{$anum}
Aresult
11
00
42 }
43 }
44  
45 130 ▶sub anum_after {
Subroutine anum_after: called CC=5 SCAR=16.1
Pod undocumented
46 130 my ($class, $after_anum) = @_;
47 ### $after_anum
48 130 my $ret;
49 130 foreach my $info (@{$class->info_arrayref}) {
50 ### after info: $info
51 61555 ▶ if ($info->{'anum'} gt $after_anum
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"anum"} gt $after_anum and !defined($ret) || $ret gt $info->{"anum"}) 390 61165 61555
Condition83%5/6
$info->{"anum"} gt $after_anum and !defined($ret) || $ret gt $info->{"anum"}
!ll&&!rl&&r
061165390
not defined $ret or $ret gt $info->{"anum"}
l!l&&r!l&&!r
6532561165
MC/DC66%2/3
$info->{"anum"} gt $after_anum and !defined($ret) || $ret gt $info->{"anum"}
$info->{"anum"} gt $after_anum not defined $ret $ret gt $info->{"anum"}
Truth table75%3/4
A and not(B) or C
A= $info->{"anum"} gt $after_anumB= not defined $retC= $ret gt $info->{"anum"}
ABCresult
0XX0
1000
11X1
1011
52 && (! defined $ret || $ret gt $info->{'anum'})) {
53 390 $ret = $info->{'anum'};
54 }
55 }
56 130 return $ret;
57 }
58 130 ▶sub anum_before {
Subroutine anum_before: called CC=5 SCAR=16.1
Pod undocumented
59 130 my ($class, $before_anum) = @_;
60 ### $before_anum
61 130 my $ret;
62 130 foreach my $info (@{$class->info_arrayref}) {
63 61555 ▶ if ($info->{'anum'} lt $before_anum
Branch: 1 branch
BranchTrueFalseTotal
if ($info->{"anum"} lt $before_anum and !defined($ret) || $ret lt $info->{"anum"}) 715 60840 61555
Condition83%5/6
$info->{"anum"} lt $before_anum and !defined($ret) || $ret lt $info->{"anum"}
!ll&&!rl&&r
060840715
not defined $ret or $ret lt $info->{"anum"}
l!l&&r!l&&!r
6565060840
MC/DC66%2/3
$info->{"anum"} lt $before_anum and !defined($ret) || $ret lt $info->{"anum"}
$info->{"anum"} lt $before_anum not defined $ret $ret lt $info->{"anum"}
Truth table75%3/4
A and not(B) or C
A= $info->{"anum"} lt $before_anumB= not defined $retC= $ret lt $info->{"anum"}
ABCresult
0XX0
1000
11X1
1011
64 && (! defined $ret || $ret lt $info->{'anum'})) {
65 715 $ret = $info->{'anum'};
66 }
67 }
68 130 return $ret;
69 }
70  
71 195 ▶sub anum_first {
Subroutine anum_first: called CC=1 SCAR=0.0
Pod undocumented
72 195 my ($class) = @_;
73 195 return $class->anum_after ('A000000');
74 }
75 195 ▶sub anum_last {
Subroutine anum_last: called CC=1 SCAR=0.0
Pod undocumented
76 195 my ($class) = @_;
77 195 return $class->anum_before('A9999999'); # 7-digits
78 }
79  
80 3 1;
81 __END__
« NumSeq/Xenodromes.pm ↑ Summary NumSeq/ReReplace.pm »