summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-19 03:10:15 +0000
committermrkn <mrkn@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-19 03:10:15 +0000
commit1d04aedb5a913a3e89bfe50550344dc698c7b3d9 (patch)
tree13bc0688910605f329870e1488ceef7db797e388 /test
parentfee5e4ff5f427ac06b6ffd2891c7ef775324d483 (diff)
* array.c (rb_ary_permutation, rb_ary_repeated_permutation, rb_ary_repeated_combination, rb_ary_product): use ary_make_shared_copy instead of ary_make_substitution. [ruby-dev:42067] [Bug #3708]
* test/ruby/test_array.rb (test_product, test_repeated_permutation, test_repeated_combination): append assertions against [Bug #3708]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_array.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index f2d723ffc9..3e32175012 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1528,6 +1528,10 @@ class TestArray < Test::Unit::TestCase
acc = [1,2].product(*[o]*10)
assert_equal([1,2].product([3,4], [3,4], [3,4], [3,4], [3,4], [3,4], [3,4], [3,4], [3,4], [3,4]),
acc)
+
+ a = []
+ [1, 2].product([0, 1, 2, 3, 4][1, 4]) {|x| a << x }
+ assert(a.all?{|x| !x.include?(0) })
end
def test_permutation
@@ -1574,6 +1578,9 @@ class TestArray < Test::Unit::TestCase
a.repeated_permutation(4) {|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].repeated_permutation(4).to_a, b)
+
+ a = @cls[0, 1, 2, 3, 4][1, 4].repeated_permutation(2)
+ assert(a.all?{|x| !x.include?(0) })
end
def test_repeated_combination
@@ -1600,6 +1607,9 @@ class TestArray < Test::Unit::TestCase
a.repeated_combination(4) {|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].repeated_combination(4).to_a, b)
+
+ a = @cls[0, 1, 2, 3, 4][1, 4].repeated_combination(2)
+ assert(a.all?{|x| !x.include?(0) })
end
def test_take