Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
719cf6e1
Commit
719cf6e1
authored
9 years ago
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a typecheck pure mode cast test.
parent
7d18de21
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
+20
-0
tests/run/pure.pyx
tests/run/pure.pyx
+20
-0
No files found.
tests/run/pure.pyx
View file @
719cf6e1
...
...
@@ -49,6 +49,26 @@ def test_cast(x):
n
=
cython
.
cast
(
cython
.
int
,
x
)
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
)
def
test_address
(
x
):
"""
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment