mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
@@ -301,6 +301,7 @@ assert list(t[0]) == [1,2,3]
|
||||
assert list(t[0]) == []
|
||||
|
||||
# itertools.product
|
||||
|
||||
it = itertools.product([1, 2], [3, 4])
|
||||
assert (1, 3) == next(it)
|
||||
assert (1, 4) == next(it)
|
||||
@@ -321,3 +322,25 @@ with assert_raises(TypeError):
|
||||
itertools.product(None)
|
||||
with assert_raises(TypeError):
|
||||
itertools.product([1, 2], repeat=None)
|
||||
|
||||
# itertools.combinations
|
||||
|
||||
it = itertools.combinations([1, 2, 3, 4], 2)
|
||||
assert list(it) == [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
|
||||
|
||||
it = itertools.combinations([1, 2, 3], 1)
|
||||
assert list(it) == [(1,), (2,), (3,)]
|
||||
|
||||
it = itertools.combinations([1, 2, 3], 2)
|
||||
assert next(it) == (1, 2)
|
||||
assert next(it) == (1, 3)
|
||||
assert next(it) == (2, 3)
|
||||
with assert_raises(StopIteration):
|
||||
next(it)
|
||||
|
||||
it = itertools.combinations([1, 2, 3], 4)
|
||||
with assert_raises(StopIteration):
|
||||
next(it)
|
||||
|
||||
with assert_raises(ValueError):
|
||||
itertools.combinations([1, 2, 3, 4], -2)
|
||||
|
||||
Reference in New Issue
Block a user