Merge pull request #4681 from shuujii/array-permutation-with-a-negative-argument-should-not-yield

`Array#permutation` with a negative argument should not yield
This commit is contained in:
Yukihiro "Matz" Matsumoto
2019-09-01 13:01:59 +09:00
committed by GitHub
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -819,7 +819,7 @@ class Array
size = self.size
if n == 0
yield []
elsif n <= size
elsif 0 < n && n <= size
i = 0
while i<size
result = [self[i]]
+2
View File
@@ -392,6 +392,7 @@ assert("Array#permutation") do
assert_permutation([[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]], a, 3)
assert_permutation([[]], a, 0)
assert_permutation([], a, 4)
assert_permutation([], a, -1)
end
assert("Array#combination") do
@@ -402,6 +403,7 @@ assert("Array#combination") do
assert_combination([[1,2,3,4]], a, 4)
assert_combination([[]], a, 0)
assert_combination([], a, 5)
assert_combination([], a, -1)
end
assert('Array#transpose') do