From: Stefan Behnel Date: Tue, 30 Nov 2010 07:35:31 +0000 (+0100) Subject: additional tests X-Git-Tag: 0.14.alpha0~43 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=24135871cdb2d8c26bd8976c5cf7e9103fce1b7e;p=cython.git additional tests --- 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")