From 1283615a7d4e77504e582948d37950e21d860495 Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Sat, 2 Apr 2011 14:33:02 -0700 Subject: [PATCH] better bint type printing, tests --- Cython/Compiler/PyrexTypes.py | 3 +++ tests/run/bint.pyx | 46 ++++++++++++++++++++++++----------- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index b62a0764..45e9af08 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -925,6 +925,9 @@ class CBIntType(CIntType): def __repr__(self): return "" + def __str__(self): + return 'bint' + class CPyUCS4IntType(CIntType): # Py_UCS4 diff --git a/tests/run/bint.pyx b/tests/run/bint.pyx index 8f498825..86502043 100644 --- a/tests/run/bint.pyx +++ b/tests/run/bint.pyx @@ -1,23 +1,41 @@ -cdef test(bint value): - print value +from cython cimport typeof -def call_test(): +def test(bint value): """ - >>> call_test() - False + >>> test(True) True + >>> test(False) + False + >>> test(None) + False + + >>> test(0) False + >>> test(1) + True + >>> test(-1) True + >>> test(100) True + + >>> test(0.0) + False + >>> test(0.1) True + + >>> test([]) + False + >>> test([1, 2, 3]) True """ - test(False) - test(True) - test(0) - test(234) - test(-1) - x = True - test(x) - x = 3242 - test(x) + return value + +def test_types(bint a): + """ + >>> test_types(None) + """ + cdef bint b = a + assert typeof(a) == 'bint', typeof(a) + assert typeof(b) == 'bint', typeof(b) + c = b + assert typeof(c) == 'bint', typeof(c) -- 2.26.2