From: Stefan Behnel Date: Sun, 10 Feb 2008 07:34:03 +0000 (+0100) Subject: compile time IF/DEF tests X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=988c3f64d3b504e5ac2101e10cb8ce2024fa7e5e;p=cython.git compile time IF/DEF tests --- diff --git a/tests/compile/ct_DEF.pyx b/tests/compile/ct_DEF.pyx deleted file mode 100644 index 68a7c09f..00000000 --- a/tests/compile/ct_DEF.pyx +++ /dev/null @@ -1,25 +0,0 @@ -DEF CHAR = c'x' -DEF INT = 42 -DEF LONG = 666L -DEF FLOAT = 17.88 -DEF STR = "spam" -DEF TUPLE = (1, 2, "buckle my shoe") -DEF TWO = TUPLE[1] -DEF FIVE = TWO + 3 - -cdef void f(): - cdef char c - cdef int i - cdef long l - cdef float f - cdef char *s - cdef int two - cdef int five - c = CHAR - i = INT - l = LONG - f = FLOAT - s = STR - two = TWO - five = FIVE - \ No newline at end of file diff --git a/tests/run/ct_DEF.pyx b/tests/run/ct_DEF.pyx new file mode 100644 index 00000000..bf191a11 --- /dev/null +++ b/tests/run/ct_DEF.pyx @@ -0,0 +1,84 @@ +__doc__ = """ + >>> c() + 120 + >>> i() + 42 + >>> l() + 666 + >>> f() + 12.5 + >>> s() + 'spam' + >>> two() + 2 + >>> five() + 5 + >>> true() + True + >>> false() + False +""" + +DEF TUPLE = (1, 2, "buckle my shoe") +DEF TRUE_FALSE = (True, False) + +DEF CHAR = c'x' +DEF INT = 42 +DEF LONG = 666L +DEF FLOAT = 12.5 +DEF STR = "spam" +DEF TWO = TUPLE[1] +DEF FIVE = TWO + 3 +DEF TRUE = TRUE_FALSE[0] +DEF FALSE = TRUE_FALSE[1] + +def c(): + cdef char c + c = CHAR + return c + +def i(): + cdef int i + i = INT + return i + +def l(): + cdef long l + l = LONG + return l + +def f(): + cdef float f + f = FLOAT + return f + +def s(): + cdef char *s + s = STR + return s + +# this does not work! +#def t(): +# cdef object t +# t = TUPLE +# return t + +def two(): + cdef int two + two = TWO + return two + +def five(): + cdef int five + five = FIVE + return five + +def true(): + cdef bint true + true = TRUE + return true + +def false(): + cdef bint false + false = FALSE + return false diff --git a/tests/broken/ct_IF.pyx b/tests/run/ct_IF.pyx similarity index 68% rename from tests/broken/ct_IF.pyx rename to tests/run/ct_IF.pyx index 8cb19417..58db9efb 100644 --- a/tests/broken/ct_IF.pyx +++ b/tests/run/ct_IF.pyx @@ -1,7 +1,16 @@ +__doc__ = """ + >>> f() + 1 + >>> g() + 2 + >>> h() + 3 +""" + DEF NO = 0 DEF YES = 1 -cdef void f(): +def f(): cdef int i IF YES: i = 1 @@ -9,8 +18,9 @@ cdef void f(): i = 2 ELSE: i = 3 + return i -cdef void g(): +def g(): cdef int i IF NO: i = 1 @@ -18,8 +28,9 @@ cdef void g(): i = 2 ELSE: i = 3 + return i -cdef void h(): +def h(): cdef int i IF NO: i = 1 @@ -27,3 +38,4 @@ cdef void h(): i = 2 ELSE: i = 3 + return i