From e9f67ac2ae13935f6cd686b11e9c8973296783ba Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 3 Dec 2009 13:21:00 +0100 Subject: [PATCH] test for ticket 236 --- tests/run/c_type_methods_T236.pyx | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/run/c_type_methods_T236.pyx diff --git a/tests/run/c_type_methods_T236.pyx b/tests/run/c_type_methods_T236.pyx new file mode 100644 index 00000000..ed536b90 --- /dev/null +++ b/tests/run/c_type_methods_T236.pyx @@ -0,0 +1,41 @@ + +__doc__ = '' + +import sys +if sys.version_info >= (2,6): + __doc__ = ''' +>>> float_is_integer(1.0) +True +>>> float_is_integer(1.1) +False +''' +if sys.version_info >= (3,1): + __doc__ = ''' +>>> int_bit_length(1) == (1).bit_length() +True +>>> int_bit_length(1234) == (1234).bit_length() +True +''' + +def float_is_integer(float f): + # requires Python 2.6+ + return f.is_integer() + +def int_bit_length(int i): + # requires Python 3.x + return i.bit_length() + + +def float__add__(float f): + """ + >>> float__add__(5.0) + 7.0 + """ + return f.__add__(2) + +def int__add__(int i): + """ + >>> int__add__(5) + 7 + """ + return i.__add__(2) -- 2.26.2