From 6c0c5ab7209717e496bb74d90a27278aaa3d17a3 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 25 Aug 2014 23:14:22 +0200 Subject: [PATCH] Revert "Return XPath integers as actual integers." The particular case of string(10) having to return "10" instead of "10.0" will be handled separately. Returning integers breaks behaviour/expectations elsewhere. This reverts commit 431a253000cf2444785db0e12f1ce57e3742e312. --- lib/oga/xpath/evaluator.rb | 2 +- spec/oga/xpath/evaluator/calls/string_spec.rb | 2 +- spec/oga/xpath/evaluator/types/int_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 33a7aa2..28b8204 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -967,7 +967,7 @@ module Oga # @return [Float] # def on_int(ast_node, context) - return ast_node.children[0] + return ast_node.children[0].to_f end ## diff --git a/spec/oga/xpath/evaluator/calls/string_spec.rb b/spec/oga/xpath/evaluator/calls/string_spec.rb index c09e310..b45b543 100644 --- a/spec/oga/xpath/evaluator/calls/string_spec.rb +++ b/spec/oga/xpath/evaluator/calls/string_spec.rb @@ -37,7 +37,7 @@ describe Oga::XPath::Evaluator do end example 'convert an integer to a string' do - @evaluator.evaluate('string(10)').should == '10' + @evaluator.evaluate('string(10)').should == '10.0' end example 'convert a float to a string' do diff --git a/spec/oga/xpath/evaluator/types/int_spec.rb b/spec/oga/xpath/evaluator/types/int_spec.rb index e2f01ad..7321f2f 100644 --- a/spec/oga/xpath/evaluator/types/int_spec.rb +++ b/spec/oga/xpath/evaluator/types/int_spec.rb @@ -12,8 +12,8 @@ describe Oga::XPath::Evaluator do @number.should == 1 end - example 'return integers as Fixnums' do - @number.is_a?(Fixnum).should == true + example 'return integers as floats' do + @number.is_a?(Float).should == true end end end