Updated used ASTs for all XPath parser specs.
This commit is contained in:
1 parent
2298ef618b
commit
bb7af98257
4 files changed
+63
-54
No files matched your search
@@ -5,91 +5,91 @@ describe Oga::XPath::Parser do
|
||||
example 'parse the ancestor axis' do
|
||||
parse_xpath('/ancestor::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'ancestor', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'ancestor', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the ancestor-or-self axis' do
|
||||
parse_xpath('/ancestor-or-self::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'ancestor-or-self', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'ancestor-or-self', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the attribute axis' do
|
||||
parse_xpath('/attribute::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'attribute', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'attribute', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the child axis' do
|
||||
parse_xpath('/child::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'child', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'child', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the descendant axis' do
|
||||
parse_xpath('/descendant::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'descendant', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'descendant', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the descendant-or-self axis' do
|
||||
parse_xpath('/descendant-or-self::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'descendant-or-self', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'descendant-or-self', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the following axis' do
|
||||
parse_xpath('/following::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'following', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'following', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the following-sibling axis' do
|
||||
parse_xpath('/following-sibling::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'following-sibling', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'following-sibling', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the namespace axis' do
|
||||
parse_xpath('/namespace::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'namespace', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'namespace', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the parent axis' do
|
||||
parse_xpath('/parent::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'parent', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'parent', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the preceding axis' do
|
||||
parse_xpath('/preceding::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'preceding', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'preceding', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the preceding-sibling axis' do
|
||||
parse_xpath('/preceding-sibling::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'preceding-sibling', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'preceding-sibling', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the self axis' do
|
||||
parse_xpath('/self::A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'self', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'self', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
end
|
||||
@@ -98,28 +98,28 @@ describe Oga::XPath::Parser do
|
||||
example 'parse the @attribute axis' do
|
||||
parse_xpath('/@A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'attribute', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'attribute', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the // axis' do
|
||||
parse_xpath('//A').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'descendant-or-self', s(:name, nil, 'A')))
|
||||
s(:path, s(:axis, 'descendant-or-self', s(:test, nil, 'A')))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the .. axis' do
|
||||
parse_xpath('/..').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'parent'))
|
||||
s(:path, s(:axis, 'parent'))
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the . axis' do
|
||||
parse_xpath('/.').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:axis, 'self'))
|
||||
s(:path, s(:axis, 'self'))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,17 +3,17 @@ require 'spec_helper'
|
||||
describe Oga::XPath::Parser do
|
||||
context 'paths' do
|
||||
example 'parse an absolute path' do
|
||||
parse_xpath('/A').should == s(:absolute, s(:test, s(:name, nil, 'A')))
|
||||
parse_xpath('/A').should == s(:absolute, s(:path, s(:test, nil, 'A')))
|
||||
end
|
||||
|
||||
example 'parse a relative path' do
|
||||
parse_xpath('A').should == s(:test, s(:name, nil, 'A'))
|
||||
parse_xpath('A').should == s(:path, s(:test, nil, 'A'))
|
||||
end
|
||||
|
||||
example 'parse an expression using two paths' do
|
||||
parse_xpath('/A/B').should == s(
|
||||
:absolute,
|
||||
s(:test, s(:name, nil, 'A'), s(:test, s(:name, nil, 'B')))
|
||||
s(:path, s(:test, nil, 'A'), s(:path, s(:test, nil, 'B')))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,14 +6,18 @@ describe Oga::XPath::Parser do
|
||||
parse_xpath('/foo[@class="bar"]').should == s(
|
||||
:absolute,
|
||||
s(
|
||||
:test,
|
||||
s(:name, nil, 'foo'),
|
||||
:path,
|
||||
s(
|
||||
:predicate,
|
||||
:test,
|
||||
nil,
|
||||
'foo',
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:name, nil, 'class')),
|
||||
s(:string, 'bar')
|
||||
:path,
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:test, nil, 'class')),
|
||||
s(:string, 'bar')
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -24,21 +28,25 @@ describe Oga::XPath::Parser do
|
||||
parse_xpath('/foo[@class="bar" or @class="baz"]').should == s(
|
||||
:absolute,
|
||||
s(
|
||||
:test,
|
||||
s(:name, nil, 'foo'),
|
||||
:path,
|
||||
s(
|
||||
:predicate,
|
||||
:test,
|
||||
nil,
|
||||
'foo',
|
||||
s(
|
||||
:or,
|
||||
:path,
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:name, nil, 'class')),
|
||||
s(:string, 'bar')
|
||||
),
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:name, nil, 'class')),
|
||||
s(:string, 'baz')
|
||||
:or,
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:test, nil, 'class')),
|
||||
s(:string, 'bar')
|
||||
),
|
||||
s(
|
||||
:eq,
|
||||
s(:axis, 'attribute', s(:test, nil, 'class')),
|
||||
s(:string, 'baz')
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user