mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
dd4374c3a4
commit
be8b517f52
2 changed files with 20 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Jan 23 22:30:59 2016 K0mA <mctj1218@gmail.com>
|
||||||
|
|
||||||
|
* test/ruby/test_array.rb (test_keep_if): Add test for
|
||||||
|
Array#keep_if separate from Array#select! [Fix GH-1218]
|
||||||
|
|
||||||
Sat Jan 23 20:54:26 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
Sat Jan 23 20:54:26 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk: revert r53633. It broke rubyci and travis.
|
* common.mk: revert r53633. It broke rubyci and travis.
|
||||||
|
|
|
@ -2081,7 +2081,6 @@ class TestArray < Test::Unit::TestCase
|
||||||
def test_select!
|
def test_select!
|
||||||
a = @cls[ 1, 2, 3, 4, 5 ]
|
a = @cls[ 1, 2, 3, 4, 5 ]
|
||||||
assert_equal(nil, a.select! { true })
|
assert_equal(nil, a.select! { true })
|
||||||
assert_equal(a, a.keep_if { true })
|
|
||||||
assert_equal(@cls[1, 2, 3, 4, 5], a)
|
assert_equal(@cls[1, 2, 3, 4, 5], a)
|
||||||
|
|
||||||
a = @cls[ 1, 2, 3, 4, 5 ]
|
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)
|
assert_equal(@cls[7, 8, 9, 10], a, bug10722)
|
||||||
end
|
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
|
def test_delete2
|
||||||
a = [0] * 1024 + [1] + [0] * 1024
|
a = [0] * 1024 + [1] + [0] * 1024
|
||||||
a.delete(0)
|
a.delete(0)
|
||||||
|
|
Loading…
Reference in a new issue