Project

General

Profile

Bug #14263 » array_intersection.rb

Failing array intersection test - gkellogg (Gregg Kellogg), 12/31/2017 09:58 PM

 
# Demonstrates that [Var.new('a')] & [Var.new('b')] is not empty when #eql? is true and hash comparison fails in Ruby 2.5.0. Works in Ruby 2.4.2.
# The documentation for Array#& says it uses both hash and eql?, but it seems to not be true in Ruby 2.5.0
class Var
attr_reader :v

def initialize(v)
@v = v
end

def eql?(other)
true
end

def hash
v.hash
end
end

if ([Var.new('a')] & [Var.new('b')]).empty?
puts "success: RUBY_VERSION: #{RUBY_VERSION}"
else
puts "failure: RUBY_VERSION: #{RUBY_VERSION}"
end
(1-1/4)