Support for the XPath true()/false() functions.

This commit is contained in:
Yorick Peterse 2014-08-27 09:37:28 +02:00
parent 4ef79bad90
commit d2f991538d
3 changed files with 50 additions and 0 deletions

View File

@ -1074,6 +1074,30 @@ module Oga
return !on_call_boolean(context, expression)
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.
#

View File

@ -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

View File

@ -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