From 1342da947e1ed1e18bf650ead38865d061fac696 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 9 May 2010 19:51:41 +0200 Subject: [PATCH] extended test case --- tests/run/all.pyx | 32 ++++++++++++++++++++++++++++++++ tests/run/any.pyx | 30 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/tests/run/all.pyx b/tests/run/all.pyx index 8ad941b8..b2b9f1ae 100644 --- a/tests/run/all.pyx +++ b/tests/run/all.pyx @@ -82,6 +82,38 @@ def all_in_simple_gen(seq): """ return all(x for x in seq) +@cython.test_assert_path_exists("//ForInStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode", + "//YieldExprNode", + "//GeneratorExpressionNode") +def all_in_conditional_gen(seq): + """ + >>> all_in_conditional_gen([3,6,9]) + False + >>> all_in_conditional_gen([0,3,7]) + False + >>> all_in_conditional_gen([1,0,1]) + True + + >>> all_in_conditional_gen(VerboseGetItem([1,1,1,1,1])) + 0 + 1 + 2 + 3 + 4 + 5 + True + >>> all_in_conditional_gen(VerboseGetItem([1,1,0,1,1])) + 0 + 1 + 2 + 3 + 4 + 5 + True + """ + return all(x%3 for x in seq if x%2 == 1) + @cython.test_assert_path_exists("//ForInStatNode") @cython.test_fail_if_path_exists("//SimpleCallNode", "//YieldExprNode", diff --git a/tests/run/any.pyx b/tests/run/any.pyx index 77729e2d..6234bc3f 100644 --- a/tests/run/any.pyx +++ b/tests/run/any.pyx @@ -78,6 +78,36 @@ def any_in_simple_gen(seq): """ return any(x for x in seq) +@cython.test_assert_path_exists("//ForInStatNode") +@cython.test_fail_if_path_exists("//SimpleCallNode", + "//YieldExprNode", + "//GeneratorExpressionNode") +def any_in_conditional_gen(seq): + """ + >>> any_in_conditional_gen([3,6,9]) + False + >>> any_in_conditional_gen([0,3,7]) + True + >>> any_in_conditional_gen([1,0,1]) + True + + >>> any_in_conditional_gen(VerboseGetItem([0,0,3,0,0])) + 0 + 1 + 2 + 3 + 4 + 5 + False + >>> any_in_conditional_gen(VerboseGetItem([0,3,0,1,1])) + 0 + 1 + 2 + 3 + True + """ + return any(x%3 for x in seq if x%2 == 1) + @cython.test_assert_path_exists("//ForInStatNode") @cython.test_fail_if_path_exists("//SimpleCallNode", "//YieldExprNode", -- 2.26.2