From 24135871cdb2d8c26bd8976c5cf7e9103fce1b7e Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Tue, 30 Nov 2010 08:35:31 +0100 Subject: [PATCH] additional tests --- tests/run/inlined_generator_expressions.pyx | 40 +++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/run/inlined_generator_expressions.pyx b/tests/run/inlined_generator_expressions.pyx index 6a46ae7f..a263f83d 100644 --- a/tests/run/inlined_generator_expressions.pyx +++ b/tests/run/inlined_generator_expressions.pyx @@ -149,6 +149,46 @@ def return_typed_sum_squares_start(seq, int start): return sum((i*i for i in seq), start) +@cython.test_assert_path_exists('//ForInStatNode', + "//InlinedGeneratorExpressionNode") +@cython.test_fail_if_path_exists('//SimpleCallNode') +def return_sum_of_listcomp_consts_start(seq, int start): + """ + >>> sum([1 for i in range(10) if i > 3], -1) + 5 + >>> return_sum_of_listcomp_consts_start(range(10), -1) + 5 + + >>> print(sum([1 for i in range(10000) if i > 3], 9)) + 10005 + >>> print(return_sum_of_listcomp_consts_start(range(10000), 9)) + 10005 + """ + return sum([1 for i in seq if i > 3], start) + + +@cython.test_assert_path_exists('//ForInStatNode', + "//InlinedGeneratorExpressionNode", + # the next test is for a deficiency + # (see InlinedGeneratorExpressionNode.coerce_to()), + # hope this breaks one day + "//CoerceFromPyTypeNode//InlinedGeneratorExpressionNode") +@cython.test_fail_if_path_exists('//SimpleCallNode') +def return_typed_sum_of_listcomp_consts_start(seq, int start): + """ + >>> sum([1 for i in range(10) if i > 3], -1) + 5 + >>> return_typed_sum_of_listcomp_consts_start(range(10), -1) + 5 + + >>> print(sum([1 for i in range(10000) if i > 3], 9)) + 10005 + >>> print(return_typed_sum_of_listcomp_consts_start(range(10000), 9)) + 10005 + """ + return sum([1 for i in seq if i > 3], start) + + @cython.test_assert_path_exists( '//ForInStatNode', "//InlinedGeneratorExpressionNode") -- 2.26.2