compile time IF/DEF tests
authorStefan Behnel <scoder@users.berlios.de>
Sun, 10 Feb 2008 07:34:03 +0000 (08:34 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 10 Feb 2008 07:34:03 +0000 (08:34 +0100)
tests/compile/ct_DEF.pyx [deleted file]
tests/run/ct_DEF.pyx [new file with mode: 0644]
tests/run/ct_IF.pyx [moved from tests/broken/ct_IF.pyx with 68% similarity]

diff --git a/tests/compile/ct_DEF.pyx b/tests/compile/ct_DEF.pyx
deleted file mode 100644 (file)
index 68a7c09..0000000
+++ /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 (file)
index 0000000..bf191a1
--- /dev/null
@@ -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
similarity index 68%
rename from tests/broken/ct_IF.pyx
rename to tests/run/ct_IF.pyx
index 8cb19417861b553b0b4a61de9e15e2a30a447910..58db9efb882503029f4a0796d6728c6757ecbea4 100644 (file)
@@ -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