From: Stefan Behnel Date: Tue, 15 Jun 2010 13:09:06 +0000 (+0200) Subject: extended test case X-Git-Tag: 0.13.beta0~2^2~24 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1a6d5069333d524787098133ea1c57076d1c8522;p=cython.git extended test case --- diff --git a/tests/run/inlined_generator_expressions.pyx b/tests/run/inlined_generator_expressions.pyx index eee9a9bc..343002c6 100644 --- a/tests/run/inlined_generator_expressions.pyx +++ b/tests/run/inlined_generator_expressions.pyx @@ -147,3 +147,35 @@ def return_typed_sum_squares_start(seq, int start): """ cdef int i return 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 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 sum( 0 if i%3 in (0,1) else 1 + for i in seq )