From: Stefan Behnel Date: Thu, 6 May 2010 19:57:51 +0000 (+0200) Subject: test for generator expressions (disabled) X-Git-Tag: 0.13.beta0~2^2~81 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b6ad71a201f46ad5f4615a7a1090e73e12ff43e4;p=cython.git test for generator expressions (disabled) --- 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)