extended test case
authorStefan Behnel <scoder@users.berlios.de>
Sun, 9 May 2010 17:51:41 +0000 (19:51 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 9 May 2010 17:51:41 +0000 (19:51 +0200)
tests/run/all.pyx
tests/run/any.pyx

index 8ad941b8a389d6989f0f30a231c53510211fd241..b2b9f1ae2b82a83966a20461d687405167c5043b 100644 (file)
@@ -82,6 +82,38 @@ def all_in_simple_gen(seq):
     """
     return all(x for x in seq)
 
+@cython.test_assert_path_exists("//ForInStatNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode",
+                                 "//YieldExprNode",
+                                 "//GeneratorExpressionNode")
+def all_in_conditional_gen(seq):
+    """
+    >>> all_in_conditional_gen([3,6,9])
+    False
+    >>> all_in_conditional_gen([0,3,7])
+    False
+    >>> all_in_conditional_gen([1,0,1])
+    True
+
+    >>> all_in_conditional_gen(VerboseGetItem([1,1,1,1,1]))
+    0
+    1
+    2
+    3
+    4
+    5
+    True
+    >>> all_in_conditional_gen(VerboseGetItem([1,1,0,1,1]))
+    0
+    1
+    2
+    3
+    4
+    5
+    True
+    """
+    return all(x%3 for x in seq if x%2 == 1)
+
 @cython.test_assert_path_exists("//ForInStatNode")
 @cython.test_fail_if_path_exists("//SimpleCallNode",
                                  "//YieldExprNode",
index 77729e2d296af5ab7b949a3315eea0128ff7cbf8..6234bc3f7988eb849b8a2d0187254a74daecd4b9 100644 (file)
@@ -78,6 +78,36 @@ def any_in_simple_gen(seq):
     """
     return any(x for x in seq)
 
+@cython.test_assert_path_exists("//ForInStatNode")
+@cython.test_fail_if_path_exists("//SimpleCallNode",
+                                 "//YieldExprNode",
+                                 "//GeneratorExpressionNode")
+def any_in_conditional_gen(seq):
+    """
+    >>> any_in_conditional_gen([3,6,9])
+    False
+    >>> any_in_conditional_gen([0,3,7])
+    True
+    >>> any_in_conditional_gen([1,0,1])
+    True
+
+    >>> any_in_conditional_gen(VerboseGetItem([0,0,3,0,0]))
+    0
+    1
+    2
+    3
+    4
+    5
+    False
+    >>> any_in_conditional_gen(VerboseGetItem([0,3,0,1,1]))
+    0
+    1
+    2
+    3
+    True
+    """
+    return any(x%3 for x in seq if x%2 == 1)
+
 @cython.test_assert_path_exists("//ForInStatNode")
 @cython.test_fail_if_path_exists("//SimpleCallNode",
                                  "//YieldExprNode",