From 22e1308048e74c9bf347f5e340f648355657eed3 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 2 Jan 2008 17:42:29 +0100 Subject: [PATCH] loads of test cases --- tests/compile/altet1.pyx | 10 ++++++++++ tests/compile/hinsen1.pyx | 12 +++++++++++- tests/compile/nogil.pyx | 2 +- tests/run/backquote.pyx | 17 +++++++++++++++-- tests/run/powop.pyx | 4 ++-- tests/run/sizeof.pyx | 6 +++++- 6 files changed, 44 insertions(+), 7 deletions(-) diff --git a/tests/compile/altet1.pyx b/tests/compile/altet1.pyx index 2a691cf0..74a67d14 100644 --- a/tests/compile/altet1.pyx +++ b/tests/compile/altet1.pyx @@ -1,3 +1,10 @@ +__doc__ = """ + >>> flub(25) + 25 + >>> g() + 0 +""" + cdef extern from "altet1.h": ctypedef int blarg @@ -7,3 +14,6 @@ def flub(blarg bobble): print bobble globvar = 0 + +def g(): + return globvar diff --git a/tests/compile/hinsen1.pyx b/tests/compile/hinsen1.pyx index f8ada947..aa7e1f21 100644 --- a/tests/compile/hinsen1.pyx +++ b/tests/compile/hinsen1.pyx @@ -1,3 +1,8 @@ +__doc__ = """ + >>> test() + 1 +""" + cdef extern from "hinsen1.h": ctypedef class spam.Spam [object PySpamObject]: @@ -7,4 +12,9 @@ cdef extern from "hinsen1.h": cdef class SpamAndEggs(Spam): cdef cook(self): - pass + return 1 + +def test(): + cdef SpamAndEggs s + s = SpamAndEggs() + return s.cook() diff --git a/tests/compile/nogil.pyx b/tests/compile/nogil.pyx index 149f0448..8f747ad0 100644 --- a/tests/compile/nogil.pyx +++ b/tests/compile/nogil.pyx @@ -1,4 +1,4 @@ -cdef extern object g(int x) nogil +cdef extern void g(int x) nogil cdef void f(int x) nogil: cdef int y diff --git a/tests/run/backquote.pyx b/tests/run/backquote.pyx index bd77227b..a7a3f28d 100644 --- a/tests/run/backquote.pyx +++ b/tests/run/backquote.pyx @@ -1,4 +1,17 @@ -def f(obj1, obj2): +__doc__ = """ + >>> f(20) + '20' + >>> f('test') + "'test'" + + >>> g() + '42' +""" + +def f(obj2): obj1 = `obj2` + return obj1 + +def g(): obj1 = `42` - \ No newline at end of file + return obj1 diff --git a/tests/run/powop.pyx b/tests/run/powop.pyx index c8633ead..c7f20d5e 100644 --- a/tests/run/powop.pyx +++ b/tests/run/powop.pyx @@ -2,8 +2,8 @@ __doc__ = """ >>> f(1.0, 2.95)[0] == f(1.0, 2.95)[1] True - >>> constant_py() - 1024L + >>> constant_py() == 2L ** 10 + True >>> constant_long() == 2L ** 36 True diff --git a/tests/run/sizeof.pyx b/tests/run/sizeof.pyx index cbc54d77..5e071981 100644 --- a/tests/run/sizeof.pyx +++ b/tests/run/sizeof.pyx @@ -1,7 +1,11 @@ +__doc__ = """ + >>> f() +""" + cdef struct Spam: char *grail -cdef void f(): +def f(): cdef int i, j, k cdef char *p i = sizeof(p) -- 2.26.2