Commit 56ab62c4 authored by Stefan Behnel's avatar Stefan Behnel

try fixing test failures in int_literals.pyx by removing dependency on Py2/3...

try fixing test failures in int_literals.pyx by removing dependency on Py2/3 specific 'L' postfix of long objects
parent b42a817e
__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 cimport cython
from cython cimport typeof from cython cimport typeof
import sys 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( @cython.test_assert_path_exists(
'//IntNode[@longness = "LL"]', '//IntNode[@longness = "LL"]',
...@@ -29,6 +10,10 @@ elif sys.maxint > 2**31: ...@@ -29,6 +10,10 @@ elif sys.maxint > 2**31:
) )
@cython.test_fail_if_path_exists('//IntNode[@longness = ""]') @cython.test_fail_if_path_exists('//IntNode[@longness = ""]')
def c_longs(): def c_longs():
"""
>>> c_longs() == (1, 1L, -1, 18446744073709551615L) or c_longs()
True
"""
cdef long a = 1L cdef long a = 1L
cdef unsigned long ua = 1UL cdef unsigned long ua = 1UL
cdef long long aa = 0xFFFFFFFFFFFFFFFFLL cdef long long aa = 0xFFFFFFFFFFFFFFFFLL
...@@ -41,16 +26,32 @@ def c_longs(): ...@@ -41,16 +26,32 @@ def c_longs():
) )
@cython.test_fail_if_path_exists('//IntNode[@longness = ""]') @cython.test_fail_if_path_exists('//IntNode[@longness = ""]')
def negative_c_longs(): def negative_c_longs():
"""
>>> negative_c_longs() == (-1, -9223285636854775809) or negative_c_longs()
True
"""
cdef long a = -1L cdef long a = -1L
cdef long long aa = -9223285636854775809LL cdef long long aa = -9223285636854775809LL
return a, aa return a, aa
def py_longs(): def py_longs():
"""
>>> py_longs() == (
... 1, 1, 100000000000000000000000000000000, -100000000000000000000000000000000
... ) or py_longs()
True
"""
return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000 return 1, 1L, 100000000000000000000000000000000, -100000000000000000000000000000000
@cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode")
@cython.test_assert_path_exists("//ReturnStatNode/IntNode") @cython.test_assert_path_exists("//ReturnStatNode/IntNode")
def py_huge_calculated_long(): def py_huge_calculated_long():
"""
>>> py_huge_calculated_long() == (
... 1606938044258990275541962092341162602522202993782792835301376
... ) or py_huge_calculated_long()
True
"""
return 1 << 200 return 1 << 200
@cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode")
...@@ -65,6 +66,12 @@ def py_huge_computation_small_result(): ...@@ -65,6 +66,12 @@ def py_huge_computation_small_result():
@cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode") @cython.test_fail_if_path_exists("//NumBinopNode", "//IntBinopNode")
#@cython.test_assert_path_exists("//ReturnStatNode/IntNode") #@cython.test_assert_path_exists("//ReturnStatNode/IntNode")
def py_huge_computation_small_result_neg(): 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 return -(2 ** 101), (-2) ** 101
def large_literal(): def large_literal():
......
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