blib/lib/Math/Int64.pm

filter: Statementstmt 93.8% 46 / 49 Branchbran 75.0% 6 / 8 Conditioncond 55.5% 5 / 9 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 11 / 11 Podpod n/a totaltotal 84.1% 69 / 82 CC 9 SCAR 12.8
CC
9
Cov
86%
import
6.2
_check_pragma_compatibility
5.5
BEGIN
1.0
CRAP 3.6
↑ Summary blib/lib/Math/Int64/native_if_available.pm »
1 package Math::Int64;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 our $VERSION = '0.57';
8  
9 9 require XSLoader;
10 9 XSLoader::load('Math::Int64', $VERSION);
11 }
12  
13 9 ▶use warnings::register;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 9 ▶use constant MAX_INT64 => string_to_int64 ( '0x7fff_ffff_ffff_ffff');
Subroutine BEGIN: called CC=1 SCAR=0.0
16 9 ▶use constant MIN_INT64 => string_to_int64 ('-0x8000_0000_0000_0000');
Subroutine BEGIN: called CC=1 SCAR=0.0
17 9 ▶use constant MAX_UINT64 => string_to_uint64( '0xffff_ffff_ffff_ffff');
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 9 require Exporter;
20 9 our @ISA = qw(Exporter);
21 9 our @EXPORT_OK = qw(int64
22 int64_to_number
23 net_to_int64 int64_to_net
24 le_to_int64 int64_to_le
25 native_to_int64 int64_to_native
26 string_to_int64 hex_to_int64
27 BER_to_int64 int64_to_BER
28 int64_to_string int64_to_hex
29 int64_rand
30 int64_srand
31 uint64
32 uint64_to_number
33 net_to_uint64 uint64_to_net
34 le_to_uint64 uint64_to_le
35 native_to_uint64 uint64_to_native
36 string_to_uint64 hex_to_uint64
37 BER_to_uint64 uint64_to_BER
38 uint64_to_string uint64_to_hex
39 uint64_rand
40 BER_length
41 MAX_INT64 MIN_INT64 MAX_UINT64
42 );
43  
44 9 my %available_pragmas = map { $_ => 1 } qw(native_if_available
45 die_on_overflow);
46  
47 9 ▶sub import {
Subroutine import: called CC=6 SCAR=18.3
48 9 my $pkg = shift;
49 9 my (%pragmas, @subs, %native);
50 9 for (@_) {
51 59 ▶ if ($_ =~ /^:(.*)/ and $available_pragmas{$1}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_ =~ /^:(.*)/ and $available_pragmas{$1}) { } 2 57 59
Condition66%2/3
$_ =~ /^:(.*)/ and $available_pragmas{$1}
!ll&&!rl&&r
5702
MC/DC50%1/2
$_ =~ /^:(.*)/ and $available_pragmas{$1}
$_ =~ /^:(.*)/ $available_pragmas{$1}
Truth table66%2/3
A and B
A= $_ =~ /^:(.*)/B= $available_pragmas{$1}
ABresult
0X0
100
111
52 2 $pragmas{$1} = 1
53 }
54 else {
55 57 push @subs, $_;
56 }
57 }
58  
59 9 ▶ if ($pragmas{die_on_overflow}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pragmas{"die_on_overflow"}) 0 9 9
60 0 require Math::Int64::die_on_overflow;
61 0 Math::Int64::die_on_overflow->import;
62 }
63  
64 9 ▶ if ($pragmas{native_if_available}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pragmas{"native_if_available"}) 2 7 9
65 2 require Math::Int64::native_if_available;
66 2 Math::Int64::native_if_available->import;
67 }
68  
69 9 Math::Int64->export_to_level(1, $pkg, @subs);
70 }
71  
72 3 ▶sub _check_pragma_compatibility {
Subroutine _check_pragma_compatibility: called CC=4 SCAR=17.1
73 3 ▶ if ($^H{'Math::Int64::native_if_available'} and
Branch: 1 branch
BranchTrueFalseTotal
if ($^H{"Math::Int64::native_if_available"} and $^H{"Math::Int64::die_on_overflow"} and warnings::enabled()) 0 3 3
Condition50%3/6
$^H{"Math::Int64::native_if_available"} and $^H{"Math::Int64::die_on_overflow"} and warnings::enabled()
!ll&&!rl&&r
300
$^H{"Math::Int64::native_if_available"} and $^H{"Math::Int64::die_on_overflow"}
!ll&&!rl&&r
120
MC/DC0%0/3
$^H{"Math::Int64::native_if_available"} and $^H{"Math::Int64::die_on_overflow"} and warnings::enabled()
$^H{"Math::Int64::native_if_available"} $^H{"Math::Int64::die_on_overflow"} warnings::enabled()
Truth table50%2/4
A and B and C
A= $^H{"Math::Int64::native_if_available"}B= $^H{"Math::Int64::die_on_overflow"}C= warnings::enabled()
ABCresult
0XX0
10X0
1100
1111
74 $^H{'Math::Int64::die_on_overflow'} and
75 warnings::enabled()) {
76 0 warnings::warn("Math::Int64::die_on_overflow pragma is useless when Math::Int64::native_if_available is also active");
77 }
78 3 1;
79 }
80  
81 9 ▶use overload ( '+' => \&_add,
Subroutine BEGIN: called CC=1 SCAR=0.0
82 '+=' => \&_add,
83 '-' => \&_sub,
84 '-=' => \&_sub,
85 '*' => \&_mul,
86 '*=' => \&_mul,
87 '**' => \&_pow,
88 '**=' => \&_pow,
89 '/' => \&_div,
90 '/=' => \&_div,
91 '%' => \&_rest,
92 '%=' => \&_rest,
93 'neg' => \&_neg,
94 '++' => \&_inc,
95 '--' => \&_dec,
96 '!' => \&_not,
97 '~' => \&_bnot,
98 '&' => \&_and,
99 '|' => \&_or,
100 '^' => \&_xor,
101 '<<' => \&_left,
102 '>>' => \&_right,
103 '<=>' => \&_spaceship,
104 '>' => \&_gtn,
105 '<' => \&_ltn,
106 '>=' => \&_gen,
107 '<=' => \&_len,
108 '==' => \&_eqn,
109 '!=' => \&_nen,
110 'bool' => \&_bool,
111 '0+' => \&_number,
112 '""' => \&_string,
113 '=' => \&_clone,
114 9 fallback => 1 );
115  
116 package # hide from PAUSE since it also has its own .pm file
117 Math::UInt64;
118 9 ▶use overload ( '+' => \&_add,
Subroutine BEGIN: called CC=1 SCAR=0.0
119 '+=' => \&_add,
120 '-' => \&_sub,
121 '-=' => \&_sub,
122 '*' => \&_mul,
123 '*=' => \&_mul,
124 '**' => \&_pow,
125 '**=' => \&_pow,
126 '/' => \&_div,
127 '/=' => \&_div,
128 '%' => \&_rest,
129 '%=' => \&_rest,
130 'neg' => \&_neg,
131 '++' => \&_inc,
132 '--' => \&_dec,
133 '!' => \&_not,
134 '~' => \&_bnot,
135 '&' => \&_and,
136 '|' => \&_or,
137 '^' => \&_xor,
138 '<<' => \&_left,
139 '>>' => \&_right,
140 '<=>' => \&_spaceship,
141 '>' => \&_gtn,
142 '<' => \&_ltn,
143 '>=' => \&_gen,
144 '<=' => \&_len,
145 '==' => \&_eqn,
146 '!=' => \&_nen,
147 'bool' => \&_bool,
148 '0+' => \&_number,
149 '""' => \&_string,
150 '=' => \&_clone,
151 9 fallback => 1 );
152  
153 9 1;
154  
155 # ABSTRACT: Manipulate 64 bits integers in Perl
156  
157 __END__
↑ Summary blib/lib/Math/Int64/native_if_available.pm »