* lib/rexml/xpath_parser.rb, test/rexml/test_xpath.rb:
add missing method availability check. [ruby-core:32447] Reported by Wiebe Cazemier. Thanks!!! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7bf12316a1
commit
d8c3fa1506
@ -1,3 +1,9 @@
|
|||||||
|
Fri Sep 17 23:44:07 2010 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rexml/xpath_parser.rb, test/rexml/test_xpath.rb:
|
||||||
|
add missing method availability check. [ruby-core:32447]
|
||||||
|
Reported by Wiebe Cazemier. Thanks!!!
|
||||||
|
|
||||||
Fri Sep 17 23:23:26 2010 Kouhei Sutou <kou@cozmixng.org>
|
Fri Sep 17 23:23:26 2010 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* test/rexml/test_sax.rb: don't use thread and sleep to avoid slow test.
|
* test/rexml/test_sax.rb: don't use thread and sleep to avoid slow test.
|
||||||
|
@ -434,7 +434,8 @@ module REXML
|
|||||||
when :and
|
when :and
|
||||||
left = expr( path_stack.shift, nodeset.dup, context )
|
left = expr( path_stack.shift, nodeset.dup, context )
|
||||||
#puts "LEFT => #{left.inspect} (#{left.class.name})"
|
#puts "LEFT => #{left.inspect} (#{left.class.name})"
|
||||||
if left == false || left.nil? || !left.inject(false) {|a,b| a | b}
|
return [] unless left
|
||||||
|
if left.respond_to?(:inject) and !left.inject(false) {|a,b| a | b}
|
||||||
return []
|
return []
|
||||||
end
|
end
|
||||||
right = expr( path_stack.shift, nodeset.dup, context )
|
right = expr( path_stack.shift, nodeset.dup, context )
|
||||||
|
@ -1053,4 +1053,27 @@ EOF
|
|||||||
r = REXML::XPath.match( d, %q{/a/b[c='3']} )
|
r = REXML::XPath.match( d, %q{/a/b[c='3']} )
|
||||||
assert_equal(1, r.size())
|
assert_equal(1, r.size())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_or_and
|
||||||
|
doc = "
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>test</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>
|
||||||
|
A <a rel=\"sub\" href=\"/\">link</a>.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"
|
||||||
|
|
||||||
|
xmldoc = REXML::Document.new(doc)
|
||||||
|
xpath = "descendant::node()[(local-name()='link' or local-name()='a') and @rel='sub']"
|
||||||
|
hrefs = []
|
||||||
|
xmldoc.elements.each(xpath) do |element|
|
||||||
|
hrefs << element.attributes["href"]
|
||||||
|
end
|
||||||
|
assert_equal(["/"], hrefs, "Bug #3842 [ruby-core:32447]")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user