XPathEngine/Number.pm

filter: Statementstmt 78.3% 29 / 37 Branchbran 50.0% 5 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 78.5% 11 / 14 Podpod 100% 10 / 10 totaltotal 77.4% 55 / 71 CC 6 SCAR 8.9
CC
6
Cov
72%
as_xml
6.0
xpath_cmp
6.0
as_string
2.1
CRAP 2.4
« XPathEngine/LocationPath.pm ↑ Summary XPathEngine/Boolean.pm »
1 # $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/Number.pm 17 2006-02-12T08:00:01.814064Z mrodrigu $
2  
3 package Tree::XPathEngine::Number;
4 6 ▶use Tree::XPathEngine::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Tree::XPathEngine::Literal;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use overload
9 6 ▶ '""' => \&value,
Subroutine BEGIN: called CC=1 SCAR=0.0
10 '0+' => \&value,
11 6 '<=>' => \&xpath_cmp;
12  
13 318 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
14 318 my $class = shift;
15 318 my $number = shift;
16 318 ▶ if ($number !~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $number =~ /^\s*[+-]?(\d+(\.\d*)?|\.\d+)\s*$/) { } 25 293 318
17 25 $number = undef;
18 }
19 else {
20 293 $number =~ s/^\s*(.*)\s*$/$1/;
21 }
22 318 bless \$number, $class;
23 }
24  
25 7 ▶sub as_string {
Subroutine as_string: called CC=2 SCAR=7.2
Pod documented
26 7 my $self = shift;
27 7 ▶ defined $$self ? $$self : 'NaN';
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 7 0 7
28 }
29  
30 0 ▶sub as_xml {
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod documented
31 0 my $self = shift;
32 0 ▶ return "<Number>" . (defined($$self) ? $$self : 'NaN') . "</Number>\n";
Branch: 1 branch
BranchTrueFalseTotal
defined $$self ? : 0 0 0
33 }
34  
35 551 ▶sub value {
Subroutine value: called CC=1 SCAR=0.0
Pod documented
36 551 my $self = shift;
37 551 $$self;
38 }
39  
40 0 ▶sub xpath_cmp {
Subroutine xpath_cmp: not called CC=2 SCAR=17.9
Pod documented
41 0 my $self = shift;
42 0 my ($other, $swap) = @_;
43 0 ▶ if ($swap) {
Branch: 1 branch
BranchTrueFalseTotal
if ($swap) 0 0 0
44 0 return $other <=> $$self;
45 }
46 0 return $$self <=> $other;
47 }
48  
49 325 ▶sub evaluate {
Subroutine evaluate: called CC=1 SCAR=0.0
Pod documented
50 325 my $self = shift;
51 325 $self;
52 }
53  
54 2 ▶sub xpath_to_boolean {
Subroutine xpath_to_boolean: called CC=2 SCAR=6.9
Pod documented
55 2 my $self = shift;
56 2 ▶ return $$self ? Tree::XPathEngine::Boolean->_true : Tree::XPathEngine::Boolean->_false;
Branch: 1 branch
BranchTrueFalseTotal
$$self ? : 1 1 2
57 }
58  
59 7 ▶sub xpath_to_literal { Tree::XPathEngine::Literal->new($_[0]->as_string); }
Subroutine xpath_to_literal: called CC=1 SCAR=0.0
Pod documented
60 282 ▶sub xpath_to_number { $_[0]; }
Subroutine xpath_to_number: called CC=1 SCAR=0.0
Pod documented
61  
62 0 ▶sub xpath_string_value { return $_[0]->value }
Subroutine xpath_string_value: not called CC=1 SCAR=6.9
Pod documented
63  
64 6 1;
65 __END__
« XPathEngine/LocationPath.pm ↑ Summary XPathEngine/Boolean.pm »