Commit 60618f0a authored by Stefan Behnel's avatar Stefan Behnel

extend fused types dispatching test to include the generic 'object' fallback case

parent ac4f248b
......@@ -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")
......
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