Commit 1283615a authored by Robert Bradshaw's avatar Robert Bradshaw

better bint type printing, tests

parent 18f44348
...@@ -925,6 +925,9 @@ class CBIntType(CIntType): ...@@ -925,6 +925,9 @@ class CBIntType(CIntType):
def __repr__(self): def __repr__(self):
return "<CNumericType bint>" return "<CNumericType bint>"
def __str__(self):
return 'bint'
class CPyUCS4IntType(CIntType): class CPyUCS4IntType(CIntType):
# Py_UCS4 # Py_UCS4
......
cdef test(bint value): from cython cimport typeof
print value
def call_test(): def test(bint value):
""" """
>>> call_test() >>> test(True)
False
True True
>>> test(False)
False
>>> test(None)
False
>>> test(0)
False False
>>> test(1)
True
>>> test(-1)
True True
>>> test(100)
True True
>>> test(0.0)
False
>>> test(0.1)
True True
>>> test([])
False
>>> test([1, 2, 3])
True True
""" """
test(False) return value
test(True)
test(0) def test_types(bint a):
test(234) """
test(-1) >>> test_types(None)
x = True """
test(x) cdef bint b = a
x = 3242 assert typeof(a) == 'bint', typeof(a)
test(x) assert typeof(b) == 'bint', typeof(b)
c = b
assert typeof(c) == 'bint', typeof(c)
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