diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-06 01:44:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-06-06 01:44:38 +0000 |
commit | c22b223cb0a48342cef7412e139313e60a913e71 (patch) | |
tree | 06e41261c0c6f831948fd8e4ed59494231f9eff8 | |
parent | f40d2c967005e49914046bbc6a7a8c06c46b1d38 (diff) |
* array.c (rb_ary_product): need to set the length in order to get
the entries marked. [ruby-dev:41540]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | array.c | 1 | ||||
-rw-r--r-- | test/ruby/envutil.rb | 8 | ||||
-rw-r--r-- | test/ruby/test_array.rb | 8 |
4 files changed, 22 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sun Jun 6 10:44:34 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@fsij.org> * vm.c (Init_BareVM): call Init_native_thread here. @@ -4306,6 +4306,7 @@ rb_ary_product(int argc, VALUE *argv, VALUE ary) 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]); diff --git a/test/ruby/envutil.rb b/test/ruby/envutil.rb index 1839ed6da5..1824e548ed 100644 --- a/test/ruby/envutil.rb +++ b/test/ruby/envutil.rb @@ -130,6 +130,14 @@ module EnvUtil 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 diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index fedcec71fc..0ee38a2b37 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestArray < Test::Unit::TestCase def setup @@ -1515,6 +1516,13 @@ class TestArray < Test::Unit::TestCase @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 |