Better XPath evaluation tests for numbers.
This commit is contained in:
		
							parent
							
								
									bcd138a15a
								
							
						
					
					
						commit
						564f8859a0
					
				| 
						 | 
					@ -3,17 +3,20 @@ require 'spec_helper'
 | 
				
			||||||
describe Oga::XPath::Evaluator do
 | 
					describe Oga::XPath::Evaluator do
 | 
				
			||||||
  context 'float types' do
 | 
					  context 'float types' do
 | 
				
			||||||
    before do
 | 
					    before do
 | 
				
			||||||
      document  = parse('<a></a>')
 | 
					      document   = parse('<a></a>')
 | 
				
			||||||
      evaluator = described_class.new(document)
 | 
					      @evaluator = described_class.new(document)
 | 
				
			||||||
      @number   = evaluator.evaluate('1.2')
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    example 'return literal integers' do
 | 
					    example 'return a float' do
 | 
				
			||||||
      @number.should == 1.2
 | 
					      @evaluator.evaluate('1.2').should == 1.2
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    example 'return integers as floats' do
 | 
					    example 'return a negative float' do
 | 
				
			||||||
      @number.is_a?(Float).should == true
 | 
					      @evaluator.evaluate('-1.2').should == -1.2
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    example 'return floats as a Float' do
 | 
				
			||||||
 | 
					      @evaluator.evaluate('1.2').is_a?(Float).should == true
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,17 +3,20 @@ require 'spec_helper'
 | 
				
			||||||
describe Oga::XPath::Evaluator do
 | 
					describe Oga::XPath::Evaluator do
 | 
				
			||||||
  context 'integer types' do
 | 
					  context 'integer types' do
 | 
				
			||||||
    before do
 | 
					    before do
 | 
				
			||||||
      document  = parse('<a></a>')
 | 
					      document   = parse('<a></a>')
 | 
				
			||||||
      evaluator = described_class.new(document)
 | 
					      @evaluator = described_class.new(document)
 | 
				
			||||||
      @number   = evaluator.evaluate('1')
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    example 'return literal integers' do
 | 
					    example 'return an integer' do
 | 
				
			||||||
      @number.should == 1
 | 
					      @evaluator.evaluate('1').should == 1
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    example 'return integers as floats' do
 | 
					    example 'return a negative integer' do
 | 
				
			||||||
      @number.is_a?(Float).should == true
 | 
					      @evaluator.evaluate('-2').should == -2
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    example 'return integers as a Float' do
 | 
				
			||||||
 | 
					      @evaluator.evaluate('1').is_a?(Float).should == true
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue