From c08d22ce50b1ec9ea5f87c18dd35ff45eeae2f12 Mon Sep 17 00:00:00 2001 From: Haoyu Bai Date: Thu, 7 Apr 2011 21:00:43 +0800 Subject: [PATCH] more tests --- tests/run/directive_locals_in_pxd.pxd | 6 ++++++ tests/run/directive_locals_in_pxd.py | 26 ++++++++++++++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/run/directive_locals_in_pxd.pxd b/tests/run/directive_locals_in_pxd.pxd index 2b5678c4..4fa9f027 100644 --- a/tests/run/directive_locals_in_pxd.pxd +++ b/tests/run/directive_locals_in_pxd.pxd @@ -2,3 +2,9 @@ cimport cython @cython.locals(egg=double) cdef foo(egg) + +@cython.locals(egg=cython.double) +cdef foo_defval(egg=*) + +@cython.locals(egg=cython.bint, v=cython.int) +cpdef cpfoo(egg=*) diff --git a/tests/run/directive_locals_in_pxd.py b/tests/run/directive_locals_in_pxd.py index 8614fdf7..87e73207 100644 --- a/tests/run/directive_locals_in_pxd.py +++ b/tests/run/directive_locals_in_pxd.py @@ -1,17 +1,31 @@ import cython -# @cython.locals(x=double) -# cdef func_defval(x=0): - # return x**2 - def foo(egg): if not cython.compiled: egg = float(egg) return egg +def foo_defval(egg=1): + if not cython.compiled: + egg = float(egg) + return egg**2 + +def cpfoo(egg=False): + if not cython.compiled: + egg = bool(egg) + v = int(not egg) + else: + v = not egg + return egg, v + def test_pxd_locals(): """ - >>> isinstance(test_pxd_locals(), float) + >>> v1, v2, v3 = test_pxd_locals() + >>> isinstance(v1, float) + True + >>> isinstance(v2, float) True + >>> v3 + (True, 0) """ - return foo(1) + return foo(1), foo_defval(), cpfoo(1) -- 2.26.2