From 1a6d5069333d524787098133ea1c57076d1c8522 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 15 Jun 2010 15:09:06 +0200 Subject: [PATCH] extended test case --- tests/run/inlined_generator_expressions.pyx | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 ) -- 2.26.2