Support for the XPath true()/false() functions.
This commit is contained in:
parent
4ef79bad90
commit
d2f991538d
|
@ -1074,6 +1074,30 @@ module Oga
|
||||||
return !on_call_boolean(context, expression)
|
return !on_call_boolean(context, expression)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Processes the `true()` function call.
|
||||||
|
#
|
||||||
|
# This function simply returns the boolean `true`.
|
||||||
|
#
|
||||||
|
# @param [Oga::XPath::NodeSet] context
|
||||||
|
# @return [TrueClass]
|
||||||
|
#
|
||||||
|
def on_call_true(context)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Processes the `false()` function call.
|
||||||
|
#
|
||||||
|
# This function simply returns the boolean `false`.
|
||||||
|
#
|
||||||
|
# @param [Oga::XPath::NodeSet] context
|
||||||
|
# @return [FalseClass]
|
||||||
|
#
|
||||||
|
def on_call_false(context)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Processes an `(int)` node.
|
# Processes an `(int)` node.
|
||||||
#
|
#
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Oga::XPath::Evaluator do
|
||||||
|
context 'false() function' do
|
||||||
|
before do
|
||||||
|
@evaluator = described_class.new(parse(''))
|
||||||
|
end
|
||||||
|
|
||||||
|
example 'return false' do
|
||||||
|
@evaluator.evaluate('false()').should == false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,13 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Oga::XPath::Evaluator do
|
||||||
|
context 'true() function' do
|
||||||
|
before do
|
||||||
|
@evaluator = described_class.new(parse(''))
|
||||||
|
end
|
||||||
|
|
||||||
|
example 'return true' do
|
||||||
|
@evaluator.evaluate('true()').should == true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue