| 1 | ##---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ## HTML Object - ~/lib/HTML/Object/XPath/Expr.pm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ## Version v0.2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | ## Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | ## Author: Jacques Deguest <jack@deguest.jp> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ## Created 2021/12/05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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::XPath::Expr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 12 | ▶ | warnings::register_categories( 'HTML::Object' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 12 | ▶ | use parent qw( Module::Generic ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 12 | ▶ | use vars qw( $TRUE $FALSE $BASE_CLASS $DEBUG $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 12 | ▶ | use HTML::Object::XPath::Boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 12 | our $TRUE = HTML::Object::XPath::Boolean->True; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 12 | our $FALSE = HTML::Object::XPath::Boolean->False; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 12 | our $BASE_CLASS = 'HTML::Object::XPath'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 12 | our $DEBUG = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 12 | our $VERSION = 'v0.2.0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 239 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # XPath Parser -> HTML::Object::XPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 239 | my $pp = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 239 | $self->{pp} = $pp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 239 | $self->{predicates} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 239 | $self->{_init_strict_use_sub} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 239 | ▶ | $self->SUPER::init( @_ ) || return( $self->pass_error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 239 | return( $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # Use of uninitialized value! grrr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # local $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | my $string = '(' . $self->{lhs}->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $string .= ' ' . $self->{op} . ' ' if( defined( $self->{op} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | $string .= $self->{rhs}->as_string if( defined( $self->{rhs} ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $string .= ')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | foreach my $predicate ( @{$self->{predicates}} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $string .= '[' . $predicate->as_string . ']'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | return( $string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | sub as_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_xml: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # Use of uninitialized value! grrr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # local $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | my $string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if( defined( $self->{op} ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $string .= $self->op_xml(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $string .= $self->{lhs}->as_xml(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | foreach my $predicate ( @{$self->{predicates}} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $string .= "<Predicate>\n" . $predicate->as_xml() . "</Predicate>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return( $string ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub evaluate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 614 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
evaluate: called CC=6 SCAR=18.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # HTML::Object::XPath::NodeSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 614 | my $node = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # If there's an op, result is result of that op. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # If no op, just resolve Expr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # warn "Evaluate Expr: ", $self->as_string, "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 614 | my $results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 614 | ▶ | if( $self->{op} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 162 | ▶ | die( "No RHS of ", $self->as_string ) unless( $self->{rhs} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 162 | $results = $self->op_eval( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # HTML::Object::XPath::LocationPath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 452 | $results = $self->{lhs}->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 608 | ▶ | if( !$self->predicates->is_empty ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 2 | ▶ | if( !$self->_is_a( $results => 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | die( "Can't have predicates execute on object type: " . ref( $results ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # filter initial nodeset by each predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | foreach my $predicate ( @{$self->{predicates}} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 2 | $results = $self->filter_by_predicate( $results, $predicate ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 608 | return( $results ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | sub filter_by_predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter_by_predicate: called CC=8 SCAR=24.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my( $nodeset, $predicate ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # See spec section 2.4, paragraphs 2 & 3: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # For each node in the node-set to be filtered, the predicate Expr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # is evaluated with that node as the context node, with the number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # of nodes in the node set as the context size, and with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | # proximity position of the node in the node set with respect to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # the axis as the context position. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # use ref because nodeset has a bool context | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | if( !ref( $nodeset ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | die( "No nodeset!!!" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # warn "Filter by predicate: $predicate\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 2 | my $newset = $self->new_nodeset->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 2 | ▶ | for( my $i = 1; $i <= $nodeset->size; $i++ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # set context set each time 'cos a loc-path in the expr could change it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 18 | $self->{pp}->_set_context_set( $nodeset ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 18 | $self->{pp}->_set_context_pos( $i ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 18 | my $result = $predicate->evaluate( $nodeset->get_node( $i ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 18 | ▶ | if( $self->_is_a( $result => 'HTML::Object::XPath::Boolean' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if( $result->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $newset->push( $nodeset->get_node( $i ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | elsif( $self->_is_a( $result => 'HTML::Object::XPath::Number' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 18 | ▶ | if( $result->value == $i ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | $newset->push( $nodeset->get_node( $i ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if( $result->to_boolean->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $newset->push( $nodeset->get_node( $i ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | return( $newset ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub get_lhs { return( $_[0]->{lhs} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_lhs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | sub get_rhs { return( $_[0]->{rhs} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_rhs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | sub get_op { return( $_[0]->{op} ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_op: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub new_literal { return( shift->_class_for( 'Literal' )->new( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_literal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | ▶ | sub new_nodeset { return( shift->_class_for( 'NodeSet' )->new( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_nodeset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | sub new_number { return( shift->_class_for( 'Number' )->new( @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | sub op_and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 10 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_and: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 10 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 10 | ▶ | if( ! $lhs->evaluate( $node )->to_boolean->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 10 | return( $rhs->evaluate( $node )->to_boolean ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | sub op_div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_div: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my $result = eval{ $lh_results->to_number->value / $rh_results->to_number->value; }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if( $@ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # assume divide by zero | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # This is probably a terrible way to handle this! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # Ah well... who wants to live forever... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return( $self->new_literal( 'Infinity' ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | return( $self->new_number( $result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | sub op_equals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 99 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_equals: called CC=26 SCAR=45.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 99 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 99 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 99 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 96 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
Truth table66%2/3
A and B
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # True if and only if there is a node in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # first set and a node in the second set such | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # that the result of performing the comparison | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # on the string-values of the two nodes is true. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | foreach my $lhnode ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | foreach my $rhnode ( $rh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | if( $lhnode->string_value eq $rhnode->string_value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ▶ | elsif( ( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition55%5/9
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet") or $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet') && $rh_results->isa('HTML::Object::XPath::NodeSet')
MC/DC25%1/4
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet')
$rh_results->isa('HTML::Object::XPath::NodeSet')
Truth table28%2/7
A or B and not(C && D)
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")C= $lh_results->isa('HTML::Object::XPath::NodeSet')D= $rh_results->isa('HTML::Object::XPath::NodeSet')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | ( !$lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | !$rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # (that says: one is a nodeset, and one is not a nodeset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 89 | my( $nodeset, $other ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 89 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 89 | $nodeset = $lh_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 89 | $other = $rh_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $nodeset = $rh_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $other = $lh_results; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | # True if and only if there is a node in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | # nodeset such that the result of performing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # the comparison on <type>(string_value($node)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | # is true. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 89 | ▶ | if( $self->_is_a( $other => 'HTML::Object::XPath::Number' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 5 | foreach my $node ( $nodeset->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 5 | ▶ | if( $node->string_value == $other->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 3 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | elsif( $self->_is_a( $other => 'HTML::Object::XPath::Literal' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 84 | foreach my $node ( $nodeset->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 59 | ▶ | if( $node->string_value eq $other->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 35 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | elsif( $self->_is_a( $other => 'HTML::Object::XPath::Boolean' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | if( $nodeset->to_boolean->value == $other->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 51 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # Neither is a nodeset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 7 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::Boolean' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
$lh_results->isa("HTML::Object::XPath::Boolean")
$rh_results->isa("HTML::Object::XPath::Boolean")
Truth table33%1/3
A or B
A= $lh_results->isa("HTML::Object::XPath::Boolean")B= $rh_results->isa("HTML::Object::XPath::Boolean")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $rh_results->isa( 'HTML::Object::XPath::Boolean' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # if either is a boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if( $lh_results->to_boolean->value == $rh_results->to_boolean->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | ▶ | elsif( $lh_results->isa( 'HTML::Object::XPath::Number' ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$lh_results->isa("HTML::Object::XPath::Number") or $rh_results->isa("HTML::Object::XPath::Number")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::Number") or $rh_results->isa("HTML::Object::XPath::Number")
$lh_results->isa("HTML::Object::XPath::Number")
$rh_results->isa("HTML::Object::XPath::Number")
Truth table33%1/3
A or B
A= $lh_results->isa("HTML::Object::XPath::Number")B= $rh_results->isa("HTML::Object::XPath::Number")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | $rh_results->isa( 'HTML::Object::XPath::Number' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | # if either is a number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | # 'number' might result in undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 7 | local $^W; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 7 | ▶ | if ($lh_results->to_number->value == $rh_results->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 3 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 4 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if( $lh_results->to_literal->value eq $rh_results->to_literal->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | sub op_eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 162 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_eval: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 162 | my $node = shift( @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 162 | my $op = $self->{op}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 162 | my $map = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 'or' => 'op_or', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 'and' => 'op_and', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | '=~' => 'op_match', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | '!~' => 'op_not_match', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | '=' => 'op_equals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | '!=' => 'op_nequals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | '<=' => 'op_le', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | '>=' => 'op_ge', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | '>' => 'op_gt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | '<' => 'op_lt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | '+' => 'op_plus', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | '-' => 'op_minus', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 'div' => 'op_div', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 'mod' => 'op_mod', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | '*' => 'op_mult', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | '|' => 'op_union', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 162 | ▶ | die( "No such operator, or operator unimplemented in ", $self->as_string, "\n" ) if( !CORE::exists( $map->{ $op } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 162 | my $mod = $map->{ $op }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 162 | return( $self->$mod( $node, $self->{lhs}, $self->{rhs} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | sub op_ge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_ge: not called CC=19 SCAR=59.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
Truth table0%0/3
A and B
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | foreach my $lhnode ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | foreach my $rhnode ( $rh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $lhNum = $self->new_number( $lhnode->string_value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my $rhNum = $self->new_number( $rhnode->string_value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | if( $lhNum->value >= $rhNum->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ▶ | elsif( ( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet") or $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet') && $rh_results->isa('HTML::Object::XPath::NodeSet')
MC/DC0%0/4
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet')
$rh_results->isa('HTML::Object::XPath::NodeSet')
Truth table0%0/7
A or B and not(C && D)
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")C= $lh_results->isa('HTML::Object::XPath::NodeSet')D= $rh_results->isa('HTML::Object::XPath::NodeSet')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | ( !$lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | !$rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | # (that says: one is a nodeset, and one is not a nodeset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | foreach my $node ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if( $node->to_number->value >= $rh_results->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | foreach my $node ( $rh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if( $lh_results->to_number->value >= $node->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # Neither is a nodeset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::Boolean' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
$lh_results->isa("HTML::Object::XPath::Boolean")
$rh_results->isa("HTML::Object::XPath::Boolean")
Truth table0%0/3
A or B
A= $lh_results->isa("HTML::Object::XPath::Boolean")B= $rh_results->isa("HTML::Object::XPath::Boolean")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | $rh_results->isa( 'HTML::Object::XPath::Boolean' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # if either is a boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if( $lh_results->to_boolean->to_number->value >= $rh_results->to_boolean->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if( $lh_results->to_number->value >= $rh_results->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | sub op_gt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_gt: called CC=19 SCAR=50.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 1 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::NodeSet") and $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
Truth table33%1/3
A and B
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | foreach my $lhnode ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | foreach my $rhnode ( $rh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | my $lhNum = $self->new_number( $lhnode->string_value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | my $rhNum = $self->new_number( $rhnode->string_value ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | if( $lhNum->value > $rhNum->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | ▶ | elsif( ( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition22%2/9
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet") or $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet') && $rh_results->isa('HTML::Object::XPath::NodeSet')
MC/DC0%0/4
$lh_results->isa("HTML::Object::XPath::NodeSet") || $rh_results->isa("HTML::Object::XPath::NodeSet") and not $lh_results->isa("HTML::Object::XPath::NodeSet") && $rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa("HTML::Object::XPath::NodeSet")
$rh_results->isa("HTML::Object::XPath::NodeSet")
$lh_results->isa('HTML::Object::XPath::NodeSet')
$rh_results->isa('HTML::Object::XPath::NodeSet')
Truth table14%1/7
A or B and not(C && D)
A= $lh_results->isa("HTML::Object::XPath::NodeSet")B= $rh_results->isa("HTML::Object::XPath::NodeSet")C= $lh_results->isa('HTML::Object::XPath::NodeSet')D= $rh_results->isa('HTML::Object::XPath::NodeSet')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ( !$lh_results->isa( 'HTML::Object::XPath::NodeSet' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | !$rh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # (that says: one is a nodeset, and one is not a nodeset) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | foreach my $node ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if( $node->to_number->value > $rh_results->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | foreach my $node ( $rh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | if( $lh_results->to_number->value > $node->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | # Neither is a nodeset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 1 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::Boolean' ) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
MC/DC0%0/2
$lh_results->isa("HTML::Object::XPath::Boolean") or $rh_results->isa("HTML::Object::XPath::Boolean")
$lh_results->isa("HTML::Object::XPath::Boolean")
$rh_results->isa("HTML::Object::XPath::Boolean")
Truth table33%1/3
A or B
A= $lh_results->isa("HTML::Object::XPath::Boolean")B= $rh_results->isa("HTML::Object::XPath::Boolean")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | $rh_results->isa( 'HTML::Object::XPath::Boolean' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # if either is a boolean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if( $lh_results->to_boolean->value > $rh_results->to_boolean->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | ▶ | if( $lh_results->to_number->value > $rh_results->to_number->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | sub op_le | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_le: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return( $self->op_ge( $node, $rhs, $lhs ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | sub op_lt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_lt: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | return( $self->op_gt( $node, $rhs, $lhs ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | sub op_match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 47 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_match: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 47 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 47 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 47 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 47 | my $rh_value = $rh_results->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 47 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 47 | foreach my $lhnode ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | # / is important here, regexp is / delimited | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 21 | ▶ | if( $lhnode->string_value =~ m/$rh_value/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 12 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 35 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | return( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | ▶ | $lh_results->string_value =~ m/$rh_value/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | ? $TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | : $FALSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | sub op_minus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_minus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my $result = $lh_results->to_number->value - $rh_results->to_number->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | return( $self->new_number( $result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | sub op_mod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_mod: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $result = $lh_results->to_number->value % $rh_results->to_number->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | return( $self->new_number( $result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | sub op_mult | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_mult: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | my $result = $lh_results->to_number->value * $rh_results->to_number->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | return( $self->new_number( $result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | sub op_nequals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_nequals: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | if( $self->op_equals( $node, $lhs, $rhs)->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | sub op_not_match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_not_match: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | my $rh_value = $rh_results->string_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | if( $lh_results->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | foreach my $lhnode ( $lh_results->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | if( $lhnode->string_value !~ m/$rh_value/ ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | return( $FALSE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | return( $lh_results->string_value !~ m/$rh_value/ ? $TRUE : $FALSE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | sub op_or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 5 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_or: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 5 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 5 | ▶ | if( $lhs->evaluate( $node )->to_boolean->value ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 5 | return( $TRUE ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | return $rhs->evaluate( $node )->to_boolean; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | sub op_plus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_plus: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $lh_results = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | my $rh_results = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | my $result = $lh_results->to_number->value + $rh_results->to_number->value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | return( $self->new_number( $result ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | sub op_union | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_union: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my( $node, $lhs, $rhs ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my $lh_result = $lhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my $rh_result = $rhs->evaluate( $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | ▶ | if( $lh_result->isa( 'HTML::Object::XPath::NodeSet' ) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$lh_result->isa("HTML::Object::XPath::NodeSet") and $rh_result->isa("HTML::Object::XPath::NodeSet")
MC/DC0%0/2
$lh_result->isa("HTML::Object::XPath::NodeSet") and $rh_result->isa("HTML::Object::XPath::NodeSet")
$lh_result->isa("HTML::Object::XPath::NodeSet")
$rh_result->isa("HTML::Object::XPath::NodeSet")
Truth table0%0/3
A and B
A= $lh_result->isa("HTML::Object::XPath::NodeSet")B= $rh_result->isa("HTML::Object::XPath::NodeSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | $rh_result->isa( 'HTML::Object::XPath::NodeSet' ) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my %found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | my $results = $self->new_nodeset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | foreach my $lhnode ( $lh_result->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | $found{ "$lhnode" }++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | $results->push( $lhnode ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | foreach my $rhnode ( $rh_result->get_nodelist ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | $results->push( $rhnode ) unless( exists( $found{ "$rhnode" } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | return( $results->sort->remove_duplicates ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | die( "Both sides of a union must be Node Sets\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | sub op_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
op_xml: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | my $op = $self->{op}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | my $map = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 'and' => 'And', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 'div' => 'Div', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 'mod' => 'Mod', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 'or' => 'Or', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | '=' => 'Equals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | '!=' => 'NotEquals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | '<=' => 'LessThanOrEquals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | '>=' => 'GreaterThanOrEquals', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | '>' => 'GreaterThan', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | '<' => 'LessThan', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | '+' => 'Plus', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | '-' => 'Minus', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | '*' => 'Multiply', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | '|' => 'Union', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | die( "No tag equivalent for operator \"$op\".\n" ) if( !CORE::exists( $map->{ $op } ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | my $tag = $map->{ $op }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | return( "<$tag>\n" . $self->{lhs}->as_xml() . $self->{rhs}->as_xml() . "</$tag>\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 612 | ▶ | sub predicates { return( shift->_set_get_array_as_object( 'predicates', @_ ) ); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
predicates: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | sub push_predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_predicate: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 2 | ▶ | die( "Only 1 predicate allowed on FilterExpr in W3C XPath 1.0" ) if( @{$self->{predicates}} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | # push( @{$self->{predicates}}, $_[0] ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 2 | $self->predicates->push( $_[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # Need to return $self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # return( $self ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | return( $self->predicates->length ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | sub set_lhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 176 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_lhs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 176 | $self->{lhs} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | sub set_op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 28 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_op: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 28 | $self->{op} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | sub set_rhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 28 | ▶ | my $self = shift( @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_rhs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 28 | $self->{rhs} = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | sub _class_for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 2 | ▶ | my( $self, $mod ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_class_for: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 2 | eval( "require ${BASE_CLASS}\::${mod};" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 2 | ▶ | die( $@ ) if( $@ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | # ${"${BASE_CLASS}\::${mod}\::DEBUG"} = $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | ▶ | eval( "\$${BASE_CLASS}\::${mod}\::DEBUG = " . ( $DEBUG // 0 ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$HTML::Object::XPath::Expr::DEBUG // 0
MC/DC0%0/1
$HTML::Object::XPath::Expr::DEBUG // 0
$HTML::Object::XPath::Expr::DEBUG
Truth table50%1/2
A
A= $HTML::Object::XPath::Expr::DEBUG
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 2 | return( "${BASE_CLASS}::${mod}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | # NOTE: POD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | HTML::Object::XPath::Expr - HTML Object XPath Expression | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | use HTML::Object::XPath::Expr; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | my $this = HTML::Object::XPath::Expr->new || die( HTML::Object::XPath::Expr->error, "\n" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | v0.2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | This modules represents an L<HTML::Object::XPath> expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | Provided with an L<HTML::Object::XPath> object and this returns a new L<HTML::Object::XPath::Expr> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | =head2 as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | Returns the expression as a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | =head2 as_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | Returns the expression as xml. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | =head2 evaluate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | Provided with a L<HTML::Object::XPath::NodeSet> object, and this will call L</op_eval> with an L<operator|/op> has been set, otherwise, it calls L<HTML::Object::XPath::LocationPath/evaluate> passing it the node set. It returns the result from either call. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | =head2 filter_by_predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | This takes a nodeset object and a predicate. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | For each node in the node-set to be filtered, the predicate Expr is evaluated with that node as the context node, with the number of nodes in the node set as the context size, and with the proximity position of the node in the node set with respect to the axis as the context position. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | It returns a new L<node set|HTML::Object::XPath::NodeSet> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | =head2 get_lhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | Returns the L<HTML::Object::XPath::LocationPath> object for the left-hand side of the expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | =head2 get_rhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | Returns the L<HTML::Object::XPath::LocationPath> object for the right-hand side of the expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | =head2 get_op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | Returns the current operator set for this expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | =head2 new_literal | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | Returns a new L<literal object|HTML::Object::XPath::Literal>, passing it whatever argument was provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | =head2 new_nodeset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | Returns a new L<node set object|HTML::Object::XPath::NodeSet>, passing it whatever argument was provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | =head2 new_number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | Returns a new L<number object|HTML::Object::XPath::Number>, passing it whatever argument was provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | =head2 op_and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will evaluate the node using the left-hand side LocationPath object, and return L<false|HTML::Object::XPath::Boolean> if it failed, or otherwise it wil evaluate the node using the right-hand side LocationPath object and return its result. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | =head2 op_div | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will attempt to divide the left-hand value by the right-hand value. If ther eis an error, it returns L<infinity|HTML::Object::XPath::Number>, otherwise it returns the value from the division as a L<number object|HTML::Object::XPath::Number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | =head2 op_equals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side LocationPath is equal tot he right-hand side LocationPath. Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | =head2 op_eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | This method will evaluate the L<node|HTML::Object::ELement> provided with the left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> object also specified by calling the appropriate method in this module based on the operator value set with L</op> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | =head2 op_ge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side is greater or equal to the right-hand side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | =head2 op_gt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side is greater than the right-hand side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | =head2 op_le | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side is lower or equal than the right-hand side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | =head2 op_lt | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side is lower than the right-hand side. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | =head2 op_match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side match the right-hand side as a regular expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | =head2 op_minus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will subtract the right-hand side from the left-hand side and return the result as a L<number object|HTML::Object::XPath::Number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | =head2 op_mod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will get the modulo between the left-hand side and the right-hand side and return the result as a L<number object|HTML::Object::XPath::Number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | =head2 op_mult | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will multiply the right-hand side by the left-hand side and return the result as a L<number object|HTML::Object::XPath::Number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | =head2 op_nequals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will return L<true|HTML::Object::XPath::Boolean> if the left-hand side is not equal to the right-hand side, or L<false|HTML::Object::XPath::Boolean> otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | =head2 op_not_match | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will check if the left-hand side does B<not> match the right-hand side as a regular expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | Returns L<true|HTML::Object::XPath::Boolean> or L<false|HTML::Object::XPath::Boolean> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | =head2 op_or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will evaluate the node using the left-hand side LocationPath and return L<true|HTML::Object::XPath::Boolean> if it worked, or otherwise return the value from evaluating the node using the right-hand side LocationPath. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | =head2 op_plus | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will add the right-hand side to the left-hand side and return the result as a L<number object|HTML::Object::XPath::Number>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | =head2 op_union | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | Provided a L<node object|HTML::Object:Element>, a left-hand side and right-hand side L<LocationPath objects|HTML::Object::XPath::LocationPath> and this will evaluate the node both by the left-hand side and right-hand side LocationPath and return a new L<node set array object|HTML::Object::XPath::NodeSet> containing all the unique nodes resulting from those both evaluation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | =head2 op_xml | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | Provided with an operator and this returns its xml equivalent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | Operators supported are: C<and>, C<div>, C<mod>, C<or>, C<=>, C<!=>, C<<=>, C<>=>, C<>>, C<<>, C<+>, C<->, C<*>, C<|> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | They will be converted respectively to: C<And>, C<Div>, C<Mod>, C<Or>, C<Equals>, C<NotEquals>, C<LessThanOrEquals>, C<GreaterThanOrEquals>, C<GreaterThan>, C<LessThan>, C<Plus>, C<Minus>, C<Multiply>, C<Union> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | =head2 predicates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | Set or get the predicates as an L<array object|Module::Generic::Array> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | =head2 push_predicate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | Add the predicate to the list and will raise an exception if more than one predicate was provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | =head2 set_lhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | Set the left-hand side L<LocationPath|HTML::Object::XPath::LocationPath> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | =head2 set_op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | Set the operator for this expression. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | =head2 set_rhs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | Set the right-hand side L<LocationPath|HTML::Object::XPath::LocationPath> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | Jacques Deguest E<lt>F<jack@deguest.jp>E<gt> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | L<HTML::Object::XPath>, L<HTML::Object::XPath::Boolean>, L<HTML::Object::XPath::Expr>, L<HTML::Object::XPath::Function>, L<HTML::Object::XPath::Literal>, L<HTML::Object::XPath::LocationPath>, L<HTML::Object::XPath::NodeSet>, L<HTML::Object::XPath::Number>, L<HTML::Object::XPath::Root>, L<HTML::Object::XPath::Step>, L<HTML::Object::XPath::Variable> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | Copyright(c) 2021 DEGUEST Pte. Ltd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | All rights reserved | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||