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
Kirill Smelkov
cython
Commits
60618f0a
Commit
60618f0a
authored
Jul 17, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extend fused types dispatching test to include the generic 'object' fallback case
parent
ac4f248b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
tests/run/fused_def.pyx
tests/run/fused_def.pyx
+49
-0
No files found.
tests/run/fused_def.pyx
View file @
60618f0a
...
...
@@ -35,9 +35,22 @@ ctypedef fused fused_t:
MyEnum
ctypedef
ExtClassA
xxxlast
ctypedef
ExtClassB
aaafirst
ctypedef
fused
fused_with_object
:
aaafirst
object
xxxlast
int
long
f
=
5.6
i
=
9
def
opt_func
(
fused_t
obj
,
cython
.
floating
myf
=
1.2
,
cython
.
integral
myi
=
7
):
"""
Test runtime dispatch, indexing of various kinds and optional arguments
...
...
@@ -111,6 +124,42 @@ def test_opt_func():
"""
opt_func
(
"ham"
,
f
,
entry4
)
def
func_with_object
(
fused_with_object
obj
,
cython
.
integral
myi
=
7
):
"""
>>> func_with_object(1)
long long
1 7
>>> func_with_object(1, 3)
long long
1 3
>>> func_with_object['int', 'int'](1, 3)
int int
1 3
>>> func_with_object(1j, 3)
Python object long
1j 3
>>> func_with_object('abc', 3)
Python object long
abc 3
>>> func_with_object(ExtClassA(), 3)
xxxlast long
ExtClassA 3
>>> func_with_object(ExtClassB(), 3)
aaafirst long
ExtClassB 3
>>> func_with_object['object', 'long'](ExtClassA(), 3)
Python object long
ExtClassA 3
>>> func_with_object['object', 'long'](ExtClassB(), 3)
Python object long
ExtClassB 3
"""
print
cython
.
typeof
(
obj
),
cython
.
typeof
(
myi
)
print
obj
,
myi
def
args_kwargs
(
fused_t
obj
,
cython
.
floating
myf
=
1.2
,
*
args
,
**
kwargs
):
"""
>>> args_kwargs("foo")
...
...
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