Commit 89b7f63b authored by gsamain's avatar gsamain

Reflect wrapped __new__ logic in __new__ test

parent deb92199
......@@ -11,6 +11,30 @@ cdef cypclass SomeMemory:
o.a = -2
return o
void __init__(self):
this.a += 1
void __init__(self, int a):
pass
void __init__(self, int a, int b, int c, int d = 21, int e = 31):
self.a = e
cdef cypclass SomeArgUnpacking:
int a
SomeArgUnpacking __new__(f, int a, int b, int c, int d = 21, int e = 31):
o = f()
return o
void __init__(self, int a, int b, int c=2, int d=4, int e = 32, int g = 65):
self.a = e
cdef cypclass SomeNewTrick:
int a
void* __new__(f, int a):
o = f()
o.a = a
......@@ -20,40 +44,30 @@ cdef cypclass SomeMemory:
Cy_INCREF(<CyObject*>o)
return <void*> o
double __new__(unused, int a, double b):
return a*b
SomeMemory __new__(f, int a, int b, int c=2, int d=4, int e = 32, int g = 65):
o = f()
return o
SomeMemory __alloc__():
return new SomeMemory()
void __init__(self, int a, int b, int c, int d = 21, int e = 31):
self.a = e
void __init__(self):
this.a += 1
void __init__(self, int a):
pass
cdef cypclass SomeNotInstanciable:
double __new__(unused, int a, double b):
return a*b
void __init__(self, int a, int b, int c, int d = 21, int e = 31):
self.a = e
cdef int foo():
o = SomeMemory()
return o.a
cdef int bar():
o = SomeMemory(3)
o = <SomeNewTrick> SomeNewTrick(3)
return o.a
cdef int baz():
o = SomeMemory(3, 2, 1, 0)
o = SomeArgUnpacking(3, 2, 1, 0)
return o.a
cdef double baa():
o = SomeMemory.__new__(SomeMemory.__alloc__, 2, 3.4)
o = SomeMemory.__new__(NULL, 2, 3.4)
o = SomeNotInstanciable.__new__(SomeNotInstanciable.__alloc__, 2, 3.4)
o = SomeNotInstanciable.__new__(NULL, 2, 3.4)
return o
cpdef bag():
......
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