зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_splice): fix r37583 doesn't condier the case when
beg > array length. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
5bde05f98f
Коммит
efeee7afa9
|
@ -1,3 +1,8 @@
|
|||
Fri Nov 9 19:40:03 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_splice): fix r37583 doesn't condier the case when
|
||||
beg > array length.
|
||||
|
||||
Fri Nov 9 16:11:58 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* random.c (rb_memhash): use siphash.
|
||||
|
|
2
array.c
2
array.c
|
@ -1438,7 +1438,7 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl)
|
|||
if (beg > ARY_MAX_SIZE - rlen) {
|
||||
rb_raise(rb_eIndexError, "index %ld too big", beg);
|
||||
}
|
||||
ary_ensure_room_for_push(ary, rlen);
|
||||
ary_ensure_room_for_push(ary, rlen-len); /* len is 0 or negative */
|
||||
len = beg + rlen;
|
||||
rb_mem_clear(RARRAY_PTR(ary) + RARRAY_LEN(ary), beg - RARRAY_LEN(ary));
|
||||
if (rlen > 0) {
|
||||
|
|
|
@ -426,6 +426,18 @@ class TestArray < Test::Unit::TestCase
|
|||
a = @cls[1, 2, 3]
|
||||
a[-1, 0] = a
|
||||
assert_equal([1, 2, 1, 2, 3, 3], a)
|
||||
|
||||
a = @cls[]
|
||||
a[5,0] = [5]
|
||||
assert_equal([nil, nil, nil, nil, nil, 5], a)
|
||||
|
||||
a = @cls[1]
|
||||
a[1,0] = [2]
|
||||
assert_equal([1, 2], a)
|
||||
|
||||
a = @cls[1]
|
||||
a[1,1] = [2]
|
||||
assert_equal([1, 2], a)
|
||||
end
|
||||
|
||||
def test_assoc
|
||||
|
|
Загрузка…
Ссылка в новой задаче