lib/HTML/Object/DOM/Number.pm

filter: Statementstmt 64.4% 38 / 59 Branchbran 20.0% 2 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 47.6% 10 / 21 Podpod 100% 8 / 8 totaltotal 56.3% 58 / 103 CC 7 SCAR 11.5
CC
7
Cov
56%
init
12.0
isSafeInteger
6.0
__ANON__
2.7
CRAP 3.2
« blib/lib/HTML/Object/DOM/Element/TableCell.pm ↑ Summary blib/lib/HTML/Object/XPath/Literal.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/Number.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/13
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::DOM::Number;
15 BEGIN
16 {
17 8 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 8 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 8 ▶ warnings::register_categories( 'HTML::Object' );
Subroutine BEGIN: called CC=2 SCAR=7.3
20 8 ▶ use parent qw( Module::Generic::Number );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 8 ▶ use vars qw( $EPSILON $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 8 ▶ use Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 # use Machine::Epsilon ();
24 8 require POSIX;
25 8 my( $POS_INF, $NEG_INF );
26 8 ▶ if( $] >= 5.022 )
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.022) { } 8 0 8
27 {
28 8 POSIX->import( qw( isnan ) );
29 # NOTE: Inf and NaN are bare literals since 5.8.1 and do not need importing.
30 # POSIX only added them as exports in 5.22, hence the version guard.
31 8 $POS_INF = 9**9**9;
32 8 $NEG_INF = -9**9**9;
33 }
34 else
35 {
36 0 $POS_INF = 9**9**9;
37 0 $NEG_INF = -9**9**9;
38 *isnan = sub
39 {
40 0 ▶ return(0) if( !defined( $_[0] ) );
Subroutine __ANON__: not called CC=2 SCAR=10.1
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 0 0 0
41 8 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
42 0 return( $_[0] != $_[0] );
43 0 };
44 }
45 use constant {
46 MAX_SAFE_INTEGER => (POSIX::pow(2,53) - 1),
47 # MAX_VALUE => (1.7976931348623157 * POSIX::pow(10,308)),
48 8 ▶ MAX_VALUE => (POSIX::pow(2, $Config::Config{use64bitint} eq 'define' ? 64 : 32)),
Branch: 1 branch
BranchTrueFalseTotal
$Config::Config{'use64bitint'} eq 'define' ? : 8 0 8
49 MIN_SAFE_INTEGER => (-(POSIX::pow(2,53) - 1)),
50 MIN_VALUE => POSIX::pow(2, -1074),
51 # <https://perldoc.perl.org/perldata#Special-floating-point:-infinity-(Inf)-and-not-a-number-(NaN)>
52 # NEGATIVE_INFINITY => -9**9**9,
53 NEGATIVE_INFINITY => $NEG_INF,
54 POSITIVE_INFINITY => $POS_INF,
55 8 ▶ };
Subroutine BEGIN: called CC=2 SCAR=6.9
56 8 our $EPSILON;
57 8 our $VERSION = 'v0.2.0';
58 };
59  
60 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
62  
63 sub init
64 {
65 0 ▶ my $self = shift( @_ );
Subroutine init: not called CC=3 SCAR=24.8
Pod documented
66 0 $self->{_init_strict_use_sub} = 1;
67 0 ▶ $self->SUPER::init( @_ ) || return( $self->pass_error );
Branch: 1 branch
BranchTrueFalseTotal
$self->SUPER::init(@_) or return $self->pass_error 0 0 0
68 # $EPSILON = Machine::Epsilon::machine_epsilon() if( !defined( $EPSILON ) );
69 0 ▶ $EPSILON = POSIX::pow(2,-52) if( !defined( $EPSILON ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $HTML::Object::DOM::Number::EPSILON 0 0 0
70 0 return( $self );
71 }
72  
73 # Note: property EPSILON
74 sub EPSILON : lvalue { return( shift->_lvalue({
75 get => sub
76 {
77 0 ▶ my $self = shift( @_ );
Subroutine __ANON__: not called CC=1 SCAR=6.9
78 0 return( $EPSILON );
79 },
80 set => sub
81 {
82 0 ▶ my( $self, $ref ) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
83 0 $EPSILON = shift( @$ref );
84 }
85 0 ▶}, @_ ) ); }
Subroutine EPSILON: not called CC=1 SCAR=6.9
Pod documented
86  
87 # Note: property MAX_SAFE_INTEGER is a constant
88  
89 # Note: property MAX_VALUE is a constant
90  
91 # Note: property MIN_SAFE_INTEGER is a constant
92  
93 # Note: property MIN_VALUE is a constant
94  
95 # Note: property NEGATIVE_INFINITY is a constant
96  
97 # Note: property POSITIVE_INFINITY is a constant
98  
99 8 my $POS_INF = POSITIVE_INFINITY;
100 0 ▶sub isFinite { return( $_[1] != $POS_INF ); }
Subroutine isFinite: not called CC=1 SCAR=6.9
Pod documented
101  
102 0 ▶sub isInteger { return( shift->_is_integer( $_[0] ) ); }
Subroutine isInteger: not called CC=1 SCAR=6.9
Pod documented
103  
104 0 ▶sub isNaN { return( isnan( $_[1] ) ); }
Subroutine isNaN: not called CC=1 SCAR=6.9
Pod documented
105  
106 0 ▶sub isSafeInteger { return( $_[0]->_is_integer( $_[1] ) && abs( $_[1] ) < MAX_SAFE_INTEGER ); }
Subroutine isSafeInteger: not called CC=2 SCAR=17.9
Pod documented
Condition0%0/3
$_[0]->_is_integer($_[1]) && abs $_[1] < 9007199254740991.0
!ll&&!rl&&r
000
MC/DC0%0/2
$_[0]->_is_integer($_[1]) && abs $_[1] < 9007199254740991.0
$_[0]->_is_integer($_[1]) abs $_[1] < 9007199254740991.0
Truth table0%0/3
A && B
A= $_[0]->_is_integer($_[1])B= abs $_[1] < 9007199254740991.0
ABresult
0X0
100
111
107  
108 0 ▶sub parseFloat { return( shift->new( shift( @_ ) ) ); }
Subroutine parseFloat: not called CC=1 SCAR=6.9
Pod documented
109  
110 0 ▶sub parseInt { return( shift->new( shift( @_ ) ) ); }
Subroutine parseInt: not called CC=1 SCAR=6.9
Pod documented
111  
112 8 1;
113 # NOTE: POD
114 __END__
« blib/lib/HTML/Object/DOM/Element/TableCell.pm ↑ Summary blib/lib/HTML/Object/XPath/Literal.pm »