aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-04 02:44:58 +0000
committerglass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-04 02:44:58 +0000
commita28a060db41415c1c1dad3e554ff2c865a20ebca (patch)
tree1bc0150b951b398dccc39af8f334cb3d853716db
parente59d5667c7769ffbe77f50687cb4393ca9280b2b (diff)
downloadruby-a28a060db41415c1c1dad3e554ff2c865a20ebca.tar.gz
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--array.c4
-rw-r--r--test/ruby/test_array.rb14
3 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bf648cf9f5..7c455ff44a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Nov 4 11:27:54 2012 Masaki Matsushita <glass.saga@gmail.com>
+
+ * 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@ruby-lang.org>
* dir.c (file_s_fnmatch): match with expanding braces if FNM_EXTGLOB
diff --git a/array.c b/array.c
index f4750696fd..1d526644c7 100644
--- a/array.c
+++ b/array.c
@@ -3282,8 +3282,10 @@ recursive_equal(VALUE ary1, VALUE ary2, int recur)
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;
}
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index b4115ac5dd..845a05089a 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1923,6 +1923,20 @@ class TestArray < Test::Unit::TestCase
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