Commit 89b7f63b authored by gsamain's avatar gsamain

Reflect wrapped __new__ logic in __new__ test

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