diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-23 13:31:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-23 13:31:51 +0000 |
commit | 1746cf4f742fd3d9511a4de0c1db9029548fe66e (patch) | |
tree | 60e745ce9ca2b84258e2c5ddc439546ba16a55b9 /test/ruby/test_array.rb | |
parent | 1d9f2e211734ee371f1a239a5831f4f6c2841d87 (diff) | |
download | ruby-1746cf4f742fd3d9511a4de0c1db9029548fe66e.tar.gz |
Add test for Array#keep_if
* test/ruby/test_array.rb (test_keep_if): Add test for
Array#keep_if separate from Array#select! [Fix GH-1218]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index b1fc473f86..436906ae32 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -2081,7 +2081,6 @@ class TestArray < Test::Unit::TestCase def test_select! a = @cls[ 1, 2, 3, 4, 5 ] assert_equal(nil, a.select! { true }) - assert_equal(a, a.keep_if { true }) assert_equal(@cls[1, 2, 3, 4, 5], a) a = @cls[ 1, 2, 3, 4, 5 ] @@ -2103,6 +2102,21 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[7, 8, 9, 10], a, bug10722) end + # also select! + def test_keep_if + a = @cls[ 1, 2, 3, 4, 5 ] + assert_equal(a, a.keep_if { true }) + assert_equal(@cls[1, 2, 3, 4, 5], a) + + a = @cls[ 1, 2, 3, 4, 5 ] + assert_equal(a, a.keep_if { false }) + assert_equal(@cls[], a) + + a = @cls[ 1, 2, 3, 4, 5 ] + assert_equal(a, a.keep_if { |i| i > 3 }) + assert_equal(@cls[4, 5], a) + end + def test_delete2 a = [0] * 1024 + [1] + [0] * 1024 a.delete(0) |