Project

General

Profile

Bug #7676 ยป bug-7676.patch

charliesome (Charlie Somerville), 01/09/2013 11:00 PM

View differences:

array.c
3532 3532
    len1 = RARRAY_LEN(ary1);
3533 3533

  
3534 3534
    for (i = 0; i < len1; i++) {
3535
	if (*p1 != *p2) {
3536
	    if (rb_equal(*p1, *p2)) {
3537
		len1 = RARRAY_LEN(ary1);
3538
		if (len1 != RARRAY_LEN(ary2))
3539
		    return Qfalse;
3540
		if (len1 < i)
3541
		    return Qtrue;
3542
		p1 = RARRAY_PTR(ary1) + i;
3543
		p2 = RARRAY_PTR(ary2) + i;
3544
	    }
3545
	    else {
3535
	if (rb_equal(*p1, *p2)) {
3536
	    len1 = RARRAY_LEN(ary1);
3537
	    if (len1 != RARRAY_LEN(ary2))
3546 3538
		return Qfalse;
3547
	    }
3539
	    if (len1 < i)
3540
		return Qtrue;
3541
	    p1 = RARRAY_PTR(ary1) + i;
3542
	    p2 = RARRAY_PTR(ary2) + i;
3543
	}
3544
	else {
3545
	    return Qfalse;
3548 3546
	}
3549 3547
	p1++;
3550 3548
	p2++;
object.c
51 51
VALUE
52 52
rb_equal(VALUE obj1, VALUE obj2)
53 53
{
54
    VALUE result;
55

  
56
    if (obj1 == obj2) return Qtrue;
57
    result = rb_funcall(obj1, id_eq, 1, obj2);
54
    VALUE result = rb_funcall(obj1, id_eq, 1, obj2);
58 55
    if (RTEST(result)) return Qtrue;
59 56
    return Qfalse;
60 57
}
test/ruby/test_array.rb
2275 2275
    a = [0, 4, 7, 10, 12]
2276 2276
    assert_equal(nil, a.bsearch {|x| "foo" }) # undefined behavior
2277 2277
  end
2278

  
2279
  def test_array_equal_with_identical_but_nonequal_objects # [ruby-core:51328]
2280
    refute [Float::NAN] == [Float::NAN]
2281

  
2282
    o = Object.new
2283
    def o.==(other)
2284
      false
2285
    end
2286
    refute [o] == [o]
2287
  end
2278 2288
end