array.c: keep consistency

* array.c (rb_ary_select_bang): keep the array consistent by
  removing unselected values soon.  [ruby-dev:48805] [Bug #10722]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-01-10 01:12:17 +00:00
parent 07b87cd239
commit d2da3d04e6
3 changed files with 26 additions and 12 deletions

View file

@ -2019,6 +2019,16 @@ class TestArray < Test::Unit::TestCase
a = @cls[ 1, 2, 3, 4, 5 ]
assert_equal(a, a.select! { |i| i > 3 })
assert_equal(@cls[4, 5], a)
bug10722 = '[ruby-dev:48805] [Bug #10722]'
a = @cls[ 5, 6, 7, 8, 9, 10 ]
r = a.select! {|i|
break i if i > 8
# assert_equal(a[0], i, "should be selected values only") if i == 7
i >= 7
}
assert_equal(9, r)
assert_equal(@cls[7, 8, 9, 10], a, bug10722)
end
def test_delete2