1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* array.c (rb_ary_combination): revisit #combination behavior.

suggested by David Flanagan.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-10-01 14:46:07 +00:00
parent 5838fff334
commit 25ff7ef4c6
3 changed files with 10 additions and 7 deletions

View file

@ -1178,7 +1178,7 @@ class TestArray < Test::Unit::TestCase
end
# def test_permutation
# assert_equal(@cls[], @cls[1,2,3].permutation(0).to_a)
# assert_equal(@cls[[]], @cls[1,2,3].permutation(0).to_a)
# assert_equal(@cls[[1],[2],[3]], @cls[1,2,3].permutation(1).to_a)
# assert_equal(@cls[[1,2],[1,3],[2,1],[2,3],[3,1],[3,2]], @cls[1,2,3].permutation(2).to_a)
# assert_equal(@cls[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]], @cls[1,2,3].permutation(3).to_a)
@ -1186,7 +1186,7 @@ class TestArray < Test::Unit::TestCase
# end
def test_combination
assert_equal(@cls[], @cls[1,2,3,4].combination(0).to_a)
assert_equal(@cls[[]], @cls[1,2,3,4].combination(0).to_a)
assert_equal(@cls[[1],[2],[3],[4]], @cls[1,2,3,4].combination(1).to_a)
assert_equal(@cls[[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]], @cls[1,2,3,4].combination(2).to_a)
assert_equal(@cls[[1,2,3],[1,2,4],[1,3,4],[2,3,4]], @cls[1,2,3,4].combination(3).to_a)