ruby-changes:25407
From: glass <ko1@a...>
Date: Sun, 4 Nov 2012 11:45:12 +0900 (JST)
Subject: [ruby-changes:25407] glass:r37464 (trunk): * array.c (recursive_equal): fix to return true when self and other
glass 2012-11-04 11:44:58 +0900 (Sun, 04 Nov 2012) New Revision: 37464 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37464 Log: * array.c (recursive_equal): fix to return true when self and other are resized to same size and the current index become out of range. * test/ruby/test_array.rb: add a test for the above. Modified files: trunk/ChangeLog trunk/array.c trunk/test/ruby/test_array.rb Index: array.c =================================================================== --- array.c (revision 37463) +++ array.c (revision 37464) @@ -3282,8 +3282,10 @@ if (*p1 != *p2) { if (rb_equal(*p1, *p2)) { len1 = RARRAY_LEN(ary1); - if (len1 != RARRAY_LEN(ary2) || len1 < i) + if (len1 != RARRAY_LEN(ary2)) return Qfalse; + if (len1 < i) + return Qtrue; p1 = RARRAY_PTR(ary1) + i; p2 = RARRAY_PTR(ary2) + i; } Index: ChangeLog =================================================================== --- ChangeLog (revision 37463) +++ ChangeLog (revision 37464) @@ -1,3 +1,11 @@ +Sun Nov 4 11:27:54 2012 Masaki Matsushita <glass.saga@g...> + + * array.c (recursive_equal): fix to return true when self and other + are resized to same size and the current index become out of + range. + + * test/ruby/test_array.rb: add a test for the above. + Sun Nov 4 10:19:03 2012 Nobuyoshi Nakada <nobu@r...> * dir.c (file_s_fnmatch): match with expanding braces if FNM_EXTGLOB Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 37463) +++ test/ruby/test_array.rb (revision 37464) @@ -1923,6 +1923,20 @@ assert_not_equal([0, 1, 2], [0, 1, 3]) end + A = Array.new(3, &:to_s) + B = A.dup + + def test_equal_resize + o = Object.new + def o.==(o) + A.clear + B.clear + true + end + A[1] = o + assert_equal(A, B) + end + def test_hash2 a = [] a << a -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/