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

ruby-changes:8501

From: mame <ko1@a...>
Date: Thu, 30 Oct 2008 01:17:26 +0900 (JST)
Subject: [ruby-changes:8501] Ruby:r20035 (ruby_1_9_1, trunk): * test/ruby/test_array (test_permutation): add a test that replaces

mame	2008-10-30 01:16:53 +0900 (Thu, 30 Oct 2008)

  New Revision: 20035

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20035

  Log:
    * test/ruby/test_array (test_permutation): add a test that replaces
      array during permutation.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/test/ruby/test_array.rb
    trunk/ChangeLog
    trunk/test/ruby/test_array.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 20034)
+++ ChangeLog	(revision 20035)
@@ -1,3 +1,8 @@
+Thu Oct 30 01:10:32 2008  Yusuke Endoh  <mame@t...>
+
+	* test/ruby/test_array (test_permutation): add a test that replaces
+	  array during permutation.
+
 Wed Oct 29 23:57:29 2008  Yusuke Endoh  <mame@t...>
 
 	* array.c (rb_ary_sort_bang): replacing array during sort broke
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 20034)
+++ test/ruby/test_array.rb	(revision 20035)
@@ -1297,6 +1297,11 @@
                  "edcba".each_char.to_a.permutation(5).sort)
     assert_equal(@cls[].permutation(0).to_a, @cls[[]])
 
+    a = @cls[1, 2, 3, 4]
+    b = @cls[]
+    a.permutation {|x| b << x; a.replace(@cls[9, 8, 7, 6]) }
+    assert_equal(@cls[9, 8, 7, 6], a)
+    assert_equal(@cls[1, 2, 3, 4].permutation.to_a, b)
   end
 
   def test_take
Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 20034)
+++ ruby_1_9_1/ChangeLog	(revision 20035)
@@ -1,3 +1,8 @@
+Thu Oct 30 01:10:32 2008  Yusuke Endoh  <mame@t...>
+
+	* test/ruby/test_array (test_permutation): add a test that replaces
+	  array during permutation.
+
 Wed Oct 29 23:57:29 2008  Yusuke Endoh  <mame@t...>
 
 	* array.c (rb_ary_sort_bang): replacing array during sort broke
Index: ruby_1_9_1/test/ruby/test_array.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_array.rb	(revision 20034)
+++ ruby_1_9_1/test/ruby/test_array.rb	(revision 20035)
@@ -1297,6 +1297,11 @@
                  "edcba".each_char.to_a.permutation(5).sort)
     assert_equal(@cls[].permutation(0).to_a, @cls[[]])
 
+    a = @cls[1, 2, 3, 4]
+    b = @cls[]
+    a.permutation {|x| b << x; a.replace(@cls[9, 8, 7, 6]) }
+    assert_equal(@cls[9, 8, 7, 6], a)
+    assert_equal(@cls[1, 2, 3, 4].permutation.to_a, b)
   end
 
   def test_take

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

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