From b6ad71a201f46ad5f4615a7a1090e73e12ff43e4 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 6 May 2010 21:57:51 +0200 Subject: [PATCH] test for generator expressions (disabled) --- tests/bugs.txt | 1 + tests/run/genexpr_T491.pyx | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/run/genexpr_T491.pyx diff --git a/tests/bugs.txt b/tests/bugs.txt index 8a3837d4..99586d8e 100644 --- a/tests/bugs.txt +++ b/tests/bugs.txt @@ -9,6 +9,7 @@ missing_baseclass_in_predecl_T262 cfunc_call_tuple_args_T408 cascaded_list_unpacking_T467 compile.cpp_operators +genexpr_T491 # CPython regression tests that don't current work: pyregr.test_threadsignals diff --git a/tests/run/genexpr_T491.pyx b/tests/run/genexpr_T491.pyx new file mode 100644 index 00000000..b2babf07 --- /dev/null +++ b/tests/run/genexpr_T491.pyx @@ -0,0 +1,43 @@ + +def test_genexpr(): + """ + >>> gen = test_genexpr() + >>> list(gen) + [0, 1, 2, 3, 4] + """ + return (i for i in range(5)) + +def test_genexpr_typed(): + """ + >>> gen = test_genexpr_typed() + >>> list(gen) + [0, 1, 2, 3, 4] + """ + cdef int i + return (i for i in range(5)) + +def test_genexpr_funccall(): + """ + >>> test_genexpr_funccall() + [0, 1, 2, 3, 4] + """ + return list(i for i in range(5)) + +def test_genexpr_scope(): + """ + >>> test_genexpr_scope() + ([0, 1, 2, 3, 4], 'abc') + """ + i = 'abc' + gen = (i for i in range(5)) + lst = list(gen) + return lst, i + +def test_genexpr_closure(): + """ + >>> gen = test_genexpr_closure() + >>> list(gen) + ['a', 'b', 'c'] + """ + abc = 'a' + 'b' + 'c' + return (c for c in abc) -- 2.26.2