Commit 4f81860a authored by Stefan Behnel's avatar Stefan Behnel

improved test for cascaded comparison coercions

--HG--
extra : transplant_source : %D3j%DF%23%CF%DB%14p%01y%26%8D%D3%91%03z%9BZ%BF%CD
parent 64ec20eb
......@@ -377,12 +377,17 @@ def test_inop_cascaded(x):
"""
return 1 != x in [2]
### The following tests are copied from CPython's test_grammar.py.
### They look stupid, but the nice thing about them is that Cython
### treats '1' as a C integer constant that triggers Python object
### coercion for the 'in' operator here, whereas the left side of
### the cascade can be evaluated entirely in C space.
def test_inop_cascaded_one():
"""
>>> test_inop_cascaded_one()
False
"""
# copied from CPython's test_grammar.py
return 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1
def test_inop_cascaded_int_orig(int x):
......@@ -392,6 +397,24 @@ def test_inop_cascaded_int_orig(int x):
"""
return 1 < 1 > 1 == 1 >= 1 <= 1 != x in 1 not in 1 is 1 is not 1
def test_inop_cascaded_one_err():
"""
>>> test_inop_cascaded_one_err() # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:... itera...
"""
return 1 == 1 >= 1 <= 1 in 1 not in 1 is 1 is not 1
def test_inop_cascaded_int_orig_err(int x):
"""
>>> test_inop_cascaded_int_orig_err(1) # doctest: +ELLIPSIS
Traceback (most recent call last):
TypeError:... itera...
"""
return 1 == 1 >= 1 <= 1 == x in 1 not in 1 is 1 is not 1
###
def test_inop_cascaded_int(int x):
"""
>>> test_inop_cascaded_int(1)
......
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