Commits

Armin Rigo committed 0e43b0a

Some extra tests

Comments (0)

Files changed (1)

pypy/module/itertools/test/test_itertools.py

         assert prod.next() == ()
         raises (StopIteration, prod.next)
 
+    def test_product_powers_of_two(self):
+        from itertools import product
+        assert list(product()) == [()]
+        assert list(product('ab')) == [('a',), ('b',)]
+        assert list(product('ab', 'cd')) == [
+            ('a', 'c'), ('a', 'd'),
+            ('b', 'c'), ('b', 'd')]
+        assert list(product('ab', 'cd', 'ef')) == [
+            ('a', 'c', 'e'), ('a', 'c', 'f'),
+            ('a', 'd', 'e'), ('a', 'd', 'f'),
+            ('b', 'c', 'e'), ('b', 'c', 'f'),
+            ('b', 'd', 'e'), ('b', 'd', 'f')]
+
+    def test_product_empty_item(self):
+        from itertools import product
+        assert list(product('')) == []
+        assert list(product('ab', '')) == []
+        assert list(product('', 'cd')) == []
+        assert list(product('ab', 'cd', '')) == []
+        assert list(product('ab', '', 'ef')) == []
+        assert list(product('', 'cd', 'ef')) == []
+
     def test_permutations(self):
         from itertools import permutations
         assert list(permutations('AB')) == [('A', 'B'), ('B', 'A')]