From eabbb0467db7c91a03a7d5b4b07e03c222b45f67 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Wed, 13 Feb 2013 18:27:45 +0100 Subject: [PATCH] refactor test --- tests/run/ct_DEF.pyx | 111 ++++++++++++++++++++++++++++----------------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/tests/run/ct_DEF.pyx b/tests/run/ct_DEF.pyx index a06eccb..a2f38e1 100644 --- a/tests/run/ct_DEF.pyx +++ b/tests/run/ct_DEF.pyx @@ -1,35 +1,12 @@ __doc__ = u""" - >>> c() - 120 - >>> i0() == -1 - True - >>> i1() == 42 - True - >>> i2() == 0x42 - True - >>> i3() == -0x42 - True - >>> l() - 666 - >>> f() - 12.5 >>> s() b'spam' - >>> two() - 2 - >>> five() - 5 - >>> true() - True - >>> false() - False """ import sys if sys.version_info[0] < 3: __doc__ = __doc__.replace(u" b'", u" '") -else: - __doc__ = __doc__.replace(u" 042", u" 0o42") + DEF TUPLE = (1, 2, u"buckle my shoe") DEF TRUE_FALSE = (True, False) @@ -50,54 +27,79 @@ DEF INT_TUPLE1 = TUPLE[:2] DEF INT_TUPLE2 = TUPLE[1:4:2] def c(): - cdef char c - c = CHAR + """ + >>> c() + 120 + """ + cdef char c = CHAR return c def i0(): - cdef int i - i = INT0 + """ + >>> i0() == -1 + True + """ + cdef int i = INT0 return i def i1(): - cdef int i - i = INT1 + """ + >>> i1() == 42 + True + """ + cdef int i = INT1 return i def i2(): - cdef int i - i = INT2 + """ + >>> i2() == 0x42 + True + """ + cdef int i = INT2 return i def i3(): - cdef int i - i = INT3 + """ + >>> i3() == -0x42 + True + """ + cdef int i = INT3 return i def l(): - cdef long l - l = LONG + """ + >>> l() + 666 + """ + cdef long l = LONG return l def f(): - cdef float f - f = FLOAT + """ + >>> f() + 12.5 + """ + cdef float f = FLOAT return f def s(): - cdef char *s - s = STR + """ + see module docstring above + """ + cdef char* s = STR return s # this does not work! #def t(): -# cdef object t -# t = TUPLE +# cdef object t = TUPLE # return t def two(): - cdef int two - two = TWO + """ + >>> two() + 2 + """ + cdef int two = TWO return two # this doesn't currently work! @@ -107,16 +109,25 @@ def two(): # return two def five(): - cdef int five - five = FIVE + """ + >>> five() + 5 + """ + cdef int five = FIVE return five def true(): - cdef bint true - true = TRUE + """ + >>> true() + True + """ + cdef bint true = TRUE return true def false(): - cdef bint false - false = FALSE + """ + >>> false() + False + """ + cdef bint false = FALSE return false -- 2.7.4