ruby-changes:16218
From: nobu <ko1@a...>
Date: Sun, 6 Jun 2010 10:45:01 +0900 (JST)
Subject: [ruby-changes:16218] Ruby:r28184 (trunk, ruby_1_9_2): * array.c (rb_ary_product): need to set the length in order to get
nobu 2010-06-06 10:44:38 +0900 (Sun, 06 Jun 2010) New Revision: 28184 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=28184 Log: * array.c (rb_ary_product): need to set the length in order to get the entries marked. [ruby-dev:41540] Modified files: branches/ruby_1_9_2/ChangeLog branches/ruby_1_9_2/array.c branches/ruby_1_9_2/test/ruby/envutil.rb branches/ruby_1_9_2/test/ruby/test_array.rb trunk/ChangeLog trunk/array.c trunk/test/ruby/envutil.rb trunk/test/ruby/test_array.rb Index: array.c =================================================================== --- array.c (revision 28183) +++ array.c (revision 28184) @@ -4306,6 +4306,7 @@ RBASIC(t1)->klass = 0; /* initialize the arrays of arrays */ + ARY_SET_LEN(t0, n); arrays[0] = ary; for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]); Index: ChangeLog =================================================================== --- ChangeLog (revision 28183) +++ ChangeLog (revision 28184) @@ -1,3 +1,8 @@ +Sun Jun 6 10:44:34 2010 Nobuyoshi Nakada <nobu@r...> + + * array.c (rb_ary_product): need to set the length in order to get + the entries marked. [ruby-dev:41540] + Sun Jun 6 08:26:01 2010 Tanaka Akira <akr@f...> * vm.c (Init_BareVM): call Init_native_thread here. Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 28183) +++ test/ruby/test_array.rb (revision 28184) @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestArray < Test::Unit::TestCase def setup @@ -1515,6 +1516,13 @@ @cls[1,2].product([3,4],[5,6])) assert_equal(@cls[[1],[2]], @cls[1,2].product) assert_equal(@cls[], @cls[1,2].product([])) + + bug3394 = '[ruby-dev:41540]' + acc = [] + EnvUtil.under_gc_stress {[1,2].product([3,4,5],[6,8]){|array| acc << array}} + assert_equal([[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8], + [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]], + acc, bug3394) end def test_permutation Index: test/ruby/envutil.rb =================================================================== --- test/ruby/envutil.rb (revision 28183) +++ test/ruby/envutil.rb (revision 28184) @@ -130,6 +130,14 @@ return stderr end module_function :verbose_warning + + def under_gc_stress + stress, GC.stress = GC.stress, true + yield + ensure + GC.stress = stress + end + module_function :under_gc_stress end module Test Index: ruby_1_9_2/array.c =================================================================== --- ruby_1_9_2/array.c (revision 28183) +++ ruby_1_9_2/array.c (revision 28184) @@ -4306,6 +4306,7 @@ RBASIC(t1)->klass = 0; /* initialize the arrays of arrays */ + ARY_SET_LEN(t0, n); arrays[0] = ary; for (i = 1; i < n; i++) arrays[i] = to_ary(argv[i-1]); Index: ruby_1_9_2/ChangeLog =================================================================== --- ruby_1_9_2/ChangeLog (revision 28183) +++ ruby_1_9_2/ChangeLog (revision 28184) @@ -1,3 +1,8 @@ +Sun Jun 6 10:44:34 2010 Nobuyoshi Nakada <nobu@r...> + + * array.c (rb_ary_product): need to set the length in order to get + the entries marked. [ruby-dev:41540] + Sun Jun 6 08:26:01 2010 Tanaka Akira <akr@f...> * vm.c (Init_BareVM): call Init_native_thread here. Index: ruby_1_9_2/test/ruby/test_array.rb =================================================================== --- ruby_1_9_2/test/ruby/test_array.rb (revision 28183) +++ ruby_1_9_2/test/ruby/test_array.rb (revision 28184) @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestArray < Test::Unit::TestCase def setup @@ -1515,6 +1516,13 @@ @cls[1,2].product([3,4],[5,6])) assert_equal(@cls[[1],[2]], @cls[1,2].product) assert_equal(@cls[], @cls[1,2].product([])) + + bug3394 = '[ruby-dev:41540]' + acc = [] + EnvUtil.under_gc_stress {[1,2].product([3,4,5],[6,8]){|array| acc << array}} + assert_equal([[1, 3, 6], [1, 3, 8], [1, 4, 6], [1, 4, 8], [1, 5, 6], [1, 5, 8], + [2, 3, 6], [2, 3, 8], [2, 4, 6], [2, 4, 8], [2, 5, 6], [2, 5, 8]], + acc, bug3394) end def test_permutation Index: ruby_1_9_2/test/ruby/envutil.rb =================================================================== --- ruby_1_9_2/test/ruby/envutil.rb (revision 28183) +++ ruby_1_9_2/test/ruby/envutil.rb (revision 28184) @@ -130,6 +130,14 @@ return stderr end module_function :verbose_warning + + def under_gc_stress + stress, GC.stress = GC.stress, true + yield + ensure + GC.stress = stress + end + module_function :under_gc_stress end module Test -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/