File Coverage

blib/lib/Tree/XPathEngine/Boolean.pm
Criterion Covered Total %
statement 23 29 79.3
branch 1 4 25.0
condition n/a
subroutine 10 12 83.3
pod 6 6 100.0
total 40 51 78.4


line stmt bran cond sub pod time code
1             # $Id: /tree-xpathengine/trunk/lib/Tree/XPathEngine/Boolean.pm 17 2006-02-12T08:00:01.814064Z mrodrigu $
2              
3             package Tree::XPathEngine::Boolean;
4 5     5   2830 use Tree::XPathEngine::Number;
  5         20  
  5         124  
5 5     5   33 use Tree::XPathEngine::Literal;
  5         11  
  5         88  
6 5     5   28 use strict;
  5         10  
  5         242  
7              
8             use overload
9 5         35 '""' => \&value,
10 5     5   26 '<=>' => \&xpath_cmp;
  5         10  
11              
12             sub _true {
13 352     352   534 my $class = shift;
14 352         501 my $val = 1;
15 352         2202 bless \$val, $class;
16             }
17              
18             sub _false {
19 495     495   662 my $class = shift;
20 495         643 my $val = 0;
21 495         2746 bless \$val, $class;
22             }
23              
24             sub value {
25 896     896 1 1402 my $self = shift;
26 896         4655 $$self;
27             }
28              
29             sub xpath_cmp {
30 0     0 1 0 my $self = shift;
31 0         0 my ($other, $swap) = @_;
32 0 0       0 if ($swap) {
33 0         0 return $other <=> $$self;
34             }
35 0         0 return $$self <=> $other;
36             }
37              
38 8     8 1 26 sub xpath_to_number { Tree::XPathEngine::Number->new($_[0]->value); }
39 47     47 1 157 sub xpath_to_boolean { $_[0]; }
40 18 50   18 1 58 sub xpath_to_literal { Tree::XPathEngine::Literal->new($_[0]->value ? "true" : "false"); }
41              
42 0     0 1   sub xpath_string_value { return $_[0]->xpath_to_literal->value; }
43              
44             1;
45             __END__