Commit 190f01d5 authored by gsamain's avatar gsamain

Amend __new__ test

parent f0fe2a22
...@@ -2,15 +2,22 @@ cdef cypclass SomeMemory: ...@@ -2,15 +2,22 @@ cdef cypclass SomeMemory:
int a int a
SomeMemory __new__(f): SomeMemory __new__(f):
o = <SomeMemory> f() o = f()
o.a = -2 o.a = -2
return o return o
void* __new__(f, int a): void* __new__(f, int a):
o = <SomeMemory> f() o = f()
o.a = a o.a = a
return <void*> 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__(): SomeMemory __alloc__():
return new SomeMemory() return new SomeMemory()
...@@ -20,6 +27,9 @@ cdef cypclass SomeMemory: ...@@ -20,6 +27,9 @@ cdef cypclass SomeMemory:
void __init__(self, int a): void __init__(self, int a):
pass pass
void __init__(self, int a, int b, int c, int d = 21, int e = 31):
self.a = e
cdef int foo(): cdef int foo():
cdef SomeMemory o = SomeMemory() cdef SomeMemory o = SomeMemory()
return o.a return o.a
...@@ -28,5 +38,14 @@ cdef int bar(): ...@@ -28,5 +38,14 @@ cdef int bar():
cdef SomeMemory o = SomeMemory(3) cdef SomeMemory o = SomeMemory(3)
return o.a return o.a
cdef int baz():
o = SomeMemory(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)
return o
cpdef bag(): cpdef bag():
return str(foo()) + '\n' + str(bar()) return str(foo()) + '\n' + str(bar()) + '\n' + str(baz()) + '\n' + str(baa())
\ No newline at end of file
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