array on 1.9 mode breaks Nokogiri test. ---------------------------------------
Key: JRUBY-5657 URL: http://jira.codehaus.org/browse/JRUBY-5657 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Affects Versions: JRuby 1.6 Environment: OSX 10.6.7, JDK 1.6.0_24 Reporter: Yoko Harada MRI 1.9.2 and JRuby 1.8.6 passes test_each of test/xml/test_node.rb, but JRuby 1.9.2 fails. The failing test is below. To see what's going on, I added some print lines: {noformat} def test_each attributes = [] @xml.xpath('//address')[1].each do |key, value| puts "key: #{key.inspect}, value: #{value.inspect}" attributes << [key, value] end assert_equal [['domestic', 'Yes'], ['street', 'Yes']], attributes end {noformat} Nokogiri defines the "each" method above in xml/node.rb as in below. Also, I added print lines to see what is happening: {noformat} def each &block attribute_nodes.each { |node| p node p node.node_name, node.value ret = block.call([node.node_name, node.value]) p 'ret', ret ret } end {noformat} when the test ran, MRI 1.9.2 produced: {noformat} /Users/yoko/Documents/workspace/Peony/test/helper.rb:10: version info: {"warnings"=>[], "nokogiri"=>"1.5.0.beta.4", "ruby"=>{"version"=>"1.9.2", "platform"=>"x86_64-darwin10.5.0", "engine"=>"ruby"}, "libxml"=>{"binding"=>"extension", "compiled"=>"2.7.8", "loaded"=>"2.7.8"}} Run options: --seed 13537 # Running tests: .................................................................................................#<Nokogiri::XML::Attr:0x80cee4d0 name="domestic" value="Yes"> "domestic" "Yes" key: "domestic", value: "Yes" "ret" [["domestic", "Yes"]] #<Nokogiri::XML::Attr:0x80cee4bc name="street" value="Yes"> "street" "Yes" key: "street", value: "Yes" "ret" [["domestic", "Yes"], ["street", "Yes"]] ....... Finished tests in 0.091298s, 1139.1268 tests/s, 2650.6605 assertions/s. 104 tests, 242 assertions, 0 failures, 0 errors, 0 skips {noformat} JRuby 1.8.7 produced: {noformat} /Users/yoko/Documents/workspace/Peony/test/helper.rb:10: version info: {"warnings"=>[], "nokogiri"=>"1.5.0.beta.4", "ruby"=>{"version"=>"1.8.7", "platform"=>"java", "engine"=>"jruby", "jruby"=>"1.6.0"}} Run options: --seed 56660 # Running tests: ............................................#<Nokogiri::XML::Attr:0x7d0 name="domestic" value="Yes"> "domestic" "Yes" key: "domestic", value: "Yes" "ret" [["domestic", "Yes"]] #<Nokogiri::XML::Attr:0x7d2 name="street" value="Yes"> "street" "Yes" key: "street", value: "Yes" "ret" [["domestic", "Yes"], ["street", "Yes"]] ........................................................... Finished tests in 2.423000s, 42.5093 tests/s, 98.2253 assertions/s. 103 tests, 238 assertions, 0 failures, 0 errors, 0 skips {noformat} Both passed the test, but JRuby 1.9.2 produced: {noformat} /Users/yoko/Documents/workspace/Peony/test/helper.rb:10: version info: {"warnings"=>[], "nokogiri"=>"1.5.0.beta.4", "ruby"=>{"version"=>"1.9.2", "platform"=>"java", "engine"=>"jruby", "jruby"=>"1.6.0"}} Run options: --seed 22326 # Running tests: .............................................................#<Nokogiri::XML::Attr:0x7fc name="domestic" value="Yes"> "domestic" "Yes" key: ["domestic", "Yes"], value: nil "ret" [[["domestic", "Yes"], nil]] #<Nokogiri::XML::Attr:0x7fe name="street" value="Yes"> "street" "Yes" key: ["street", "Yes"], value: nil "ret" [[["domestic", "Yes"], nil], [["street", "Yes"], nil]] F......................................... Finished tests in 2.474000s, 41.6330 tests/s, 96.2005 assertions/s. 1) Failure: test_each(Nokogiri::XML::TestNode) [test/xml/test_node.rb:555]: Expected [["domestic", "Yes"], ["street", "Yes"]], not [[["domestic", "Yes"], nil], [["street", "Yes"], nil]]. 103 tests, 238 assertions, 1 failures, 0 errors, 0 skips {noformat} So, the argument of the block.call([node.node_name, node.value]) becames key: "domestic", value: "Yes" on MRI and JRuby 1.8.7, but key: ["domestic", "Yes"], value: nil on JRuby 1.9.2. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email