extended test case
authorStefan Behnel <scoder@users.berlios.de>
Tue, 15 Jun 2010 13:09:06 +0000 (15:09 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 15 Jun 2010 13:09:06 +0000 (15:09 +0200)
tests/run/inlined_generator_expressions.pyx

index eee9a9bc96bc1782dac7a4bf5b83284da59fdf5d..343002c6d0e4954abbc97e9dfd1d0a4bb8af58da 100644 (file)
@@ -147,3 +147,35 @@ def return_typed_sum_squares_start(seq, int start):
     """
     cdef int i
     return <int>sum((i*i for i in seq), start)
+
+
+@cython.test_assert_path_exists(
+    '//ForInStatNode',
+    "//InlinedGeneratorExpressionNode")
+@cython.test_fail_if_path_exists(
+    '//SimpleCallNode',
+    "//InlinedGeneratorExpressionNode//CoerceToPyTypeNode")
+def return_typed_sum_cond_exp(seq):
+    """
+    >>> return_typed_sum_cond_exp([1,2,3,4])
+    2
+    """
+    cdef int i
+    return <int>sum( 0 if i%2 else 1
+                     for i in seq )
+
+
+@cython.test_assert_path_exists(
+    '//ForInStatNode',
+    "//InlinedGeneratorExpressionNode")
+@cython.test_fail_if_path_exists(
+    '//SimpleCallNode',
+    "//InlinedGeneratorExpressionNode//CoerceToPyTypeNode")
+def return_typed_sum_cond_exp_in(seq):
+    """
+    >>> return_typed_sum_cond_exp_in([1,2,3,4,5,6,7,8,9])
+    3
+    """
+    cdef int i
+    return <int>sum( 0 if i%3 in (0,1) else 1
+                     for i in seq )