return ExprNodes.BoolNode(pos, value=True)
elif name == "False":
return ExprNodes.BoolNode(pos, value=False)
+ elif name == "NULL":
+ return ExprNodes.NullNode(pos)
else:
return p_name(s, name)
- elif sy == 'NULL':
- s.next()
- return ExprNodes.NullNode(pos)
else:
s.error("Expected an identifier or literal")
"raise", "import", "exec", "try", "except", "finally",
"while", "if", "elif", "else", "for", "in", "assert",
"and", "or", "not", "is", "in", "lambda", "from",
- "NULL", "cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE"
+ "cimport", "by", "with", "cpdef", "DEF", "IF", "ELIF", "ELSE"
]
class Method:
-import sys, os
-sys.path.insert(0, "..")
+__doc__ = """
+>>> test_sizeof()
+True
+True
+True
+True
+True
-import cython
+>>> test_declare(100)
+(100, 100)
+>>> test_declare(100.5)
+(100, 100)
+>>> test_declare(None)
+Traceback (most recent call last):
+...
+TypeError: an integer is required
+
+>>> test_cast(1.5)
+1
+>>> test_cast(None)
+Traceback (most recent call last):
+...
+TypeError: a float is required
+
+>>> test_address(39)
+39
+
+>>> test_locals(5)
+True
+>>> test_struct(389, 1.64493)
+(389, 1.64493)
+
+>>> test_imports()
+True
+"""
+
+import cython
def test_sizeof():
x = cython.declare(cython.bint)
import cython as cy
from cython import declare, cast, locals, address, typedef, p_void, compiled
-from cython import declare as my_declare, locals as my_locals, p_void as my_void_star, typedef as my_typedef, my_compiled
+from cython import declare as my_declare, locals as my_locals, p_void as my_void_star, typedef as my_typedef, compiled as my_compiled
@my_locals(a=cython.p_void)
def test_imports():
- a = NULL
- b = declare(p_void, NULL)
- c = my_declare(my_void_star, NULL)
- d = cy.declare(cy.p_void, NULL)
- compiled and my_compiled
+ a = cython.NULL
+ b = declare(p_void, cython.NULL)
+ c = my_declare(my_void_star, cython.NULL)
+ d = cy.declare(cy.p_void, cython.NULL)
+ return a == d and compiled and my_compiled
MyStruct3 = typedef(MyStruct[3])
MyStruct4 = my_typedef(MyStruct[4])