blib/lib/Math/GMP.pm

filter: Statementstmt 100% 49 / 49 Branchbran 75.0% 9 / 12 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 15 / 15 Podpod 100% 1 / 1 totaltotal 91.7% 78 / 85 CC 9 SCAR 8.2
CC
9
Cov
92%
import
4.2
new
4.0
__ANON__
2.1
CRAP 2.3
↑ Summary GMP.xs »
1 package Math::GMP;
2  
3 # Math::GMP, a Perl module for high-speed arbitrary size integer
4 # calculations
5 # Copyright (C) 2000-2008 James H. Turner
6 # Copyright (C) 2008-2009 Greg Sabino Mullane
7  
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Library General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
12  
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Library General Public License for more details.
17  
18 # You should have received a copy of the GNU Library General Public
19 # License along with this library; if not, write to the Free
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  
22 # You can contact the author at chip@redhat.com, chipt@cpan.org, or by mail:
23  
24 # Chip Turner
25 # Red Hat Inc.
26 # 2600 Meridian Park Blvd
27 # Durham, NC 27713
28  
29 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 5 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 5 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 5 ▶use vars qw(@ISA @EXPORT @EXPORT_OK $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
34  
35 use overload (
36 793 ▶ '""' => sub { stringify($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
37 47 ▶ '0+' => sub { $_[0] >= 0 ? uintify($_[0]) : intify($_[0]) },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[0] >= 0 ? : 47 0 47
38 4 ▶ 'bool' => sub { $_[0] != 0 },
Subroutine __ANON__: called CC=1 SCAR=0.0
39  
40 '<=>' => \&op_spaceship,
41 '==' => \&op_eq,
42  
43 '+' => \&op_add,
44 '-' => \&op_sub,
45  
46 '&' => \&band,
47 '^' => \&bxor,
48 '|' => \&bior,
49  
50 '<<' => \&blshift,
51 '>>' => \&brshift,
52  
53 '%' => \&op_mod,
54 2 ▶ '**' => sub { $_[2] ? op_pow($_[1], $_[0]) : op_pow($_[0], $_[1]) },
Subroutine __ANON__: called CC=2 SCAR=7.6
Branch: 1 branch
BranchTrueFalseTotal
$_[2] ? : 0 2 2
55 5 '*' => \&op_mul,
56 '/' => \&op_div,
57 5 ▶);
Subroutine BEGIN: called CC=1 SCAR=0.0
58  
59 5 require Exporter;
60 5 require DynaLoader;
61 5 require AutoLoader;
62  
63 5 @ISA = qw(Exporter DynaLoader);
64 # Items to export into callers namespace by default. Note: do not export
65 # names by default without a very good reason. Use EXPORT_OK instead.
66 # Do not simply export all your public functions/methods/constants.
67  
68 5 our $VERSION = '2.19';
69  
70  
71 5 bootstrap Math::GMP $VERSION;
72  
73 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
74 sub import {
75 4 ▶ shift;
Subroutine import: called CC=4 SCAR=14.3
76 4 ▶ return unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 3 1 4
77 1 ▶ die "unknown import: @_" unless @_ == 1 and $_[0] eq ':constant';
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 1 and $_[0] eq ":constant" 0 1 1
Condition33%1/3
@_ == 1 and $_[0] eq ":constant"
!ll&&!rl&&r
001
MC/DC0%0/2
@_ == 1 and $_[0] eq ":constant"
@_ == 1 $_[0] eq ":constant"
Truth table33%1/3
A and B
A= @_ == 1B= $_[0] eq ":constant"
ABresult
0X0
100
111
78 1 ▶ overload::constant integer => sub { Math::GMP->new(shift) };
Subroutine __ANON__: called CC=1 SCAR=0.0
79 1 return;
80 }
81  
82  
83 sub new {
84 1581 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=13.9
Pod documented
85 1581 ▶ my $ival = shift || 0;
Condition100%2/2
shift() || 0
l!l
151170
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
86 1581 my $base = shift;
87  
88 1581 $ival =~ s/\A\+//;
89 1581 $ival =~ tr/ _//d;
90 1581 ▶ if ($base) {
Branch: 1 branch
BranchTrueFalseTotal
if ($base) { } 2 1579 1581
91 2 return Math::GMP::new_from_scalar_with_base($ival, $base);
92 }
93 else {
94 1579 ▶ if ($ival =~ /[^\d\-xA-Fa-f]/)
Branch: 1 branch
BranchTrueFalseTotal
if ($ival =~ /[^\d\-xA-Fa-f]/) 1 1578 1579
95 {
96 1 die "Argument to Math::GMP->new is not a string representing an integer";
97 }
98 1578 return Math::GMP::new_from_scalar($ival);
99 }
100 }
101  
102 BEGIN
103 {
104 5 ▶ *DESTROY = \&Math::GMP::destroy;
Subroutine BEGIN: called CC=1 SCAR=0.0
105 5 *gcd = \&bgcd;
106 5 *lcm = \&blcm;
107 }
108  
109 __END__
↑ Summary GMP.xs »