Commit 988c3f64 authored by Stefan Behnel's avatar Stefan Behnel

compile time IF/DEF tests

parent 04794cd7
__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 CHAR = c'x'
DEF INT = 42 DEF INT = 42
DEF LONG = 666L DEF LONG = 666L
DEF FLOAT = 17.88 DEF FLOAT = 12.5
DEF STR = "spam" DEF STR = "spam"
DEF TUPLE = (1, 2, "buckle my shoe")
DEF TWO = TUPLE[1] DEF TWO = TUPLE[1]
DEF FIVE = TWO + 3 DEF FIVE = TWO + 3
DEF TRUE = TRUE_FALSE[0]
DEF FALSE = TRUE_FALSE[1]
cdef void f(): def c():
cdef char c cdef char c
cdef int i
cdef long l
cdef float f
cdef char *s
cdef int two
cdef int five
c = CHAR c = CHAR
return c
def i():
cdef int i
i = INT i = INT
return i
def l():
cdef long l
l = LONG l = LONG
return l
def f():
cdef float f
f = FLOAT f = FLOAT
return f
def s():
cdef char *s
s = STR s = STR
return s
# this does not work!
#def t():
# cdef object t
# t = TUPLE
# return t
def two():
cdef int two
two = TWO two = TWO
return two
def five():
cdef int five
five = FIVE five = FIVE
return five
\ No newline at end of file
def true():
cdef bint true
true = TRUE
return true
def false():
cdef bint false
false = FALSE
return false
__doc__ = """
>>> f()
1
>>> g()
2
>>> h()
3
"""
DEF NO = 0 DEF NO = 0
DEF YES = 1 DEF YES = 1
cdef void f(): def f():
cdef int i cdef int i
IF YES: IF YES:
i = 1 i = 1
...@@ -9,8 +18,9 @@ cdef void f(): ...@@ -9,8 +18,9 @@ cdef void f():
i = 2 i = 2
ELSE: ELSE:
i = 3 i = 3
return i
cdef void g(): def g():
cdef int i cdef int i
IF NO: IF NO:
i = 1 i = 1
...@@ -18,8 +28,9 @@ cdef void g(): ...@@ -18,8 +28,9 @@ cdef void g():
i = 2 i = 2
ELSE: ELSE:
i = 3 i = 3
return i
cdef void h(): def h():
cdef int i cdef int i
IF NO: IF NO:
i = 1 i = 1
...@@ -27,3 +38,4 @@ cdef void h(): ...@@ -27,3 +38,4 @@ cdef void h():
i = 2 i = 2
ELSE: ELSE:
i = 3 i = 3
return i
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment