Commit 719cf6e1 authored by Robert Bradshaw's avatar Robert Bradshaw

Add a typecheck pure mode cast test.

parent 7d18de21
...@@ -49,6 +49,26 @@ def test_cast(x): ...@@ -49,6 +49,26 @@ def test_cast(x):
n = cython.cast(cython.int, x) n = cython.cast(cython.int, x)
return n return n
@cython.locals(as_list=list)
def test_cast_object(x, typecheck):
"""
>>> test_cast_object([1, 2, 3], True)
[1, 2, 3]
>>> test_cast_object([1, 2, 3], False)
[1, 2, 3]
>>> test_cast_object((1, 2, 3), True)
Traceback (most recent call last):
...
TypeError: Expected list, got tuple
>>> test_cast_object((1, 2, 3), False)
(1, 2, 3)
"""
if typecheck:
as_list = cython.cast(list, x, typecheck=True)
else:
as_list = cython.cast(list, x, typecheck=False)
return as_list
@cython.locals(x=cython.int, y=cython.p_int) @cython.locals(x=cython.int, y=cython.p_int)
def test_address(x): def test_address(x):
""" """
......
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