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