From: Stefan Behnel Date: Wed, 11 Dec 2013 18:02:23 +0000 (+0100) Subject: try fixing test failures in int_literals.pyx by removing dependency on Py2/3 specific... X-Git-Tag: 0.20b1~125 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=56ab62c40a48763ddec608a84ee44292a059d02a;p=platform%2Fupstream%2Fpython-cython.git try fixing test failures in int_literals.pyx by removing dependency on Py2/3 specific 'L' postfix of long objects --- diff --git a/tests/run/int_literals.pyx b/tests/run/int_literals.pyx index 74a4700..79b64ef 100644 --- a/tests/run/int_literals.pyx +++ b/tests/run/int_literals.pyx @@ -1,27 +1,8 @@ -__doc__ = u""" ->>> c_longs() -(1, 1L, -1, 18446744073709551615L) ->>> negative_c_longs() -(-1, -9223285636854775809L) ->>> py_longs() -(1, 1L, 100000000000000000000000000000000L, -100000000000000000000000000000000L) - ->>> py_huge_calculated_long() -1606938044258990275541962092341162602522202993782792835301376L ->>> py_huge_computation_small_result_neg() -(-2535301200456458802993406410752L, -2535301200456458802993406410752L) -""" - cimport cython from cython cimport typeof import sys -if sys.version_info[0] >= 3: - __doc__ = __doc__.replace(u'L', u'') -elif sys.maxint > 2**31: - # sizeof(long) == sizeof(long long) - __doc__ = __doc__.replace("9223285636854775809L", "9223285636854775809") @cython.test_assert_path_exists( '//IntNode[@longness = "LL"]', @@ -29,6 +10,10 @@ elif sys.maxint > 2**31: ) @cython.test_fail_if_path_exists('//IntNode[@longness = ""]') def c_longs(): + """ + >>> c_longs() == (1, 1L, -1, 18446744073709551615L) or c_longs() + True + """ cdef long a = 1L cdef unsigned long ua = 1UL cdef long long aa = 0xFFFFFFFFFFFFFFFFLL @@ -41,16 +26,32 @@ def c_longs(): ) @cython.test_fail_if_path_exists('//IntNode[@longness = ""]') def negative_c_longs(): + """ + >>> negative_c_longs() == (-1, -9223285636854775809) or negative_c_longs() + True + """ cdef long a = -1L cdef long long aa = -9223285636854775809LL return a, aa def py_longs(): + """ + >>> py_longs() == ( + ... 1, 1, 100000000000000000000000000000000, -100000000000000000000000000000000 + ... ) or py_longs() + True + """ return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000 @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") @cython.test_assert_path_exists("//ReturnStatNode/IntNode") def py_huge_calculated_long(): + """ + >>> py_huge_calculated_long() == ( + ... 1606938044258990275541962092341162602522202993782792835301376 + ... ) or py_huge_calculated_long() + True + """ return 1 << 200 @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") @@ -65,6 +66,12 @@ def py_huge_computation_small_result(): @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") #@cython.test_assert_path_exists("//ReturnStatNode/IntNode") def py_huge_computation_small_result_neg(): + """ + >>> py_huge_computation_small_result_neg() == ( + ... -2535301200456458802993406410752L, -2535301200456458802993406410752L + ... ) or py_huge_computation_small_result_neg() + True + """ return -(2 ** 101), (-2) ** 101 def large_literal():