[前][次][番号順一覧][スレッド一覧]

ruby-changes:41565

From: nobu <ko1@a...>
Date: Sat, 23 Jan 2016 22:31:07 +0900 (JST)
Subject: [ruby-changes:41565] nobu:r53639 (trunk): Add test for Array#keep_if

nobu	2016-01-23 22:31:51 +0900 (Sat, 23 Jan 2016)

  New Revision: 53639

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53639

  Log:
    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]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_array.rb
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 53638)
+++ test/ruby/test_array.rb	(revision 53639)
@@ -2081,7 +2081,6 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2081
   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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L2102
     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)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 53638)
+++ ChangeLog	(revision 53639)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Jan 23 22:30:59 2016  K0mA  <mctj1218@g...>
+
+	* 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@r...>
 
 	* common.mk: revert r53633. It broke rubyci and travis.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]