XPathEngine/LocationPath.pm

filter: Statementstmt 57.1% 16 / 28 Branchbran 12.5% 1 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 4 / 4 totaltotal 53.3% 24 / 45 CC 6 SCAR 17.8
CC
6
Cov
47%
as_string
12.0
as_xml
6.0
evaluate
3.0
CRAP 5.9
« XPathEngine/Function.pm ↑ Summary XPathEngine/Number.pm »
1 # $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/LocationPath.pm 22 2006-02-13T14:00:25.731780Z mrodrigu $
2  
3 package Tree::XPathEngine::LocationPath;
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 155 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
7 155 my $class = shift;
8 155 my $self = [];
9 155 bless $self, $class;
10 }
11  
12 0 ▶sub as_string {
Subroutine as_string: not called CC=3 SCAR=24.8
Pod documented
13 0 my $self = shift;
14 0 my $string;
15 0 ▶ for (my $i = 0; $i < @$self; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$self) 0 0 0
16 0 $string .= $self->[$i]->as_string;
17 0 ▶ $string .= "/" if $self->[$i+1];
Branch: 1 branch
BranchTrueFalseTotal
if $$self[$i + 1] 0 0 0
18 }
19 0 return $string;
20 }
21  
22 0 ▶sub as_xml {
Subroutine as_xml: not called CC=2 SCAR=17.9
Pod documented
23 0 my $self = shift;
24 0 my $string = "<LocationPath>\n";
25  
26 0 ▶ for (my $i = 0; $i < @$self; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$self) 0 0 0
27 0 $string .= $self->[$i]->as_xml;
28 }
29  
30 0 $string .= "</LocationPath>\n";
31 0 return $string;
32 }
33  
34  
35 640 ▶sub evaluate {
Subroutine evaluate: called CC=3 SCAR=11.0
Pod documented
36 640 my $self = shift;
37 # context _MUST_ be a single node
38 640 my $context = shift;
39 640 ▶ die "No context" unless $context;
Branch: 1 branch
BranchTrueFalseTotal
unless $context 0 640 640
40
41 # I _think_ this is how it should work :)
42
43 640 my $nodeset = Tree::XPathEngine::NodeSet->new();
44 640 $nodeset->push($context);
45
46 640 foreach my $step (@$self) {
47 # For each step
48 # evaluate the step with the nodeset
49 904 my $pos = 1;
50 904 $nodeset = $step->evaluate($nodeset);
51 }
52
53 638 return $nodeset->remove_duplicates;
54 }
55  
56 6 1;
57  
58 __END__
« XPathEngine/Function.pm ↑ Summary XPathEngine/Number.pm »