Commit ccd3ee5a authored by Stefan Behnel's avatar Stefan Behnel

add test case for more complex compile time expression and add tree assertions to others

parent 7cec62b7
cimport cython
__doc__ = u""" __doc__ = u"""
>>> s() >>> s()
b'spam' b'spam'
...@@ -25,6 +28,7 @@ DEF TRUE = TRUE_FALSE[0] ...@@ -25,6 +28,7 @@ DEF TRUE = TRUE_FALSE[0]
DEF FALSE = TRUE_FALSE[1] DEF FALSE = TRUE_FALSE[1]
DEF INT_TUPLE1 = TUPLE[:2] DEF INT_TUPLE1 = TUPLE[:2]
DEF INT_TUPLE2 = TUPLE[1:4:2] DEF INT_TUPLE2 = TUPLE[1:4:2]
DEF EXPRESSION = int(float(2*2)) + int(str(2)) + int(max(1,2,3)) + sum([TWO, FIVE])
def c(): def c():
""" """
...@@ -89,6 +93,7 @@ def s(): ...@@ -89,6 +93,7 @@ def s():
cdef char* s = STR cdef char* s = STR
return s return s
@cython.test_assert_path_exists('//TupleNode')
def constant_tuple(): def constant_tuple():
""" """
>>> constant_tuple() >>> constant_tuple()
...@@ -97,6 +102,7 @@ def constant_tuple(): ...@@ -97,6 +102,7 @@ def constant_tuple():
cdef object t = TUPLE cdef object t = TUPLE
return t return t
@cython.test_assert_path_exists('//IntNode')
def tuple_indexing(): def tuple_indexing():
""" """
>>> tuple_indexing() >>> tuple_indexing()
...@@ -121,6 +127,7 @@ def five(): ...@@ -121,6 +127,7 @@ def five():
cdef int five = FIVE cdef int five = FIVE
return five return five
@cython.test_assert_path_exists('//BoolNode')
def true(): def true():
""" """
>>> true() >>> true()
...@@ -129,6 +136,7 @@ def true(): ...@@ -129,6 +136,7 @@ def true():
cdef bint true = TRUE cdef bint true = TRUE
return true return true
@cython.test_assert_path_exists('//BoolNode')
def false(): def false():
""" """
>>> false() >>> false()
...@@ -136,3 +144,13 @@ def false(): ...@@ -136,3 +144,13 @@ def false():
""" """
cdef bint false = FALSE cdef bint false = FALSE
return false return false
@cython.test_assert_path_exists('//IntNode')
@cython.test_fail_if_path_exists('//AddNode')
def expression():
"""
>>> expression()
16
"""
cdef int i = EXPRESSION
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