Commit d3a8f712 authored by gsamain's avatar gsamain

Unit testing

parent 594d66ef
cdef cypclass SomeMemory:
int a
SomeMemory __new__():
o = new SomeMemory()
o.a = -2
return o
void* __new__(int a):
o = new SomeMemory()
o.a = a
return <void*> o
void __init__():
this.a += 1
void __init__(int a):
pass
cdef int foo():
cdef SomeMemory o = SomeMemory()
return o.a
cdef int bar():
cdef SomeMemory o = SomeMemory(3)
return o.a
cpdef bag():
return str(foo()) + '\n' + str(bar())
\ No newline at end of file
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test___new__',
language='c++',
sources=['cypclass_test___new__.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ No newline at end of file
cdef cypclass SomeMemory:
int a
cpdef foo():
cdef SomeMemory o = SomeMemory()
o.a = 3
return o.a
def bag():
return str(foo())
\ No newline at end of file
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_basic',
language='c++',
sources=['cypclass_test_basic.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ No newline at end of file
cdef cypclass SomeMemory:
int a
void __init__(int a):
this.a = a
void __init__(int a, int b):
this.a = a*b
cpdef foo():
cdef SomeMemory o1 = SomeMemory(3)
return o1.a
cpdef bar():
cdef SomeMemory o2 = SomeMemory(2, 7)
return o2.a
def bag():
return str(foo()) + '\n' + str(bar())
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_constructor',
language='c++',
sources=['cypclass_test_constructor.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ No newline at end of file
cdef cypclass SomeMemory:
int a
void __init__(int a, int b=1):
this.a = a*b
cpdef foo():
cdef SomeMemory o1 = SomeMemory(3)
return o1.a
cpdef bar():
cdef SomeMemory o2 = SomeMemory(2, 7)
return o2.a
def bag():
return str(foo()) + '\n' + str(bar())
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_constructor_optional_arguments',
language='c++',
sources=['cypclass_test_constructor_optional_arguments.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ No newline at end of file
cdef cypclass SomeMemory:
int a
void __init__(int a):
this.a = a
void __init__(int a, int b):
this.a = a*b
cdef cypclass SomeSubMemory(SomeMemory):
void __init__(int a, int b):
this.a = a+b
int getter():
return this.a
cpdef foo():
cdef SomeMemory o1 = SomeMemory(2, 7)
return o1.a
cpdef bar():
cdef SomeSubMemory o2 = SomeSubMemory(2, 7)
return o2.getter()
cpdef baz():
cdef SomeSubMemory o3 = SomeSubMemory(2)
return o3.getter()
def bag():
return str(foo()) + '\n' + str(bar()) + '\n' + str(baz())
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_inheritance',
language='c++',
sources=['cypclass_test_inheritance.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ No newline at end of file
cdef cypclass SomeMemory:
int a
cpdef foo():
cdef SomeMemory o = new SomeMemory()
o.a = 3
return o.a
def bag():
return str(foo())
\ No newline at end of file
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
setup(
ext_modules = cythonize([
Extension(
'cypclass_test_keywordnew',
language='c++',
sources=['cypclass_test_keywordnew.pyx'],
extra_compile_args=["-pthread", "-std=c++11"],
),
])
)
\ 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