Bug #7676 ยป bug-7676.patch
array.c | ||
---|---|---|
len1 = RARRAY_LEN(ary1);
|
||
for (i = 0; i < len1; i++) {
|
||
if (*p1 != *p2) {
|
||
if (rb_equal(*p1, *p2)) {
|
||
len1 = RARRAY_LEN(ary1);
|
||
if (len1 != RARRAY_LEN(ary2))
|
||
return Qfalse;
|
||
if (len1 < i)
|
||
return Qtrue;
|
||
p1 = RARRAY_PTR(ary1) + i;
|
||
p2 = RARRAY_PTR(ary2) + i;
|
||
}
|
||
else {
|
||
if (rb_equal(*p1, *p2)) {
|
||
len1 = RARRAY_LEN(ary1);
|
||
if (len1 != RARRAY_LEN(ary2))
|
||
return Qfalse;
|
||
}
|
||
if (len1 < i)
|
||
return Qtrue;
|
||
p1 = RARRAY_PTR(ary1) + i;
|
||
p2 = RARRAY_PTR(ary2) + i;
|
||
}
|
||
else {
|
||
return Qfalse;
|
||
}
|
||
p1++;
|
||
p2++;
|
object.c | ||
---|---|---|
VALUE
|
||
rb_equal(VALUE obj1, VALUE obj2)
|
||
{
|
||
VALUE result;
|
||
if (obj1 == obj2) return Qtrue;
|
||
result = rb_funcall(obj1, id_eq, 1, obj2);
|
||
VALUE result = rb_funcall(obj1, id_eq, 1, obj2);
|
||
if (RTEST(result)) return Qtrue;
|
||
return Qfalse;
|
||
}
|
test/ruby/test_array.rb | ||
---|---|---|
a = [0, 4, 7, 10, 12]
|
||
assert_equal(nil, a.bsearch {|x| "foo" }) # undefined behavior
|
||
end
|
||
def test_array_equal_with_identical_but_nonequal_objects # [ruby-core:51328]
|
||
refute [Float::NAN] == [Float::NAN]
|
||
o = Object.new
|
||
def o.==(other)
|
||
false
|
||
end
|
||
refute [o] == [o]
|
||
end
|
||
end
|