summaryrefslogtreecommitdiff
path: root/test/rexml
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-19 21:34:40 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-19 21:34:40 +0000
commit9090241e614d3c5b302b713041164e27929f8898 (patch)
tree4441d9db2b7172064402741a39d329a8bf741e7f /test/rexml
parent632e10cad3935ad0152204d21b80b90c4906e753 (diff)
rexml: Fix a XPath bug that white spaces aren't ignored
lib/rexml/parsers/xpathparser.rb: Ignore white spaces in relative location path. test/rexml/xpath/test_base.rb: Add more test patterns and use more debug friendly assertion style. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml')
-rw-r--r--test/rexml/xpath/test_base.rb51
1 files changed, 29 insertions, 22 deletions
diff --git a/test/rexml/xpath/test_base.rb b/test/rexml/xpath/test_base.rb
index f71be51e2fc..935c8d54e40 100644
--- a/test/rexml/xpath/test_base.rb
+++ b/test/rexml/xpath/test_base.rb
@@ -632,29 +632,36 @@ module REXMLTests
<c id='a'/>
</b>
<c id='b'/>
+ <c id='c'/>
+ <c/>
</a>")
- assert_equal( 1, REXML::XPath.match(doc,
- "//*[local-name()='c' and @id='b']").size )
- assert_equal( 1, REXML::XPath.match(doc,
- "//*[ local-name()='c' and @id='b' ]").size )
- assert_equal( 1, REXML::XPath.match(doc,
- "//*[ local-name() = 'c' and @id = 'b' ]").size )
- assert_equal( 1,
- REXML::XPath.match(doc, '/a/c[@id]').size )
- assert_equal( 1,
- REXML::XPath.match(doc, '/a/c[(@id)]').size )
- assert_equal( 1,
- REXML::XPath.match(doc, '/a/c[ @id ]').size )
- assert_equal( 1,
- REXML::XPath.match(doc, '/a/c[ (@id) ]').size )
- assert_equal( 1,
- REXML::XPath.match(doc, '/a/c[( @id )]').size )
- assert_equal( 1, REXML::XPath.match(doc.root,
- '/a/c[ ( @id ) ]').size )
- assert_equal( 1, REXML::XPath.match(doc,
- '/a/c [ ( @id ) ] ').size )
- assert_equal( 1, REXML::XPath.match(doc,
- ' / a / c [ ( @id ) ] ').size )
+ match = lambda do |xpath|
+ REXML::XPath.match(doc, xpath).collect(&:to_s)
+ end
+ assert_equal(["<c id='b'/>"],
+ match.call("//*[local-name()='c' and @id='b']"))
+ assert_equal(["<c id='b'/>"],
+ match.call("//*[ local-name()='c' and @id='b' ]"))
+ assert_equal(["<c id='b'/>"],
+ match.call("//*[ local-name() = 'c' and @id = 'b' ]"))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[@id]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[(@id)]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[ @id ]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[ (@id) ]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[( @id )]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c[ ( @id ) ]'))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/a/c [ ( @id ) ] '))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call(' / a / c [ ( @id ) ] '))
+ assert_equal(["<c id='b'/>", "<c id='c'/>"],
+ match.call('/ a / child:: c [( @id )] /'))
end
def test_text_nodes