Added failing descendant-or-self XPath specs.
These currently fail due to the child:: selector not working entirely as it should be. Consider the following XML: <a><b><b><c class="x"></c></b></b></a> And the following XPath: descendant-or-self::node()/a In Nokogiri/libxml this will return a node set containing the <a> node. In Oga however this will return an empty node set. This will require some further investigation to see what exactly is going on, and in particular what is the correct behaviour.
This commit is contained in:
parent
83e6138f2f
commit
f6319ed0c7
|
@ -40,6 +40,32 @@ describe Oga::XPath::Evaluator do
|
|||
end
|
||||
end
|
||||
|
||||
context 'chained descendants' do
|
||||
before do
|
||||
@set = @evaluator.evaluate(
|
||||
'descendant-or-self::a/descendant-or-self::*'
|
||||
)
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 4
|
||||
|
||||
example 'return the <a> node' do
|
||||
@set[0].should == @first_a
|
||||
end
|
||||
|
||||
example 'return the first <b> node' do
|
||||
@set[1].should == @first_b
|
||||
end
|
||||
|
||||
example 'return the second <b> node' do
|
||||
@set[2].should == @second_b
|
||||
end
|
||||
|
||||
example 'return the <c> node' do
|
||||
@set[3].should == @first_c
|
||||
end
|
||||
end
|
||||
|
||||
context 'nested descendants with a matching predicate' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('descendant-or-self::c[@class="x"]')
|
||||
|
@ -139,5 +165,37 @@ describe Oga::XPath::Evaluator do
|
|||
@set[0].should == @first_c
|
||||
end
|
||||
end
|
||||
|
||||
context 'descendants of descendants usign the short form' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('//a//*')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 3
|
||||
|
||||
example 'return the first <b> node' do
|
||||
@set[0].should == @first_b
|
||||
end
|
||||
|
||||
example 'return the second <b> node' do
|
||||
@set[1].should == @second_b
|
||||
end
|
||||
|
||||
example 'return the <c> node' do
|
||||
@set[2].should == @first_c
|
||||
end
|
||||
end
|
||||
|
||||
context 'children of descendants using the short form' do
|
||||
before do
|
||||
@set = @evaluator.evaluate('//a/b')
|
||||
end
|
||||
|
||||
it_behaves_like :node_set, :length => 1
|
||||
|
||||
example 'return the first <b> node' do
|
||||
@set[0].should == @first_b
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue