Merge branch 'yazug-python_test_suite_pep8_whitespace_cleanup'
* yazug-python_test_suite_pep8_whitespace_cleanup: autopep8 cleanup of Examples/test-suite/python
This commit is contained in:
commit
2348d8377f
202 changed files with 3477 additions and 3382 deletions
|
|
@ -2,5 +2,4 @@ import abstract_access
|
||||||
|
|
||||||
d = abstract_access.D()
|
d = abstract_access.D()
|
||||||
if d.do_x() != 1:
|
if d.do_x() != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,3 @@
|
||||||
from abstract_typedef2 import *
|
from abstract_typedef2 import *
|
||||||
|
|
||||||
a = A_UF()
|
a = A_UF()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
from abstract_typedef import *
|
from abstract_typedef import *
|
||||||
e = Engine()
|
e = Engine()
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
|
|
||||||
|
|
||||||
if a.write(e) != 1:
|
if a.write(e) != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,26 @@
|
||||||
from argcargvtest import *
|
from argcargvtest import *
|
||||||
|
|
||||||
largs=['hi','hola','hello']
|
largs = ['hi', 'hola', 'hello']
|
||||||
if mainc(largs) != 3:
|
if mainc(largs) != 3:
|
||||||
raise RuntimeError("bad main typemap")
|
raise RuntimeError("bad main typemap")
|
||||||
|
|
||||||
targs=('hi','hola')
|
targs = ('hi', 'hola')
|
||||||
if mainv(targs,1) != 'hola':
|
if mainv(targs, 1) != 'hola':
|
||||||
print(mainv(targs,1))
|
print(mainv(targs, 1))
|
||||||
raise RuntimeError("bad main typemap")
|
raise RuntimeError("bad main typemap")
|
||||||
|
|
||||||
targs=('hi', 'hola')
|
targs = ('hi', 'hola')
|
||||||
if mainv(targs,1) != 'hola':
|
if mainv(targs, 1) != 'hola':
|
||||||
raise RuntimeError("bad main typemap")
|
raise RuntimeError("bad main typemap")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
error = 0
|
error = 0
|
||||||
mainv('hello',1)
|
mainv('hello', 1)
|
||||||
error = 1
|
error = 1
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
if error:
|
if error:
|
||||||
raise RuntimeError("bad main typemap")
|
raise RuntimeError("bad main typemap")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
initializeApp(largs)
|
initializeApp(largs)
|
||||||
|
|
|
||||||
|
|
@ -3,19 +3,16 @@ from array_member import *
|
||||||
f = Foo()
|
f = Foo()
|
||||||
f.data = cvar.global_data
|
f.data = cvar.global_data
|
||||||
|
|
||||||
for i in range(0,8):
|
for i in range(0, 8):
|
||||||
if get_value(f.data,i) != get_value(cvar.global_data,i):
|
if get_value(f.data, i) != get_value(cvar.global_data, i):
|
||||||
raise RuntimeError, "Bad array assignment"
|
raise RuntimeError, "Bad array assignment"
|
||||||
|
|
||||||
|
|
||||||
for i in range(0,8):
|
for i in range(0, 8):
|
||||||
set_value(f.data,i,-i)
|
set_value(f.data, i, -i)
|
||||||
|
|
||||||
cvar.global_data = f.data
|
cvar.global_data = f.data
|
||||||
|
|
||||||
for i in range(0,8):
|
for i in range(0, 8):
|
||||||
if get_value(f.data,i) != get_value(cvar.global_data,i):
|
if get_value(f.data, i) != get_value(cvar.global_data, i):
|
||||||
raise RuntimeError, "Bad array assignment"
|
raise RuntimeError, "Bad array assignment"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,19 @@ import arrays_global
|
||||||
|
|
||||||
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
|
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
|
||||||
|
|
||||||
from arrays_global import *
|
from arrays_global import *
|
||||||
|
|
||||||
BeginString_FIX44a
|
BeginString_FIX44a
|
||||||
cvar.BeginString_FIX44b
|
cvar.BeginString_FIX44b
|
||||||
BeginString_FIX44c
|
BeginString_FIX44c
|
||||||
cvar.BeginString_FIX44d
|
cvar.BeginString_FIX44d
|
||||||
cvar.BeginString_FIX44d
|
cvar.BeginString_FIX44d
|
||||||
cvar.BeginString_FIX44b ="12"'\0'"45"
|
cvar.BeginString_FIX44b = "12"'\0'"45"
|
||||||
cvar.BeginString_FIX44b
|
cvar.BeginString_FIX44b
|
||||||
cvar.BeginString_FIX44d
|
cvar.BeginString_FIX44d
|
||||||
cvar.BeginString_FIX44e
|
cvar.BeginString_FIX44e
|
||||||
BeginString_FIX44f
|
BeginString_FIX44f
|
||||||
|
|
||||||
test_a("hello","hi","chello","chi")
|
test_a("hello", "hi", "chello", "chi")
|
||||||
|
|
||||||
test_b("1234567","hi")
|
test_b("1234567", "hi")
|
||||||
|
|
|
||||||
|
|
@ -1,341 +1,332 @@
|
||||||
from autodoc import *
|
from autodoc import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
def check(got, expected, expected_builtin = None, skip = False):
|
|
||||||
if not skip:
|
def check(got, expected, expected_builtin=None, skip=False):
|
||||||
expect = expected
|
if not skip:
|
||||||
if is_python_builtin() and expected_builtin != None:
|
expect = expected
|
||||||
expect = expected_builtin
|
if is_python_builtin() and expected_builtin != None:
|
||||||
if expect != got:
|
expect = expected_builtin
|
||||||
raise RuntimeError("\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
|
if expect != got:
|
||||||
|
raise RuntimeError(
|
||||||
|
"\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
if not is_new_style_class(A):
|
if not is_new_style_class(A):
|
||||||
# Missing static methods make this hard to test... skip if -classic is used!
|
# Missing static methods make this hard to test... skip if -classic is
|
||||||
sys.exit(0)
|
# used!
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
skip = True # skip builtin check - the autodoc is missing, but it probably should not be
|
# skip builtin check - the autodoc is missing, but it probably should not be
|
||||||
|
skip = True
|
||||||
|
|
||||||
check(A.__doc__, "Proxy of C++ A class", "::A")
|
check(A.__doc__, "Proxy of C++ A class", "::A")
|
||||||
check(A.funk.__doc__, "just a string")
|
check(A.funk.__doc__, "just a string")
|
||||||
check(A.func0.__doc__,
|
check(A.func0.__doc__,
|
||||||
"func0(self, arg2, hello) -> int",
|
"func0(self, arg2, hello) -> int",
|
||||||
"func0(arg2, hello) -> int")
|
"func0(arg2, hello) -> int")
|
||||||
check(A.func1.__doc__,
|
check(A.func1.__doc__,
|
||||||
"func1(A self, short arg2, Tuple hello) -> int",
|
"func1(A self, short arg2, Tuple hello) -> int",
|
||||||
"func1(short arg2, Tuple hello) -> int")
|
"func1(short arg2, Tuple hello) -> int")
|
||||||
check(A.func2.__doc__,
|
check(A.func2.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func2(self, arg2, hello) -> int\n"
|
" func2(self, arg2, hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func2(arg2, hello) -> int\n"
|
||||||
"func2(arg2, hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func3.__doc__,
|
check(A.func3.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func3(A self, short arg2, Tuple hello) -> int\n"
|
" func3(A self, short arg2, Tuple hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func3(short arg2, Tuple hello) -> int\n"
|
||||||
"func3(short arg2, Tuple hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
|
|
||||||
check(A.func0default.__doc__,
|
check(A.func0default.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func0default(self, e, arg3, hello, f=2) -> int\n"
|
" func0default(self, e, arg3, hello, f=2) -> int\n"
|
||||||
" func0default(self, e, arg3, hello) -> int\n"
|
" func0default(self, e, arg3, hello) -> int\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func0default(e, arg3, hello, f=2) -> int\n"
|
||||||
"func0default(e, arg3, hello, f=2) -> int\n"
|
"func0default(e, arg3, hello) -> int\n"
|
||||||
"func0default(e, arg3, hello) -> int\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func1default.__doc__,
|
check(A.func1default.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
" func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
|
" func1default(A self, A e, short arg3, Tuple hello) -> int\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
"func1default(A e, short arg3, Tuple hello) -> int\n"
|
||||||
"func1default(A e, short arg3, Tuple hello) -> int\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func2default.__doc__,
|
check(A.func2default.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func2default(self, e, arg3, hello, f=2) -> int\n"
|
" func2default(self, e, arg3, hello, f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg3: short\n"
|
" arg3: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
" f: double\n"
|
" f: double\n"
|
||||||
"\n"
|
"\n"
|
||||||
" func2default(self, e, arg3, hello) -> int\n"
|
" func2default(self, e, arg3, hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg3: short\n"
|
" arg3: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func2default(e, arg3, hello, f=2) -> int\n"
|
||||||
"func2default(e, arg3, hello, f=2) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg3: short\n"
|
||||||
" arg3: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
" f: double\n"
|
||||||
" f: double\n"
|
"\n"
|
||||||
"\n"
|
"func2default(e, arg3, hello) -> int\n"
|
||||||
"func2default(e, arg3, hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg3: short\n"
|
||||||
" arg3: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func3default.__doc__,
|
check(A.func3default.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg3: short\n"
|
" arg3: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
" f: double\n"
|
" f: double\n"
|
||||||
"\n"
|
"\n"
|
||||||
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
|
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg3: short\n"
|
" arg3: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
||||||
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg3: short\n"
|
||||||
" arg3: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
" f: double\n"
|
||||||
" f: double\n"
|
"\n"
|
||||||
"\n"
|
"func3default(A e, short arg3, Tuple hello) -> int\n"
|
||||||
"func3default(A e, short arg3, Tuple hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg3: short\n"
|
||||||
" arg3: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
|
|
||||||
check(A.func0static.__doc__,
|
check(A.func0static.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func0static(e, arg2, hello, f=2) -> int\n"
|
" func0static(e, arg2, hello, f=2) -> int\n"
|
||||||
" func0static(e, arg2, hello) -> int\n"
|
" func0static(e, arg2, hello) -> int\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func0static(e, arg2, hello, f=2) -> int\n"
|
||||||
"func0static(e, arg2, hello, f=2) -> int\n"
|
"func0static(e, arg2, hello) -> int\n"
|
||||||
"func0static(e, arg2, hello) -> int\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func1static.__doc__,
|
check(A.func1static.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
" func1static(A e, short arg2, Tuple hello) -> int\n"
|
" func1static(A e, short arg2, Tuple hello) -> int\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
"func1static(A e, short arg2, Tuple hello) -> int\n"
|
||||||
"func1static(A e, short arg2, Tuple hello) -> int\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func2static.__doc__,
|
check(A.func2static.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func2static(e, arg2, hello, f=2) -> int\n"
|
" func2static(e, arg2, hello, f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
" f: double\n"
|
" f: double\n"
|
||||||
"\n"
|
"\n"
|
||||||
" func2static(e, arg2, hello) -> int\n"
|
" func2static(e, arg2, hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func2static(e, arg2, hello, f=2) -> int\n"
|
||||||
"func2static(e, arg2, hello, f=2) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
" f: double\n"
|
||||||
" f: double\n"
|
"\n"
|
||||||
"\n"
|
"func2static(e, arg2, hello) -> int\n"
|
||||||
"func2static(e, arg2, hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
check(A.func3static.__doc__,
|
check(A.func3static.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
" f: double\n"
|
" f: double\n"
|
||||||
"\n"
|
"\n"
|
||||||
" func3static(A e, short arg2, Tuple hello) -> int\n"
|
" func3static(A e, short arg2, Tuple hello) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" e: A *\n"
|
" e: A *\n"
|
||||||
" arg2: short\n"
|
" arg2: short\n"
|
||||||
" hello: int tuple[2]\n"
|
" hello: int tuple[2]\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||||
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
" f: double\n"
|
||||||
" f: double\n"
|
"\n"
|
||||||
"\n"
|
"func3static(A e, short arg2, Tuple hello) -> int\n"
|
||||||
"func3static(A e, short arg2, Tuple hello) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" e: A *\n"
|
||||||
" e: A *\n"
|
" arg2: short\n"
|
||||||
" arg2: short\n"
|
" hello: int tuple[2]\n"
|
||||||
" hello: int tuple[2]\n"
|
"\n"
|
||||||
"\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if sys.version_info[0:2] > (2, 4):
|
if sys.version_info[0:2] > (2, 4):
|
||||||
# Python 2.4 does not seem to work
|
# Python 2.4 does not seem to work
|
||||||
check(A.variable_a.__doc__,
|
check(A.variable_a.__doc__,
|
||||||
"A_variable_a_get(self) -> int",
|
"A_variable_a_get(self) -> int",
|
||||||
"A.variable_a"
|
"A.variable_a"
|
||||||
)
|
)
|
||||||
check(A.variable_b.__doc__,
|
check(A.variable_b.__doc__,
|
||||||
"A_variable_b_get(A self) -> int",
|
"A_variable_b_get(A self) -> int",
|
||||||
"A.variable_b"
|
"A.variable_b"
|
||||||
)
|
)
|
||||||
check(A.variable_c.__doc__,
|
check(A.variable_c.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
"A_variable_c_get(self) -> int\n"
|
"A_variable_c_get(self) -> int\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Parameters:\n"
|
"Parameters:\n"
|
||||||
" self: A *\n"
|
" self: A *\n"
|
||||||
"\n"
|
"\n",
|
||||||
,
|
"A.variable_c"
|
||||||
"A.variable_c"
|
)
|
||||||
)
|
check(A.variable_d.__doc__,
|
||||||
check(A.variable_d.__doc__,
|
"\n"
|
||||||
"\n"
|
"A_variable_d_get(A self) -> int\n"
|
||||||
"A_variable_d_get(A self) -> int\n"
|
"\n"
|
||||||
"\n"
|
"Parameters:\n"
|
||||||
"Parameters:\n"
|
" self: A *\n"
|
||||||
" self: A *\n"
|
"\n",
|
||||||
"\n"
|
"A.variable_d"
|
||||||
,
|
)
|
||||||
"A.variable_d"
|
|
||||||
)
|
|
||||||
|
|
||||||
check(B.__doc__,
|
check(B.__doc__,
|
||||||
"Proxy of C++ B class",
|
"Proxy of C++ B class",
|
||||||
"::B"
|
"::B"
|
||||||
)
|
)
|
||||||
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
|
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
|
||||||
check(D.__init__.__doc__, "__init__(D self, int a, int b, Hola h) -> D", None, skip)
|
check(D.__init__.__doc__,
|
||||||
|
"__init__(D self, int a, int b, Hola h) -> D", None, skip)
|
||||||
check(E.__init__.__doc__,
|
check(E.__init__.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" __init__(self, a, b, h) -> E\n"
|
" __init__(self, a, b, h) -> E\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" a: special comment for parameter a\n"
|
" a: special comment for parameter a\n"
|
||||||
" b: another special comment for parameter b\n"
|
" b: another special comment for parameter b\n"
|
||||||
" h: enum Hola\n"
|
" h: enum Hola\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ", None, skip
|
||||||
, None, skip
|
)
|
||||||
)
|
|
||||||
check(F.__init__.__doc__,
|
check(F.__init__.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" __init__(F self, int a, int b, Hola h) -> F\n"
|
" __init__(F self, int a, int b, Hola h) -> F\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Parameters:\n"
|
" Parameters:\n"
|
||||||
" a: special comment for parameter a\n"
|
" a: special comment for parameter a\n"
|
||||||
" b: another special comment for parameter b\n"
|
" b: another special comment for parameter b\n"
|
||||||
" h: enum Hola\n"
|
" h: enum Hola\n"
|
||||||
"\n"
|
"\n"
|
||||||
" "
|
" ", None, skip
|
||||||
, None, skip
|
)
|
||||||
)
|
|
||||||
|
|
||||||
check(B.funk.__doc__,
|
check(B.funk.__doc__,
|
||||||
"funk(B self, int c, int d) -> int",
|
"funk(B self, int c, int d) -> int",
|
||||||
"funk(int c, int d) -> int")
|
"funk(int c, int d) -> int")
|
||||||
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
|
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
|
||||||
check(funkdefaults.__doc__,
|
check(funkdefaults.__doc__,
|
||||||
"\n"
|
"\n"
|
||||||
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
||||||
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
" funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
||||||
" "
|
" ",
|
||||||
,
|
"\n"
|
||||||
"\n"
|
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
||||||
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
|
"funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
||||||
"funkdefaults(A e, short arg2, int c, int d) -> int\n"
|
""
|
||||||
""
|
)
|
||||||
)
|
|
||||||
|
|
||||||
check(func_input.__doc__, "func_input(int * INPUT) -> int")
|
check(func_input.__doc__, "func_input(int * INPUT) -> int")
|
||||||
check(func_output.__doc__, "func_output() -> int")
|
check(func_output.__doc__, "func_output() -> int")
|
||||||
|
|
|
||||||
|
|
@ -2,30 +2,30 @@ import _callback
|
||||||
from callback import *
|
from callback import *
|
||||||
|
|
||||||
if foo(2) != 2:
|
if foo(2) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if A_bar(2) != 4:
|
if A_bar(2) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foobar(3, _callback.foo) != foo(3):
|
if foobar(3, _callback.foo) != foo(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foobar(3, foo) != foo(3):
|
if foobar(3, foo) != foo(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foobar(3, A_bar) != A_bar(3):
|
if foobar(3, A_bar) != A_bar(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foobar(3, foof) != foof(3):
|
if foobar(3, foof) != foof(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foobar_i(3, foo_i) != foo_i(3):
|
if foobar_i(3, foo_i) != foo_i(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
if foobar_d(3.5, foo_d) != foo_d(3.5):
|
if foobar_d(3.5, foo_d) != foo_d(3.5):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
|
if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ from char_binary import *
|
||||||
|
|
||||||
t = Test()
|
t = Test()
|
||||||
if t.strlen('hile') != 4:
|
if t.strlen('hile') != 4:
|
||||||
print t.strlen('hile')
|
print t.strlen('hile')
|
||||||
raise RuntimeError, "bad multi-arg typemap"
|
raise RuntimeError, "bad multi-arg typemap"
|
||||||
|
|
||||||
if t.strlen('hil\0') != 4:
|
if t.strlen('hil\0') != 4:
|
||||||
raise RuntimeError, "bad multi-arg typemap"
|
raise RuntimeError, "bad multi-arg typemap"
|
||||||
|
|
||||||
#
|
#
|
||||||
# creating a raw char*
|
# creating a raw char*
|
||||||
|
|
@ -20,17 +20,16 @@ pchar_setitem(pc, 4, 0)
|
||||||
|
|
||||||
|
|
||||||
if t.strlen(pc) != 4:
|
if t.strlen(pc) != 4:
|
||||||
raise RuntimeError, "bad multi-arg typemap"
|
raise RuntimeError, "bad multi-arg typemap"
|
||||||
|
|
||||||
cvar.var_pchar = pc
|
cvar.var_pchar = pc
|
||||||
if cvar.var_pchar != "hola":
|
if cvar.var_pchar != "hola":
|
||||||
print cvar.var_pchar
|
print cvar.var_pchar
|
||||||
raise RuntimeError, "bad pointer case"
|
raise RuntimeError, "bad pointer case"
|
||||||
|
|
||||||
cvar.var_namet = pc
|
cvar.var_namet = pc
|
||||||
#if cvar.var_namet != "hola\0":
|
# if cvar.var_namet != "hola\0":
|
||||||
if cvar.var_namet != "hola":
|
if cvar.var_namet != "hola":
|
||||||
raise RuntimeError, "bad pointer case"
|
raise RuntimeError, "bad pointer case"
|
||||||
|
|
||||||
delete_pchar(pc)
|
delete_pchar(pc)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,17 +4,16 @@ defaults1 = Defaults1(1000)
|
||||||
defaults1 = Defaults1()
|
defaults1 = Defaults1()
|
||||||
|
|
||||||
if defaults1.ret(10.0) != 10.0:
|
if defaults1.ret(10.0) != 10.0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if defaults1.ret() != -1.0:
|
if defaults1.ret() != -1.0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
defaults2 = Defaults2(1000)
|
defaults2 = Defaults2(1000)
|
||||||
defaults2 = Defaults2()
|
defaults2 = Defaults2()
|
||||||
|
|
||||||
if defaults2.ret(10.0) != 10.0:
|
if defaults2.ret(10.0) != 10.0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if defaults2.ret() != -1.0:
|
if defaults2.ret() != -1.0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
import complextest
|
import complextest
|
||||||
|
|
||||||
a = complex(-1,2)
|
a = complex(-1, 2)
|
||||||
|
|
||||||
if complextest.Conj(a) != a.conjugate():
|
if complextest.Conj(a) != a.conjugate():
|
||||||
raise RuntimeError, "bad complex mapping"
|
raise RuntimeError, "bad complex mapping"
|
||||||
|
|
||||||
if complextest.Conjf(a) != a.conjugate():
|
if complextest.Conjf(a) != a.conjugate():
|
||||||
raise RuntimeError, "bad complex mapping"
|
raise RuntimeError, "bad complex mapping"
|
||||||
|
|
||||||
|
|
||||||
v = (complex(1,2), complex(2,3), complex(4,3), 1)
|
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
complextest.Copy_h(v)
|
complextest.Copy_h(v)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,20 @@
|
||||||
import constant_directive
|
import constant_directive
|
||||||
|
|
||||||
if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
|
if not isinstance(constant_directive.TYPE1_CONSTANT1, constant_directive.Type1):
|
||||||
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
|
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(
|
||||||
if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
|
type(constant_directive.TYPE1_CONSTANT1)))
|
||||||
raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
|
if not isinstance(constant_directive.getType1Instance(), constant_directive.Type1):
|
||||||
|
raise RuntimeError("Failure: getType1Instance() type: {}".format(
|
||||||
|
type(constant_directive.getType1Instance())))
|
||||||
|
|
||||||
if constant_directive.TYPE1_CONSTANT1.val != 1:
|
if constant_directive.TYPE1_CONSTANT1.val != 1:
|
||||||
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
|
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" %
|
||||||
|
constant_directive.TYPE1_CONSTANT1.val)
|
||||||
|
|
||||||
if constant_directive.TYPE1_CONSTANT2.val != 2:
|
if constant_directive.TYPE1_CONSTANT2.val != 2:
|
||||||
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
|
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" %
|
||||||
|
constant_directive.TYPE1_CONSTANT2.val)
|
||||||
|
|
||||||
if constant_directive.TYPE1_CONSTANT3.val != 3:
|
if constant_directive.TYPE1_CONSTANT3.val != 3:
|
||||||
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)
|
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" %
|
||||||
|
constant_directive.TYPE1_CONSTANT3.val)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ p = constover.test_pconst("test")
|
||||||
if p != "test_pconst":
|
if p != "test_pconst":
|
||||||
print "test_pconst failed!"
|
print "test_pconst failed!"
|
||||||
error = 1
|
error = 1
|
||||||
|
|
||||||
f = constover.Foo()
|
f = constover.Foo()
|
||||||
p = f.test("test")
|
p = f.test("test")
|
||||||
if p != "test":
|
if p != "test":
|
||||||
|
|
@ -32,7 +32,5 @@ p = f.test_pconstm("test")
|
||||||
if p != "test_pconstmethod":
|
if p != "test_pconstmethod":
|
||||||
print "member-test_pconstm failed!"
|
print "member-test_pconstm failed!"
|
||||||
error = 1
|
error = 1
|
||||||
|
|
||||||
sys.exit(error)
|
sys.exit(error)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from constructor_copy import *
|
from constructor_copy import *
|
||||||
|
|
||||||
f1 = Foo1(3);
|
f1 = Foo1(3)
|
||||||
f11 = Foo1(f1);
|
f11 = Foo1(f1)
|
||||||
|
|
||||||
|
|
||||||
if f1.x != f11.x:
|
if f1.x != f11.x:
|
||||||
|
|
@ -24,7 +24,7 @@ bc = Bari(bi)
|
||||||
|
|
||||||
if (bi.x != bc.x):
|
if (bi.x != bc.x):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
bd = Bard(5)
|
bd = Bard(5)
|
||||||
try:
|
try:
|
||||||
|
|
@ -35,4 +35,3 @@ except:
|
||||||
|
|
||||||
if not good:
|
if not good:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,143 +1,142 @@
|
||||||
import contract
|
import contract
|
||||||
|
|
||||||
contract.test_preassert(1,2)
|
contract.test_preassert(1, 2)
|
||||||
try:
|
try:
|
||||||
contract.test_preassert(-1)
|
contract.test_preassert(-1)
|
||||||
print "Failed! Preassertions are broken"
|
print "Failed! Preassertions are broken"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
contract.test_postassert(3)
|
contract.test_postassert(3)
|
||||||
try:
|
try:
|
||||||
contract.test_postassert(-3)
|
contract.test_postassert(-3)
|
||||||
print "Failed! Postassertions are broken"
|
print "Failed! Postassertions are broken"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
contract.test_prepost(2,3)
|
contract.test_prepost(2, 3)
|
||||||
contract.test_prepost(5,-4)
|
contract.test_prepost(5, -4)
|
||||||
try:
|
try:
|
||||||
contract.test_prepost(-3,4)
|
contract.test_prepost(-3, 4)
|
||||||
print "Failed! Preassertions are broken"
|
print "Failed! Preassertions are broken"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
contract.test_prepost(4,-10)
|
contract.test_prepost(4, -10)
|
||||||
print "Failed! Postassertions are broken"
|
print "Failed! Postassertions are broken"
|
||||||
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
f = contract.Foo()
|
f = contract.Foo()
|
||||||
f.test_preassert(4,5)
|
f.test_preassert(4, 5)
|
||||||
try:
|
try:
|
||||||
f.test_preassert(-2,3)
|
f.test_preassert(-2, 3)
|
||||||
print "Failed! Method preassertion."
|
print "Failed! Method preassertion."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
f.test_postassert(4)
|
f.test_postassert(4)
|
||||||
try:
|
try:
|
||||||
f.test_postassert(-4)
|
f.test_postassert(-4)
|
||||||
print "Failed! Method postassertion"
|
print "Failed! Method postassertion"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
f.test_prepost(3,4)
|
f.test_prepost(3, 4)
|
||||||
f.test_prepost(4,-3)
|
f.test_prepost(4, -3)
|
||||||
try:
|
try:
|
||||||
f.test_prepost(-4,2)
|
f.test_prepost(-4, 2)
|
||||||
print "Failed! Method preassertion."
|
print "Failed! Method preassertion."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f.test_prepost(4,-10)
|
f.test_prepost(4, -10)
|
||||||
print "Failed! Method postassertion."
|
print "Failed! Method postassertion."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
contract.Foo_stest_prepost(4,0)
|
contract.Foo_stest_prepost(4, 0)
|
||||||
try:
|
try:
|
||||||
contract.Foo_stest_prepost(-4,2)
|
contract.Foo_stest_prepost(-4, 2)
|
||||||
print "Failed! Static method preassertion"
|
print "Failed! Static method preassertion"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
contract.Foo_stest_prepost(4,-10)
|
contract.Foo_stest_prepost(4, -10)
|
||||||
print "Failed! Static method posteassertion"
|
print "Failed! Static method posteassertion"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
b = contract.Bar()
|
b = contract.Bar()
|
||||||
try:
|
try:
|
||||||
b.test_prepost(2,-4)
|
b.test_prepost(2, -4)
|
||||||
print "Failed! Inherited preassertion."
|
print "Failed! Inherited preassertion."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
d = contract.D()
|
d = contract.D()
|
||||||
try:
|
try:
|
||||||
d.foo(-1,1,1,1,1)
|
d.foo(-1, 1, 1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.foo(1,-1,1,1,1)
|
d.foo(1, -1, 1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.foo(1,1,-1,1,1)
|
d.foo(1, 1, -1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.foo(1,1,1,-1,1)
|
d.foo(1, 1, 1, -1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.foo(1,1,1,1,-1)
|
d.foo(1, 1, 1, 1, -1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d.bar(-1,1,1,1,1)
|
d.bar(-1, 1, 1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.bar(1,-1,1,1,1)
|
d.bar(1, -1, 1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.bar(1,1,-1,1,1)
|
d.bar(1, 1, -1, 1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.bar(1,1,1,-1,1)
|
d.bar(1, 1, 1, -1, 1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
d.bar(1,1,1,1,-1)
|
d.bar(1, 1, 1, 1, -1)
|
||||||
print "Failed! Inherited preassertion (D)."
|
print "Failed! Inherited preassertion (D)."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
#Namespace
|
# Namespace
|
||||||
my = contract.myClass(1)
|
my = contract.myClass(1)
|
||||||
try:
|
try:
|
||||||
my = contract.myClass(0)
|
my = contract.myClass(0)
|
||||||
print "Failed! constructor preassertion"
|
print "Failed! constructor preassertion"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ import cpp11_alternate_function_syntax
|
||||||
|
|
||||||
a = cpp11_alternate_function_syntax.SomeStruct()
|
a = cpp11_alternate_function_syntax.SomeStruct()
|
||||||
|
|
||||||
res = a.addNormal(4,5)
|
res = a.addNormal(4, 5)
|
||||||
if res != 9:
|
if res != 9:
|
||||||
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ", res, " should be 9.")
|
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
|
||||||
|
res, " should be 9.")
|
||||||
|
|
||||||
|
|
||||||
res = a.addAlternate(4,5)
|
res = a.addAlternate(4, 5)
|
||||||
if res != 9:
|
if res != 9:
|
||||||
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ", res, " should be 9.")
|
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
|
||||||
|
res, " should be 9.")
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,16 @@ import cpp11_decltype
|
||||||
a = cpp11_decltype.A()
|
a = cpp11_decltype.A()
|
||||||
a.i = 5
|
a.i = 5
|
||||||
if a.i != 5:
|
if a.i != 5:
|
||||||
raise RuntimeError, "Assignment to a.i failed."
|
raise RuntimeError, "Assignment to a.i failed."
|
||||||
|
|
||||||
a.j = 10
|
a.j = 10
|
||||||
if a.j != 10:
|
if a.j != 10:
|
||||||
raise RuntimeError, "Assignment to a.j failed."
|
raise RuntimeError, "Assignment to a.j failed."
|
||||||
|
|
||||||
b = a.foo(5)
|
b = a.foo(5)
|
||||||
if b != 10:
|
if b != 10:
|
||||||
raise RuntimeError, "foo(5) should return 10."
|
raise RuntimeError, "foo(5) should return 10."
|
||||||
|
|
||||||
b = a.foo(6)
|
b = a.foo(6)
|
||||||
if b != 0:
|
if b != 0:
|
||||||
raise RuntimeError, "foo(6) should return 0."
|
raise RuntimeError, "foo(6) should return 0."
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import cpp11_function_objects
|
import cpp11_function_objects
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Test1(cpp11_function_objects.Test):
|
class Test1(cpp11_function_objects.Test):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
cpp11_function_objects.Test.__init__(self)
|
cpp11_function_objects.Test.__init__(self)
|
||||||
|
|
||||||
|
|
@ -10,14 +12,17 @@ class Test1(cpp11_function_objects.Test):
|
||||||
|
|
||||||
t = cpp11_function_objects.Test()
|
t = cpp11_function_objects.Test()
|
||||||
if t.value != 0:
|
if t.value != 0:
|
||||||
raise RuntimeError("Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
|
raise RuntimeError(
|
||||||
|
"Runtime cpp11_function_objects failed. t.value should be 0, but is " + str(t.value))
|
||||||
|
|
||||||
t(1,2) # adds numbers and sets value
|
t(1, 2) # adds numbers and sets value
|
||||||
|
|
||||||
if t.value != 3:
|
if t.value != 3:
|
||||||
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
|
raise RuntimeError(
|
||||||
|
"Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
|
||||||
|
|
||||||
t2 = Test1()
|
t2 = Test1()
|
||||||
a = cpp11_function_objects.testit1(t2, 4,3)
|
a = cpp11_function_objects.testit1(t2, 4, 3)
|
||||||
if a != 12:
|
if a != 12:
|
||||||
raise RuntimeError("Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
|
raise RuntimeError(
|
||||||
|
"Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import cpp11_initializer_list_extend
|
import cpp11_initializer_list_extend
|
||||||
|
|
||||||
c = cpp11_initializer_list_extend.Container( [10, 20, 30, 40] )
|
c = cpp11_initializer_list_extend.Container([10, 20, 30, 40])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,3 @@ import cpp11_initializer_list
|
||||||
|
|
||||||
a = cpp11_initializer_list.A()
|
a = cpp11_initializer_list.A()
|
||||||
a = cpp11_initializer_list.A(11.1)
|
a = cpp11_initializer_list.A(11.1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@ import cpp11_null_pointer_constant
|
||||||
a = cpp11_null_pointer_constant.A()
|
a = cpp11_null_pointer_constant.A()
|
||||||
|
|
||||||
if a._myA != None:
|
if a._myA != None:
|
||||||
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
|
raise RuntimeError, (
|
||||||
|
"cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
|
||||||
|
|
||||||
b = cpp11_null_pointer_constant.A()
|
b = cpp11_null_pointer_constant.A()
|
||||||
if a._myA != b._myA:
|
if a._myA != b._myA:
|
||||||
raise RuntimeError, ("cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
|
raise RuntimeError, (
|
||||||
|
"cpp11_null_pointer_constant: a._myA should be the same as b._myA, but ", a._myA, "!=", b._myA)
|
||||||
|
|
||||||
a._myA = cpp11_null_pointer_constant.A()
|
a._myA = cpp11_null_pointer_constant.A()
|
||||||
if a._myA == None:
|
if a._myA == None:
|
||||||
raise RuntimeError, ("cpp11_null_pointer_constant: _myA should be object, but is None")
|
raise RuntimeError, (
|
||||||
|
"cpp11_null_pointer_constant: _myA should be object, but is None")
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,48 @@
|
||||||
from cpp11_raw_string_literals import *
|
from cpp11_raw_string_literals import *
|
||||||
|
|
||||||
if cvar.L != 100:
|
if cvar.L != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.u8 != 100:
|
if cvar.u8 != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.u != 100:
|
if cvar.u != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if UStruct.U != 100:
|
if UStruct.U != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
if cvar.R != 100:
|
if cvar.R != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.LR != 100:
|
if cvar.LR != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.u8R != 100:
|
if cvar.u8R != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.uR != 100:
|
if cvar.uR != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if URStruct.UR != 100:
|
if URStruct.UR != 100:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
if cvar.aa != "Wide string":
|
if cvar.aa != "Wide string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if cvar.bb != "UTF-8 string":
|
if cvar.bb != "UTF-8 string":
|
||||||
raise RuntimeError, cvar.wide
|
raise RuntimeError, cvar.wide
|
||||||
|
|
||||||
if cvar.xx != ")I'm an \"ascii\" \\ string.":
|
if cvar.xx != ")I'm an \"ascii\" \\ string.":
|
||||||
raise RuntimeError, cvar.xx
|
raise RuntimeError, cvar.xx
|
||||||
|
|
||||||
if cvar.ee != ")I'm an \"ascii\" \\ string.":
|
if cvar.ee != ")I'm an \"ascii\" \\ string.":
|
||||||
raise RuntimeError, cvar.ee
|
raise RuntimeError, cvar.ee
|
||||||
|
|
||||||
if cvar.ff != "I'm a \"raw wide\" \\ string.":
|
if cvar.ff != "I'm a \"raw wide\" \\ string.":
|
||||||
raise RuntimeError, cvar.ff
|
raise RuntimeError, cvar.ff
|
||||||
|
|
||||||
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
|
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
|
||||||
raise RuntimeError, cvar.gg
|
raise RuntimeError, cvar.gg
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ import cpp11_result_of
|
||||||
|
|
||||||
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
|
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
|
||||||
if result != 9.0:
|
if result != 9.0:
|
||||||
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(result)
|
raise RuntimeError, "test_result(square, 3.0) is not 9.0. Got: " + str(
|
||||||
|
result)
|
||||||
|
|
||||||
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
|
result = cpp11_result_of.test_result_alternative1(cpp11_result_of.SQUARE, 3.0)
|
||||||
if result != 9.0:
|
if result != 9.0:
|
||||||
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(result)
|
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
|
||||||
|
result)
|
||||||
|
|
|
||||||
|
|
@ -4,21 +4,24 @@ a = cpp11_rvalue_reference.A()
|
||||||
|
|
||||||
a.setAcopy(5)
|
a.setAcopy(5)
|
||||||
if a.getAcopy() != 5:
|
if a.getAcopy() != 5:
|
||||||
raise RunTimeError, ("int A::getAcopy() value is ", a.getAcopy(), " should be 5")
|
raise RunTimeError, ("int A::getAcopy() value is ",
|
||||||
|
a.getAcopy(), " should be 5")
|
||||||
|
|
||||||
ptr = a.getAptr()
|
ptr = a.getAptr()
|
||||||
|
|
||||||
a.setAptr(ptr)
|
a.setAptr(ptr)
|
||||||
if a.getAcopy() != 5:
|
if a.getAcopy() != 5:
|
||||||
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
|
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
|
||||||
|
), " should be 5")
|
||||||
|
|
||||||
a.setAref(ptr)
|
a.setAref(ptr)
|
||||||
if a.getAcopy() != 5:
|
if a.getAcopy() != 5:
|
||||||
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
|
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
|
||||||
|
), " should be 5")
|
||||||
|
|
||||||
rvalueref = a.getAmove()
|
rvalueref = a.getAmove()
|
||||||
|
|
||||||
a.setAmove(rvalueref)
|
a.setAmove(rvalueref)
|
||||||
if a.getAcopy() != 5:
|
if a.getAcopy() != 5:
|
||||||
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(), " should be 5")
|
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
|
||||||
|
), " should be 5")
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
from cpp11_strongly_typed_enumerations import *
|
from cpp11_strongly_typed_enumerations import *
|
||||||
|
|
||||||
|
|
||||||
def enumCheck(actual, expected):
|
def enumCheck(actual, expected):
|
||||||
if actual != expected:
|
if actual != expected:
|
||||||
raise RuntimeError("Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
|
raise RuntimeError(
|
||||||
return expected + 1
|
"Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
|
||||||
|
return expected + 1
|
||||||
|
|
||||||
val = 0
|
val = 0
|
||||||
val = enumCheck(Enum1_Val1, val)
|
val = enumCheck(Enum1_Val1, val)
|
||||||
|
|
@ -161,4 +163,3 @@ enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121)
|
||||||
enumCheck(globalTest1(Enum1_Val5a), 13)
|
enumCheck(globalTest1(Enum1_Val5a), 13)
|
||||||
enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
|
enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
|
||||||
#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)
|
#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,37 +2,36 @@ from cpp11_thread_local import *
|
||||||
|
|
||||||
t = ThreadLocals()
|
t = ThreadLocals()
|
||||||
if t.stval != 11:
|
if t.stval != 11:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if t.tsval != 22:
|
if t.tsval != 22:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if t.tscval99 != 99:
|
if t.tscval99 != 99:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.etval = -11
|
cvar.etval = -11
|
||||||
if cvar.etval != -11:
|
if cvar.etval != -11:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.stval = -22
|
cvar.stval = -22
|
||||||
if cvar.stval != -22:
|
if cvar.stval != -22:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.tsval = -33
|
cvar.tsval = -33
|
||||||
if cvar.tsval != -33:
|
if cvar.tsval != -33:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.etval = -44
|
cvar.etval = -44
|
||||||
if cvar.etval != -44:
|
if cvar.etval != -44:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.teval = -55
|
cvar.teval = -55
|
||||||
if cvar.teval != -55:
|
if cvar.teval != -55:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.ectval = -66
|
cvar.ectval = -66
|
||||||
if cvar.ectval != -66:
|
if cvar.ectval != -66:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cvar.ecpptval = -66
|
cvar.ecpptval = -66
|
||||||
if cvar.ecpptval != -66:
|
if cvar.ecpptval != -66:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from cpp11_type_traits import *
|
from cpp11_type_traits import *
|
||||||
|
|
||||||
if Elaborate(0, 0) != 1:
|
if Elaborate(0, 0) != 1:
|
||||||
raise RuntimeError("Elaborate should have returned 1")
|
raise RuntimeError("Elaborate should have returned 1")
|
||||||
|
|
||||||
if Elaborate(0, 0.0) != 2:
|
if Elaborate(0, 0.0) != 2:
|
||||||
raise RuntimeError("Elaborate should have returned 2")
|
raise RuntimeError("Elaborate should have returned 2")
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,20 @@ import cpp11_uniform_initialization
|
||||||
|
|
||||||
var1 = cpp11_uniform_initialization.cvar.var1
|
var1 = cpp11_uniform_initialization.cvar.var1
|
||||||
if var1.x != 5:
|
if var1.x != 5:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
var2 = cpp11_uniform_initialization.cvar.var2
|
var2 = cpp11_uniform_initialization.cvar.var2
|
||||||
if var2.getX() != 2:
|
if var2.getX() != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
m = cpp11_uniform_initialization.MoreInit()
|
m = cpp11_uniform_initialization.MoreInit()
|
||||||
if m.charptr != None:
|
if m.charptr != None:
|
||||||
raise RuntimeError, m.charptr
|
raise RuntimeError, m.charptr
|
||||||
m.charptr = "hello sir"
|
m.charptr = "hello sir"
|
||||||
if m.charptr != "hello sir":
|
if m.charptr != "hello sir":
|
||||||
raise RuntimeError, m.charptr
|
raise RuntimeError, m.charptr
|
||||||
if m.more1(m.vi) != 15:
|
if m.more1(m.vi) != 15:
|
||||||
raise RuntimeError, m.vi
|
raise RuntimeError, m.vi
|
||||||
if m.more1( [-1,1,2] ) != 2:
|
if m.more1([-1, 1, 2]) != 2:
|
||||||
raise RuntimeError, m.vi
|
raise RuntimeError, m.vi
|
||||||
if m.more1() != 10:
|
if m.more1() != 10:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,21 @@ import cpp_enum
|
||||||
f = cpp_enum.Foo()
|
f = cpp_enum.Foo()
|
||||||
|
|
||||||
if f.hola != f.Hello:
|
if f.hola != f.Hello:
|
||||||
print f.hola
|
print f.hola
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
f.hola = f.Hi
|
f.hola = f.Hi
|
||||||
if f.hola != f.Hi:
|
if f.hola != f.Hi:
|
||||||
print f.hola
|
print f.hola
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
f.hola = f.Hello
|
f.hola = f.Hello
|
||||||
|
|
||||||
if f.hola != f.Hello:
|
if f.hola != f.Hello:
|
||||||
print f.hola
|
print f.hola
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
cpp_enum.cvar.hi = cpp_enum.Hello
|
cpp_enum.cvar.hi = cpp_enum.Hello
|
||||||
if cpp_enum.cvar.hi != cpp_enum.Hello:
|
if cpp_enum.cvar.hi != cpp_enum.Hello:
|
||||||
print cpp_enum.cvar.hi
|
print cpp_enum.cvar.hi
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ if cpp_namespace.do_method(t) != "Test::method":
|
||||||
|
|
||||||
if cpp_namespace.do_method2(t) != "Test::method":
|
if cpp_namespace.do_method2(t) != "Test::method":
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
cpp_namespace.weird("hello", 4)
|
cpp_namespace.weird("hello", 4)
|
||||||
|
|
||||||
del t
|
del t
|
||||||
|
|
@ -30,16 +30,14 @@ t5 = cpp_namespace.Test5()
|
||||||
if cpp_namespace.foo3(42) != 42:
|
if cpp_namespace.foo3(42) != 42:
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
if cpp_namespace.do_method3(t2,40) != "Test2::method":
|
if cpp_namespace.do_method3(t2, 40) != "Test2::method":
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
if cpp_namespace.do_method3(t3,40) != "Test3::method":
|
if cpp_namespace.do_method3(t3, 40) != "Test3::method":
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
if cpp_namespace.do_method3(t4,40) != "Test4::method":
|
if cpp_namespace.do_method3(t4, 40) != "Test4::method":
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
if cpp_namespace.do_method3(t5,40) != "Test5::method":
|
if cpp_namespace.do_method3(t5, 40) != "Test5::method":
|
||||||
raise RuntimeError("Bad return value!")
|
raise RuntimeError("Bad return value!")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,17 @@
|
||||||
#!/usr/bin/evn python
|
#!/usr/bin/evn python
|
||||||
from cpp_static import *
|
from cpp_static import *
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
if is_new_style_class(StaticFunctionTest):
|
if is_new_style_class(StaticFunctionTest):
|
||||||
StaticFunctionTest.static_func()
|
StaticFunctionTest.static_func()
|
||||||
StaticFunctionTest.static_func_2(1)
|
StaticFunctionTest.static_func_2(1)
|
||||||
StaticFunctionTest.static_func_3(1,2)
|
StaticFunctionTest.static_func_3(1, 2)
|
||||||
else:
|
else:
|
||||||
StaticFunctionTest().static_func()
|
StaticFunctionTest().static_func()
|
||||||
StaticFunctionTest().static_func_2(1)
|
StaticFunctionTest().static_func_2(1)
|
||||||
StaticFunctionTest().static_func_3(1,2)
|
StaticFunctionTest().static_func_3(1, 2)
|
||||||
StaticMemberTest.static_int = 10
|
StaticMemberTest.static_int = 10
|
||||||
assert StaticMemberTest.static_int == 10
|
assert StaticMemberTest.static_int == 10
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,17 @@ from default_arg_values import *
|
||||||
d = Display()
|
d = Display()
|
||||||
|
|
||||||
if d.draw1() != 0:
|
if d.draw1() != 0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if d.draw1(12) != 12:
|
if d.draw1(12) != 12:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
p = createPtr(123);
|
p = createPtr(123)
|
||||||
if d.draw2() != 0:
|
if d.draw2() != 0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if d.draw2(p) != 123:
|
if d.draw2(p) != 123:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if d.bool0() != False or type(d.bool0()) != type(False):
|
if d.bool0() != False or type(d.bool0()) != type(False):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,122 +1,133 @@
|
||||||
# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
|
# Note that this test is also used by python_default_args_runme.py hence
|
||||||
|
# the use of __main__ and the run function
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
|
|
||||||
def run(module_name):
|
def run(module_name):
|
||||||
default_args = __import__(module_name)
|
default_args = __import__(module_name)
|
||||||
ec = default_args.EnumClass()
|
ec = default_args.EnumClass()
|
||||||
if not ec.blah():
|
if not ec.blah():
|
||||||
raise RuntimeError("EnumClass::blah() default arguments don't work")
|
raise RuntimeError("EnumClass::blah() default arguments don't work")
|
||||||
|
|
||||||
de = default_args.DerivedEnumClass()
|
de = default_args.DerivedEnumClass()
|
||||||
de.accelerate()
|
de.accelerate()
|
||||||
de.accelerate(default_args.EnumClass.SLOW)
|
de.accelerate(default_args.EnumClass.SLOW)
|
||||||
|
|
||||||
if default_args.Statics_staticMethod() != 60:
|
if default_args.Statics_staticMethod() != 60:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if default_args.cfunc1(1) != 2:
|
if default_args.cfunc1(1) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if default_args.cfunc2(1) != 3:
|
if default_args.cfunc2(1) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if default_args.cfunc3(1) != 4:
|
if default_args.cfunc3(1) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
f = default_args.Foo()
|
||||||
|
|
||||||
|
f.newname()
|
||||||
|
f.newname(1)
|
||||||
|
|
||||||
|
if f.double_if_void_ptr_is_null(2, None) != 4:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.double_if_void_ptr_is_null(3) != 6:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.double_if_handle_is_null(4, None) != 8:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.double_if_handle_is_null(5) != 10:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.double_if_dbl_ptr_is_null(6, None) != 12:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.double_if_dbl_ptr_is_null(7) != 14:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = default_args.Foo(1)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::Foo ignore is not working")
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = default_args.Foo(1, 2)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::Foo ignore is not working")
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = default_args.Foo(1, 2, 3)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::Foo ignore is not working")
|
||||||
|
|
||||||
|
try:
|
||||||
|
m = f.meth(1)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::meth ignore is not working")
|
||||||
|
|
||||||
|
try:
|
||||||
|
m = f.meth(1, 2)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::meth ignore is not working")
|
||||||
|
|
||||||
|
try:
|
||||||
|
m = f.meth(1, 2, 3)
|
||||||
|
error = 1
|
||||||
|
except:
|
||||||
|
error = 0
|
||||||
|
if error:
|
||||||
|
raise RuntimeError("Foo::meth ignore is not working")
|
||||||
|
|
||||||
|
if is_new_style_class(default_args.Klass):
|
||||||
|
Klass_inc = default_args.Klass.inc
|
||||||
|
else:
|
||||||
|
Klass_inc = default_args.Klass_inc
|
||||||
|
|
||||||
|
if Klass_inc(100, default_args.Klass(22)).val != 122:
|
||||||
|
raise RuntimeError("Klass::inc failed")
|
||||||
|
|
||||||
|
if Klass_inc(100).val != 99:
|
||||||
|
raise RuntimeError("Klass::inc failed")
|
||||||
|
|
||||||
|
if Klass_inc().val != 0:
|
||||||
|
raise RuntimeError("Klass::inc failed")
|
||||||
|
|
||||||
|
default_args.trickyvalue1(10)
|
||||||
|
default_args.trickyvalue1(10, 10)
|
||||||
|
default_args.trickyvalue2(10)
|
||||||
|
default_args.trickyvalue2(10, 10)
|
||||||
|
default_args.trickyvalue3(10)
|
||||||
|
default_args.trickyvalue3(10, 10)
|
||||||
|
default_args.seek()
|
||||||
|
default_args.seek(10)
|
||||||
|
|
||||||
|
if default_args.slightly_off_square(10) != 102:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
if default_args.slightly_off_square() != 291:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
f = default_args.Foo()
|
if __name__ == "__main__":
|
||||||
|
run('default_args')
|
||||||
f.newname()
|
|
||||||
f.newname(1)
|
|
||||||
|
|
||||||
if f.double_if_void_ptr_is_null(2, None) != 4:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.double_if_void_ptr_is_null(3) != 6:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.double_if_handle_is_null(4, None) != 8:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.double_if_handle_is_null(5) != 10:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.double_if_dbl_ptr_is_null(6, None) != 12:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.double_if_dbl_ptr_is_null(7) != 14:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
try:
|
|
||||||
f = default_args.Foo(1)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::Foo ignore is not working")
|
|
||||||
|
|
||||||
try:
|
|
||||||
f = default_args.Foo(1,2)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::Foo ignore is not working")
|
|
||||||
|
|
||||||
try:
|
|
||||||
f = default_args.Foo(1,2,3)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::Foo ignore is not working")
|
|
||||||
|
|
||||||
try:
|
|
||||||
m = f.meth(1)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::meth ignore is not working")
|
|
||||||
|
|
||||||
try:
|
|
||||||
m = f.meth(1,2)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::meth ignore is not working")
|
|
||||||
|
|
||||||
try:
|
|
||||||
m = f.meth(1,2,3)
|
|
||||||
error = 1
|
|
||||||
except:
|
|
||||||
error = 0
|
|
||||||
if error: raise RuntimeError("Foo::meth ignore is not working")
|
|
||||||
|
|
||||||
if is_new_style_class(default_args.Klass):
|
|
||||||
Klass_inc = default_args.Klass.inc
|
|
||||||
else:
|
|
||||||
Klass_inc = default_args.Klass_inc
|
|
||||||
|
|
||||||
if Klass_inc(100, default_args.Klass(22)).val != 122:
|
|
||||||
raise RuntimeError("Klass::inc failed")
|
|
||||||
|
|
||||||
if Klass_inc(100).val != 99:
|
|
||||||
raise RuntimeError("Klass::inc failed")
|
|
||||||
|
|
||||||
if Klass_inc().val != 0:
|
|
||||||
raise RuntimeError("Klass::inc failed")
|
|
||||||
|
|
||||||
default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
|
|
||||||
default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
|
|
||||||
default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
|
|
||||||
default_args.seek(); default_args.seek(10)
|
|
||||||
|
|
||||||
if default_args.slightly_off_square(10) != 102:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if default_args.slightly_off_square() != 291:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
|
|
||||||
if __name__=="__main__":
|
|
||||||
run('default_args')
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import _default_constructor
|
||||||
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
|
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
|
||||||
# which is not provided with the -builtin option.
|
# which is not provided with the -builtin option.
|
||||||
if _default_constructor.is_python_builtin():
|
if _default_constructor.is_python_builtin():
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
dc = _default_constructor
|
dc = _default_constructor
|
||||||
|
|
||||||
|
|
@ -23,7 +23,7 @@ except:
|
||||||
del_b = dc.delete_B
|
del_b = dc.delete_B
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bb = dc.new_BB();
|
bb = dc.new_BB()
|
||||||
print "Whoa. new_BB created."
|
print "Whoa. new_BB created."
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -42,7 +42,7 @@ cc = dc.new_CC()
|
||||||
dc.delete_CC(cc)
|
dc.delete_CC(cc)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
d = dc.new_D();
|
d = dc.new_D()
|
||||||
print "Whoa. new_D created"
|
print "Whoa. new_D created"
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
@ -113,5 +113,4 @@ dc.delete_GG(gg)
|
||||||
|
|
||||||
|
|
||||||
import default_constructor
|
import default_constructor
|
||||||
hh = default_constructor.HH(1,1)
|
hh = default_constructor.HH(1, 1)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,79 +1,91 @@
|
||||||
import director_abstract
|
import director_abstract
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(director_abstract.Foo):
|
class MyFoo(director_abstract.Foo):
|
||||||
def __init__(self):
|
|
||||||
director_abstract.Foo.__init__(self)
|
def __init__(self):
|
||||||
def ping(self):
|
director_abstract.Foo.__init__(self)
|
||||||
return "MyFoo::ping()"
|
|
||||||
|
def ping(self):
|
||||||
|
return "MyFoo::ping()"
|
||||||
|
|
||||||
|
|
||||||
a = MyFoo()
|
a = MyFoo()
|
||||||
|
|
||||||
if a.ping() != "MyFoo::ping()":
|
if a.ping() != "MyFoo::ping()":
|
||||||
raise RuntimeError, a.ping()
|
raise RuntimeError, a.ping()
|
||||||
|
|
||||||
if a.pong() != "Foo::pong();MyFoo::ping()":
|
if a.pong() != "Foo::pong();MyFoo::ping()":
|
||||||
raise RuntimeError, a.pong()
|
raise RuntimeError, a.pong()
|
||||||
|
|
||||||
|
|
||||||
class MyExample1(director_abstract.Example1):
|
class MyExample1(director_abstract.Example1):
|
||||||
def Color(self, r, g, b):
|
|
||||||
return r
|
def Color(self, r, g, b):
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
class MyExample2(director_abstract.Example2):
|
class MyExample2(director_abstract.Example2):
|
||||||
def Color(self, r, g, b):
|
|
||||||
return g
|
def Color(self, r, g, b):
|
||||||
|
return g
|
||||||
|
|
||||||
|
|
||||||
class MyExample3(director_abstract.Example3_i):
|
class MyExample3(director_abstract.Example3_i):
|
||||||
def Color(self, r, g, b):
|
|
||||||
return b
|
def Color(self, r, g, b):
|
||||||
|
return b
|
||||||
|
|
||||||
me1 = MyExample1()
|
me1 = MyExample1()
|
||||||
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
|
if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if is_new_style_class(MyExample2):
|
if is_new_style_class(MyExample2):
|
||||||
MyExample2_static = MyExample2
|
MyExample2_static = MyExample2
|
||||||
else:
|
else:
|
||||||
MyExample2_static = MyExample2(0, 0)
|
MyExample2_static = MyExample2(0, 0)
|
||||||
me2 = MyExample2(1,2)
|
me2 = MyExample2(1, 2)
|
||||||
if MyExample2_static.get_color(me2, 1,2,3) != 2:
|
if MyExample2_static.get_color(me2, 1, 2, 3) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if is_new_style_class(MyExample3):
|
if is_new_style_class(MyExample3):
|
||||||
MyExample3_static = MyExample3
|
MyExample3_static = MyExample3
|
||||||
else:
|
else:
|
||||||
MyExample3_static = MyExample3()
|
MyExample3_static = MyExample3()
|
||||||
me3 = MyExample3()
|
me3 = MyExample3()
|
||||||
if MyExample3_static.get_color(me3, 1,2,3) != 3:
|
if MyExample3_static.get_color(me3, 1, 2, 3) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
error = 1
|
error = 1
|
||||||
try:
|
try:
|
||||||
me1 = director_abstract.Example1()
|
me1 = director_abstract.Example1()
|
||||||
except:
|
except:
|
||||||
error = 0
|
error = 0
|
||||||
if (error): raise RuntimeError
|
if (error):
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
error = 1
|
error = 1
|
||||||
try:
|
try:
|
||||||
me2 = director_abstract.Example2()
|
me2 = director_abstract.Example2()
|
||||||
except:
|
except:
|
||||||
error = 0
|
error = 0
|
||||||
if (error): raise RuntimeError
|
if (error):
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
error = 1
|
error = 1
|
||||||
try:
|
try:
|
||||||
me3 = director_abstract.Example3_i()
|
me3 = director_abstract.Example3_i()
|
||||||
except:
|
except:
|
||||||
error = 0
|
error = 0
|
||||||
if (error): raise RuntimeError
|
if (error):
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = director_abstract.A.f
|
f = director_abstract.A.f
|
||||||
except:
|
except:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,4 @@ from director_alternating import *
|
||||||
|
|
||||||
id = getBar().id()
|
id = getBar().id()
|
||||||
if id != idFromGetBar():
|
if id != idFromGetBar():
|
||||||
raise RuntimeError, "Got wrong id: " + str(id)
|
raise RuntimeError, "Got wrong id: " + str(id)
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,43 @@
|
||||||
import director_basic
|
import director_basic
|
||||||
|
|
||||||
|
|
||||||
class PyFoo(director_basic.Foo):
|
class PyFoo(director_basic.Foo):
|
||||||
def ping(self):
|
|
||||||
return "PyFoo::ping()"
|
def ping(self):
|
||||||
|
return "PyFoo::ping()"
|
||||||
|
|
||||||
|
|
||||||
a = PyFoo()
|
a = PyFoo()
|
||||||
|
|
||||||
if a.ping() != "PyFoo::ping()":
|
if a.ping() != "PyFoo::ping()":
|
||||||
raise RuntimeError, a.ping()
|
raise RuntimeError, a.ping()
|
||||||
|
|
||||||
if a.pong() != "Foo::pong();PyFoo::ping()":
|
if a.pong() != "Foo::pong();PyFoo::ping()":
|
||||||
raise RuntimeError, a.pong()
|
raise RuntimeError, a.pong()
|
||||||
|
|
||||||
b = director_basic.Foo()
|
b = director_basic.Foo()
|
||||||
|
|
||||||
if b.ping() != "Foo::ping()":
|
if b.ping() != "Foo::ping()":
|
||||||
raise RuntimeError, b.ping()
|
raise RuntimeError, b.ping()
|
||||||
|
|
||||||
if b.pong() != "Foo::pong();Foo::ping()":
|
if b.pong() != "Foo::pong();Foo::ping()":
|
||||||
raise RuntimeError, b.pong()
|
raise RuntimeError, b.pong()
|
||||||
|
|
||||||
a = director_basic.A1(1)
|
a = director_basic.A1(1)
|
||||||
|
|
||||||
if a.rg(2) != 2:
|
if a.rg(2) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PyClass(director_basic.MyClass):
|
class PyClass(director_basic.MyClass):
|
||||||
def method(self, vptr):
|
|
||||||
self.cmethod = 7
|
def method(self, vptr):
|
||||||
pass
|
self.cmethod = 7
|
||||||
|
pass
|
||||||
def vmethod(self, b):
|
|
||||||
b.x = b.x + 31
|
def vmethod(self, b):
|
||||||
return b
|
b.x = b.x + 31
|
||||||
|
return b
|
||||||
|
|
||||||
|
|
||||||
b = director_basic.Bar(3)
|
b = director_basic.Bar(3)
|
||||||
|
|
@ -50,49 +52,42 @@ bd = dd.cmethod(b)
|
||||||
|
|
||||||
cc.method(b)
|
cc.method(b)
|
||||||
if c.cmethod != 7:
|
if c.cmethod != 7:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if bc.x != 34:
|
if bc.x != 34:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
if bd.x != 16:
|
if bd.x != 16:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PyMulti(director_basic.Foo, director_basic.MyClass):
|
class PyMulti(director_basic.Foo, director_basic.MyClass):
|
||||||
def __init__(self):
|
|
||||||
director_basic.Foo.__init__(self)
|
|
||||||
director_basic.MyClass.__init__(self)
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
def vmethod(self, b):
|
director_basic.Foo.__init__(self)
|
||||||
b.x = b.x + 31
|
director_basic.MyClass.__init__(self)
|
||||||
return b
|
pass
|
||||||
|
|
||||||
|
def vmethod(self, b):
|
||||||
def ping(self):
|
b.x = b.x + 31
|
||||||
return "PyFoo::ping()"
|
return b
|
||||||
|
|
||||||
|
def ping(self):
|
||||||
|
return "PyFoo::ping()"
|
||||||
|
|
||||||
a = 0
|
a = 0
|
||||||
for i in range(0,100):
|
for i in range(0, 100):
|
||||||
pymult = PyMulti()
|
pymult = PyMulti()
|
||||||
pymult.pong()
|
pymult.pong()
|
||||||
del pymult
|
del pymult
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pymult = PyMulti()
|
pymult = PyMulti()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
p1 = director_basic.Foo_get_self(pymult)
|
p1 = director_basic.Foo_get_self(pymult)
|
||||||
p2 = director_basic.MyClass_get_self(pymult)
|
p2 = director_basic.MyClass_get_self(pymult)
|
||||||
|
|
||||||
p1.ping()
|
p1.ping()
|
||||||
p2.vmethod(bc)
|
p2.vmethod(bc)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,53 +1,76 @@
|
||||||
from director_classic import *
|
from director_classic import *
|
||||||
|
|
||||||
|
|
||||||
class TargetLangPerson(Person):
|
class TargetLangPerson(Person):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Person.__init__(self)
|
Person.__init__(self)
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
identifier = "TargetLangPerson"
|
identifier = "TargetLangPerson"
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
|
|
||||||
class TargetLangChild(Child):
|
class TargetLangChild(Child):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Child.__init__(self)
|
Child.__init__(self)
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
identifier = "TargetLangChild"
|
identifier = "TargetLangChild"
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
|
|
||||||
class TargetLangGrandChild(GrandChild):
|
class TargetLangGrandChild(GrandChild):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
GrandChild.__init__(self)
|
GrandChild.__init__(self)
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
identifier = "TargetLangGrandChild"
|
identifier = "TargetLangGrandChild"
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
# Semis - don't override id() in target language
|
# Semis - don't override id() in target language
|
||||||
|
|
||||||
|
|
||||||
class TargetLangSemiPerson(Person):
|
class TargetLangSemiPerson(Person):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Person.__init__(self)
|
Person.__init__(self)
|
||||||
# No id() override
|
# No id() override
|
||||||
|
|
||||||
|
|
||||||
class TargetLangSemiChild(Child):
|
class TargetLangSemiChild(Child):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Child.__init__(self)
|
Child.__init__(self)
|
||||||
# No id() override
|
# No id() override
|
||||||
|
|
||||||
|
|
||||||
class TargetLangSemiGrandChild(GrandChild):
|
class TargetLangSemiGrandChild(GrandChild):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
GrandChild.__init__(self)
|
GrandChild.__init__(self)
|
||||||
# No id() override
|
# No id() override
|
||||||
|
|
||||||
# Orphans - don't override id() in C++
|
# Orphans - don't override id() in C++
|
||||||
|
|
||||||
|
|
||||||
class TargetLangOrphanPerson(OrphanPerson):
|
class TargetLangOrphanPerson(OrphanPerson):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
OrphanPerson.__init__(self)
|
OrphanPerson.__init__(self)
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
identifier = "TargetLangOrphanPerson"
|
identifier = "TargetLangOrphanPerson"
|
||||||
return identifier
|
return identifier
|
||||||
|
|
||||||
|
|
||||||
class TargetLangOrphanChild(OrphanChild):
|
class TargetLangOrphanChild(OrphanChild):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Child.__init__(self)
|
Child.__init__(self)
|
||||||
|
|
||||||
def id(self):
|
def id(self):
|
||||||
identifier = "TargetLangOrphanChild"
|
identifier = "TargetLangOrphanChild"
|
||||||
return identifier
|
return identifier
|
||||||
|
|
@ -55,88 +78,90 @@ class TargetLangOrphanChild(OrphanChild):
|
||||||
|
|
||||||
def check(person, expected):
|
def check(person, expected):
|
||||||
|
|
||||||
debug = 0
|
debug = 0
|
||||||
# Normal target language polymorphic call
|
# Normal target language polymorphic call
|
||||||
ret = person.id()
|
ret = person.id()
|
||||||
if (debug):
|
if (debug):
|
||||||
print(ret)
|
print(ret)
|
||||||
if (ret != expected):
|
if (ret != expected):
|
||||||
raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
|
raise RuntimeError(
|
||||||
|
"Failed. Received: " + str(ret) + " Expected: " + expected)
|
||||||
|
|
||||||
# Polymorphic call from C++
|
# Polymorphic call from C++
|
||||||
caller = Caller()
|
caller = Caller()
|
||||||
caller.setCallback(person)
|
caller.setCallback(person)
|
||||||
ret = caller.call()
|
ret = caller.call()
|
||||||
if (debug):
|
if (debug):
|
||||||
print(ret)
|
print(ret)
|
||||||
if (ret != expected):
|
if (ret != expected):
|
||||||
raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
|
raise RuntimeError(
|
||||||
|
"Failed. Received: " + str(ret) + " Expected: " + expected)
|
||||||
|
|
||||||
# Polymorphic call of object created in target language and passed to C++ and back again
|
# Polymorphic call of object created in target language and passed to C++
|
||||||
baseclass = caller.baseClass()
|
# and back again
|
||||||
ret = baseclass.id()
|
baseclass = caller.baseClass()
|
||||||
if (debug):
|
ret = baseclass.id()
|
||||||
print(ret)
|
if (debug):
|
||||||
if (ret != expected):
|
print(ret)
|
||||||
raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected)
|
if (ret != expected):
|
||||||
|
raise RuntimeError(
|
||||||
|
"Failed. Received: " + str(ret) + " Expected: " + expected)
|
||||||
|
|
||||||
caller.resetCallback()
|
caller.resetCallback()
|
||||||
if (debug):
|
if (debug):
|
||||||
print("----------------------------------------")
|
print("----------------------------------------")
|
||||||
|
|
||||||
|
|
||||||
|
person = Person()
|
||||||
person = Person();
|
check(person, "Person")
|
||||||
check(person, "Person");
|
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = Child();
|
person = Child()
|
||||||
check(person, "Child");
|
check(person, "Child")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = GrandChild();
|
person = GrandChild()
|
||||||
check(person, "GrandChild");
|
check(person, "GrandChild")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangPerson();
|
person = TargetLangPerson()
|
||||||
check(person, "TargetLangPerson");
|
check(person, "TargetLangPerson")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangChild();
|
person = TargetLangChild()
|
||||||
check(person, "TargetLangChild");
|
check(person, "TargetLangChild")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangGrandChild();
|
person = TargetLangGrandChild()
|
||||||
check(person, "TargetLangGrandChild");
|
check(person, "TargetLangGrandChild")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
# Semis - don't override id() in target language
|
# Semis - don't override id() in target language
|
||||||
person = TargetLangSemiPerson();
|
person = TargetLangSemiPerson()
|
||||||
check(person, "Person");
|
check(person, "Person")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangSemiChild();
|
person = TargetLangSemiChild()
|
||||||
check(person, "Child");
|
check(person, "Child")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangSemiGrandChild();
|
person = TargetLangSemiGrandChild()
|
||||||
check(person, "GrandChild");
|
check(person, "GrandChild")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
# Orphans - don't override id() in C++
|
# Orphans - don't override id() in C++
|
||||||
person = OrphanPerson();
|
person = OrphanPerson()
|
||||||
check(person, "Person");
|
check(person, "Person")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = OrphanChild();
|
person = OrphanChild()
|
||||||
check(person, "Child");
|
check(person, "Child")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangOrphanPerson();
|
person = TargetLangOrphanPerson()
|
||||||
check(person, "TargetLangOrphanPerson");
|
check(person, "TargetLangOrphanPerson")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
person = TargetLangOrphanChild();
|
person = TargetLangOrphanChild()
|
||||||
check(person, "TargetLangOrphanChild");
|
check(person, "TargetLangOrphanChild")
|
||||||
del person
|
del person
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,26 @@
|
||||||
import director_detect
|
import director_detect
|
||||||
|
|
||||||
|
|
||||||
class MyBar(director_detect.Bar):
|
class MyBar(director_detect.Bar):
|
||||||
def __init__(self, val = 2):
|
|
||||||
director_detect.Bar.__init__(self)
|
|
||||||
self.val = val
|
|
||||||
|
|
||||||
def get_value(self):
|
def __init__(self, val=2):
|
||||||
self.val = self.val + 1
|
director_detect.Bar.__init__(self)
|
||||||
return self.val
|
self.val = val
|
||||||
|
|
||||||
def get_class(self):
|
|
||||||
self.val = self.val + 1
|
|
||||||
return director_detect.A()
|
|
||||||
|
|
||||||
def just_do_it(self):
|
def get_value(self):
|
||||||
self.val = self.val + 1
|
self.val = self.val + 1
|
||||||
|
return self.val
|
||||||
|
|
||||||
def clone(self):
|
def get_class(self):
|
||||||
return MyBar(self.val)
|
self.val = self.val + 1
|
||||||
pass
|
return director_detect.A()
|
||||||
|
|
||||||
|
def just_do_it(self):
|
||||||
|
self.val = self.val + 1
|
||||||
|
|
||||||
|
def clone(self):
|
||||||
|
return MyBar(self.val)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
b = MyBar()
|
b = MyBar()
|
||||||
|
|
@ -33,4 +35,4 @@ c = b.clone()
|
||||||
vc = c.get_value()
|
vc = c.get_value()
|
||||||
|
|
||||||
if (v != 3) or (b.val != 5) or (vc != 6):
|
if (v != 3) or (b.val != 5) or (vc != 6):
|
||||||
raise RuntimeError,"Bad virtual detection"
|
raise RuntimeError, "Bad virtual detection"
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,14 @@
|
||||||
import director_enum
|
import director_enum
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(director_enum.Foo):
|
class MyFoo(director_enum.Foo):
|
||||||
def say_hi(self, val):
|
|
||||||
return val
|
def say_hi(self, val):
|
||||||
|
return val
|
||||||
|
|
||||||
|
|
||||||
b = director_enum.Foo()
|
b = director_enum.Foo()
|
||||||
a = MyFoo()
|
a = MyFoo()
|
||||||
|
|
||||||
if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi):
|
if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,29 @@
|
||||||
from director_exception import *
|
from director_exception import *
|
||||||
|
|
||||||
|
|
||||||
class MyException(Exception):
|
class MyException(Exception):
|
||||||
def __init__(self, a, b):
|
|
||||||
self.msg = a + b
|
def __init__(self, a, b):
|
||||||
|
self.msg = a + b
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(Foo):
|
class MyFoo(Foo):
|
||||||
def ping(self):
|
|
||||||
raise NotImplementedError, "MyFoo::ping() EXCEPTION"
|
def ping(self):
|
||||||
|
raise NotImplementedError, "MyFoo::ping() EXCEPTION"
|
||||||
|
|
||||||
|
|
||||||
class MyFoo2(Foo):
|
class MyFoo2(Foo):
|
||||||
def ping(self):
|
|
||||||
return True
|
def ping(self):
|
||||||
pass # error: should return a string
|
return True
|
||||||
|
pass # error: should return a string
|
||||||
|
|
||||||
|
|
||||||
class MyFoo3(Foo):
|
class MyFoo3(Foo):
|
||||||
def ping(self):
|
|
||||||
raise MyException("foo", "bar")
|
def ping(self):
|
||||||
|
raise MyException("foo", "bar")
|
||||||
|
|
||||||
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
|
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
|
||||||
# MyFoo.pong().
|
# MyFoo.pong().
|
||||||
|
|
@ -23,16 +31,16 @@ ok = 0
|
||||||
a = MyFoo()
|
a = MyFoo()
|
||||||
b = launder(a)
|
b = launder(a)
|
||||||
try:
|
try:
|
||||||
b.pong()
|
b.pong()
|
||||||
except NotImplementedError, e:
|
except NotImplementedError, e:
|
||||||
if str(e) == "MyFoo::ping() EXCEPTION":
|
if str(e) == "MyFoo::ping() EXCEPTION":
|
||||||
ok = 1
|
ok = 1
|
||||||
else:
|
else:
|
||||||
print "Unexpected error message: %s" % str(e)
|
print "Unexpected error message: %s" % str(e)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not ok:
|
if not ok:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
# Check that the director returns the appropriate TypeError if the return type
|
# Check that the director returns the appropriate TypeError if the return type
|
||||||
|
|
@ -41,14 +49,14 @@ ok = 0
|
||||||
a = MyFoo2()
|
a = MyFoo2()
|
||||||
b = launder(a)
|
b = launder(a)
|
||||||
try:
|
try:
|
||||||
b.pong()
|
b.pong()
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
|
if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
|
||||||
ok = 1
|
ok = 1
|
||||||
else:
|
else:
|
||||||
print "Unexpected error message: %s" % str(e)
|
print "Unexpected error message: %s" % str(e)
|
||||||
if not ok:
|
if not ok:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
# Check that the director can return an exception which requires two arguments
|
# Check that the director can return an exception which requires two arguments
|
||||||
|
|
@ -57,24 +65,24 @@ ok = 0
|
||||||
a = MyFoo3()
|
a = MyFoo3()
|
||||||
b = launder(a)
|
b = launder(a)
|
||||||
try:
|
try:
|
||||||
b.pong()
|
b.pong()
|
||||||
except MyException, e:
|
except MyException, e:
|
||||||
if e.msg == 'foobar':
|
if e.msg == 'foobar':
|
||||||
ok = 1
|
ok = 1
|
||||||
else:
|
else:
|
||||||
print "Unexpected error message: %s" % str(e)
|
print "Unexpected error message: %s" % str(e)
|
||||||
if not ok:
|
if not ok:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# This is expected to fail with -builtin option
|
# This is expected to fail with -builtin option
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
if not is_python_builtin():
|
if not is_python_builtin():
|
||||||
try:
|
try:
|
||||||
raise Exception2()
|
raise Exception2()
|
||||||
except Exception2:
|
except Exception2:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
raise Exception1()
|
raise Exception1()
|
||||||
except Exception1:
|
except Exception1:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
# Test case from bug #1506850
|
# Test case from bug #1506850
|
||||||
#"When threading is enabled, the interpreter will infinitely wait on a mutex the second
|
#"When threading is enabled, the interpreter will infinitely wait on a mutex the second
|
||||||
#time this type of extended method is called. Attached is an example
|
# time this type of extended method is called. Attached is an example
|
||||||
#program that waits on the mutex to be unlocked."
|
# program that waits on the mutex to be unlocked."
|
||||||
|
|
||||||
from director_extend import *
|
from director_extend import *
|
||||||
|
|
||||||
|
|
||||||
class MyObject(SpObject):
|
class MyObject(SpObject):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
SpObject.__init__(self)
|
SpObject.__init__(self)
|
||||||
return
|
return
|
||||||
|
|
||||||
def getFoo(self):
|
def getFoo(self):
|
||||||
return 123
|
return 123
|
||||||
|
|
||||||
m = MyObject()
|
m = MyObject()
|
||||||
if m.dummy() != 666:
|
if m.dummy() != 666:
|
||||||
raise RuntimeError, "1st call"
|
raise RuntimeError, "1st call"
|
||||||
if m.dummy() != 666: # Locked system
|
if m.dummy() != 666: # Locked system
|
||||||
raise RuntimeError, "2nd call"
|
raise RuntimeError, "2nd call"
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
from director_finalizer import *
|
from director_finalizer import *
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(Foo):
|
class MyFoo(Foo):
|
||||||
def __del__(self):
|
|
||||||
self.orStatus(2)
|
def __del__(self):
|
||||||
try: Foo.__del__(self)
|
self.orStatus(2)
|
||||||
except: pass
|
try:
|
||||||
|
Foo.__del__(self)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
resetStatus()
|
resetStatus()
|
||||||
|
|
@ -13,7 +17,7 @@ a = MyFoo()
|
||||||
del a
|
del a
|
||||||
|
|
||||||
if getStatus() != 3:
|
if getStatus() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
resetStatus()
|
resetStatus()
|
||||||
|
|
||||||
|
|
@ -21,12 +25,12 @@ a = MyFoo()
|
||||||
launder(a)
|
launder(a)
|
||||||
|
|
||||||
if getStatus() != 0:
|
if getStatus() != 0:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
del a
|
del a
|
||||||
|
|
||||||
if getStatus() != 3:
|
if getStatus() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
resetStatus()
|
resetStatus()
|
||||||
|
|
||||||
|
|
@ -34,15 +38,14 @@ a = MyFoo().__disown__()
|
||||||
deleteFoo(a)
|
deleteFoo(a)
|
||||||
|
|
||||||
if getStatus() != 3:
|
if getStatus() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
resetStatus()
|
resetStatus()
|
||||||
|
|
||||||
a = MyFoo().__disown__()
|
a = MyFoo().__disown__()
|
||||||
deleteFoo(launder(a))
|
deleteFoo(launder(a))
|
||||||
|
|
||||||
if getStatus() != 3:
|
if getStatus() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
resetStatus()
|
|
||||||
|
|
||||||
|
resetStatus()
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from director_frob import *
|
from director_frob import *
|
||||||
|
|
||||||
foo = Bravo();
|
foo = Bravo()
|
||||||
s = foo.abs_method();
|
s = foo.abs_method()
|
||||||
|
|
||||||
if s != "Bravo::abs_method()":
|
if s != "Bravo::abs_method()":
|
||||||
raise RuntimeError, s
|
raise RuntimeError, s
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,3 @@ from director_keywords import *
|
||||||
|
|
||||||
f = Foo()
|
f = Foo()
|
||||||
f.check_self(20)
|
f.check_self(20)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,62 +2,63 @@ from director_nested import *
|
||||||
|
|
||||||
|
|
||||||
class A(FooBar_int):
|
class A(FooBar_int):
|
||||||
def do_step(self):
|
|
||||||
return "A::do_step;"
|
|
||||||
|
|
||||||
def get_value(self):
|
|
||||||
return "A::get_value"
|
|
||||||
|
|
||||||
pass
|
def do_step(self):
|
||||||
|
return "A::do_step;"
|
||||||
|
|
||||||
|
def get_value(self):
|
||||||
|
return "A::get_value"
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;":
|
if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;":
|
||||||
raise RuntimeError,"Bad A virtual resolution"
|
raise RuntimeError, "Bad A virtual resolution"
|
||||||
|
|
||||||
|
|
||||||
class B(FooBar_int):
|
class B(FooBar_int):
|
||||||
def do_advance(self):
|
|
||||||
return "B::do_advance;" + self.do_step()
|
|
||||||
|
|
||||||
def do_step(self):
|
def do_advance(self):
|
||||||
return "B::do_step;"
|
return "B::do_advance;" + self.do_step()
|
||||||
|
|
||||||
def get_value(self):
|
|
||||||
return 1
|
|
||||||
|
|
||||||
pass
|
def do_step(self):
|
||||||
|
return "B::do_step;"
|
||||||
|
|
||||||
|
def get_value(self):
|
||||||
|
return 1
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
b = B()
|
b = B()
|
||||||
|
|
||||||
if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;":
|
if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;":
|
||||||
raise RuntimeError,"Bad B virtual resolution"
|
raise RuntimeError, "Bad B virtual resolution"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class C(FooBar_int):
|
class C(FooBar_int):
|
||||||
def do_advance(self):
|
|
||||||
return "C::do_advance;" + FooBar_int.do_advance(self)
|
|
||||||
|
|
||||||
def do_step(self):
|
def do_advance(self):
|
||||||
return "C::do_step;"
|
return "C::do_advance;" + FooBar_int.do_advance(self)
|
||||||
|
|
||||||
def get_value(self):
|
|
||||||
return 2
|
|
||||||
|
|
||||||
def get_name(self):
|
def do_step(self):
|
||||||
return FooBar_int.get_name(self) + " hello"
|
return "C::do_step;"
|
||||||
|
|
||||||
|
def get_value(self):
|
||||||
pass
|
return 2
|
||||||
|
|
||||||
|
def get_name(self):
|
||||||
|
return FooBar_int.get_name(self) + " hello"
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
cc = C()
|
cc = C()
|
||||||
c = FooBar_int_get_self(cc)
|
c = FooBar_int_get_self(cc)
|
||||||
c.advance()
|
c.advance()
|
||||||
|
|
||||||
if c.get_name() != "FooBar::get_name hello":
|
if c.get_name() != "FooBar::get_name hello":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if c.name() != "FooBar::get_name hello":
|
if c.name() != "FooBar::get_name hello":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
import director_profile
|
import director_profile
|
||||||
|
|
||||||
class MyB(director_profile.B):
|
|
||||||
def vfi(self, a):
|
|
||||||
return a+3
|
|
||||||
|
|
||||||
|
class MyB(director_profile.B):
|
||||||
|
|
||||||
|
def vfi(self, a):
|
||||||
|
return a + 3
|
||||||
|
|
||||||
|
|
||||||
a = director_profile.A()
|
a = director_profile.A()
|
||||||
|
|
@ -15,27 +16,26 @@ fi = b.fi
|
||||||
i = 50000
|
i = 50000
|
||||||
a = 1
|
a = 1
|
||||||
while i:
|
while i:
|
||||||
a = fi(a) #1
|
a = fi(a) # 1
|
||||||
a = fi(a) #2
|
a = fi(a) # 2
|
||||||
a = fi(a) #3
|
a = fi(a) # 3
|
||||||
a = fi(a) #4
|
a = fi(a) # 4
|
||||||
a = fi(a) #5
|
a = fi(a) # 5
|
||||||
a = fi(a) #6
|
a = fi(a) # 6
|
||||||
a = fi(a) #7
|
a = fi(a) # 7
|
||||||
a = fi(a) #8
|
a = fi(a) # 8
|
||||||
a = fi(a) #9
|
a = fi(a) # 9
|
||||||
a = fi(a) #10
|
a = fi(a) # 10
|
||||||
a = fi(a) #1
|
a = fi(a) # 1
|
||||||
a = fi(a) #2
|
a = fi(a) # 2
|
||||||
a = fi(a) #3
|
a = fi(a) # 3
|
||||||
a = fi(a) #4
|
a = fi(a) # 4
|
||||||
a = fi(a) #5
|
a = fi(a) # 5
|
||||||
a = fi(a) #6
|
a = fi(a) # 6
|
||||||
a = fi(a) #7
|
a = fi(a) # 7
|
||||||
a = fi(a) #8
|
a = fi(a) # 8
|
||||||
a = fi(a) #9
|
a = fi(a) # 9
|
||||||
a = fi(a) #20
|
a = fi(a) # 20
|
||||||
i -= 1
|
i -= 1
|
||||||
|
|
||||||
print a
|
print a
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,19 @@
|
||||||
import director_property
|
import director_property
|
||||||
|
|
||||||
class PyFoo(director_property.Foo):
|
|
||||||
a = property(director_property.Foo.getA, director_property.Foo.setA)
|
|
||||||
|
|
||||||
def ping(self):
|
class PyFoo(director_property.Foo):
|
||||||
return "PyFoo::ping()"
|
a = property(director_property.Foo.getA, director_property.Foo.setA)
|
||||||
|
|
||||||
|
def ping(self):
|
||||||
|
return "PyFoo::ping()"
|
||||||
|
|
||||||
|
|
||||||
foo = PyFoo()
|
foo = PyFoo()
|
||||||
|
|
||||||
foo.setA("BLABLA")
|
foo.setA("BLABLA")
|
||||||
if foo.getA() != "BLABLA":
|
if foo.getA() != "BLABLA":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
foo.a = "BIBI"
|
foo.a = "BIBI"
|
||||||
if foo.a != "BIBI":
|
if foo.a != "BIBI":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,129 +1,132 @@
|
||||||
from director_protected import *
|
from director_protected import *
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FooBar(Bar):
|
class FooBar(Bar):
|
||||||
def ping(self):
|
|
||||||
return "FooBar::ping();"
|
def ping(self):
|
||||||
|
return "FooBar::ping();"
|
||||||
|
|
||||||
|
|
||||||
class FooBar2(Bar):
|
class FooBar2(Bar):
|
||||||
def ping(self):
|
|
||||||
return "FooBar2::ping();"
|
def ping(self):
|
||||||
def pang(self):
|
return "FooBar2::ping();"
|
||||||
return "FooBar2::pang();"
|
|
||||||
|
def pang(self):
|
||||||
|
return "FooBar2::pang();"
|
||||||
|
|
||||||
|
|
||||||
class FooBar3(Bar):
|
class FooBar3(Bar):
|
||||||
def cheer(self):
|
|
||||||
return "FooBar3::cheer();"
|
def cheer(self):
|
||||||
|
return "FooBar3::cheer();"
|
||||||
|
|
||||||
|
|
||||||
b = Bar()
|
b = Bar()
|
||||||
f = b.create()
|
f = b.create()
|
||||||
fb = FooBar()
|
fb = FooBar()
|
||||||
fb2 = FooBar2()
|
fb2 = FooBar2()
|
||||||
fb3 = FooBar3()
|
fb3 = FooBar3()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s = fb.used()
|
s = fb.used()
|
||||||
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();":
|
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad FooBar::used"
|
raise RuntimeError, "bad FooBar::used"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s = fb2.used()
|
s = fb2.used()
|
||||||
if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
|
if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad FooBar2::used"
|
raise RuntimeError, "bad FooBar2::used"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s = b.pong()
|
s = b.pong()
|
||||||
if s != "Bar::pong();Foo::pong();Bar::ping();":
|
if s != "Bar::pong();Foo::pong();Bar::ping();":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad Bar::pong"
|
raise RuntimeError, "bad Bar::pong"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
s = f.pong()
|
s = f.pong()
|
||||||
if s != "Bar::pong();Foo::pong();Bar::ping();":
|
if s != "Bar::pong();Foo::pong();Bar::ping();":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError," bad Foo::pong"
|
raise RuntimeError, " bad Foo::pong"
|
||||||
|
|
||||||
try:
|
|
||||||
s = fb.pong()
|
|
||||||
if s != "Bar::pong();Foo::pong();FooBar::ping();":
|
|
||||||
raise RuntimeError
|
|
||||||
pass
|
|
||||||
except:
|
|
||||||
raise RuntimeError," bad FooBar::pong"
|
|
||||||
|
|
||||||
protected=1
|
|
||||||
try:
|
try:
|
||||||
b.ping()
|
s = fb.pong()
|
||||||
protected=0
|
if s != "Bar::pong();Foo::pong();FooBar::ping();":
|
||||||
|
raise RuntimeError
|
||||||
|
pass
|
||||||
except:
|
except:
|
||||||
pass
|
raise RuntimeError, " bad FooBar::pong"
|
||||||
|
|
||||||
|
protected = 1
|
||||||
|
try:
|
||||||
|
b.ping()
|
||||||
|
protected = 0
|
||||||
|
except:
|
||||||
|
pass
|
||||||
if not protected:
|
if not protected:
|
||||||
raise RuntimeError,"Foo::ping is protected"
|
raise RuntimeError, "Foo::ping is protected"
|
||||||
|
|
||||||
protected=1
|
protected = 1
|
||||||
try:
|
try:
|
||||||
f.ping()
|
f.ping()
|
||||||
protected=0
|
protected = 0
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not protected:
|
if not protected:
|
||||||
raise RuntimeError,"Foo::ping is protected"
|
raise RuntimeError, "Foo::ping is protected"
|
||||||
|
|
||||||
|
|
||||||
protected=1
|
protected = 1
|
||||||
try:
|
try:
|
||||||
f.pang()
|
f.pang()
|
||||||
protected=0
|
protected = 0
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not protected:
|
if not protected:
|
||||||
raise RuntimeError,"FooBar::pang is protected"
|
raise RuntimeError, "FooBar::pang is protected"
|
||||||
|
|
||||||
|
|
||||||
protected=1
|
protected = 1
|
||||||
try:
|
try:
|
||||||
b.cheer()
|
b.cheer()
|
||||||
protected=0
|
protected = 0
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not protected:
|
if not protected:
|
||||||
raise RuntimeError,"Bar::cheer is protected"
|
raise RuntimeError, "Bar::cheer is protected"
|
||||||
|
|
||||||
protected=1
|
protected = 1
|
||||||
try:
|
try:
|
||||||
f.cheer()
|
f.cheer()
|
||||||
protected=0
|
protected = 0
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
if not protected:
|
if not protected:
|
||||||
raise RuntimeError,"Foo::cheer is protected"
|
raise RuntimeError, "Foo::cheer is protected"
|
||||||
|
|
||||||
if fb3.cheer() != "FooBar3::cheer();":
|
if fb3.cheer() != "FooBar3::cheer();":
|
||||||
raise RuntimeError, "bad fb3::cheer"
|
raise RuntimeError, "bad fb3::cheer"
|
||||||
|
|
||||||
if fb2.callping() != "FooBar2::ping();":
|
if fb2.callping() != "FooBar2::ping();":
|
||||||
raise RuntimeError, "bad fb2.callping"
|
raise RuntimeError, "bad fb2.callping"
|
||||||
|
|
||||||
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
|
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
|
||||||
raise RuntimeError, "bad fb2.callcheer"
|
raise RuntimeError, "bad fb2.callcheer"
|
||||||
|
|
||||||
if fb3.callping() != "Bar::ping();":
|
if fb3.callping() != "Bar::ping();":
|
||||||
raise RuntimeError, "bad fb3.callping"
|
raise RuntimeError, "bad fb3.callping"
|
||||||
|
|
||||||
if fb3.callcheer() != "FooBar3::cheer();":
|
if fb3.callcheer() != "FooBar3::cheer();":
|
||||||
raise RuntimeError, "bad fb3.callcheer"
|
raise RuntimeError, "bad fb3.callcheer"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
import director_stl
|
import director_stl
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(director_stl.Foo):
|
class MyFoo(director_stl.Foo):
|
||||||
def ping(self, s):
|
|
||||||
return "MyFoo::ping():" + s
|
|
||||||
|
|
||||||
def pident(self, arg):
|
def ping(self, s):
|
||||||
return arg
|
return "MyFoo::ping():" + s
|
||||||
|
|
||||||
def vident(self,v):
|
|
||||||
return v
|
|
||||||
|
|
||||||
def vidents(self,v):
|
def pident(self, arg):
|
||||||
return v
|
return arg
|
||||||
|
|
||||||
def vsecond(self,v1,v2):
|
def vident(self, v):
|
||||||
return v2
|
return v
|
||||||
|
|
||||||
|
def vidents(self, v):
|
||||||
|
return v
|
||||||
|
|
||||||
|
def vsecond(self, v1, v2):
|
||||||
|
return v2
|
||||||
|
|
||||||
|
|
||||||
a = MyFoo()
|
a = MyFoo()
|
||||||
|
|
@ -22,18 +24,18 @@ a = MyFoo()
|
||||||
a.tping("hello")
|
a.tping("hello")
|
||||||
a.tpong("hello")
|
a.tpong("hello")
|
||||||
|
|
||||||
p = (1,2)
|
p = (1, 2)
|
||||||
a.pident(p)
|
a.pident(p)
|
||||||
v = (3,4)
|
v = (3, 4)
|
||||||
a.vident(v)
|
a.vident(v)
|
||||||
|
|
||||||
a.tpident(p)
|
a.tpident(p)
|
||||||
a.tvident(v)
|
a.tvident(v)
|
||||||
|
|
||||||
v1 = (3,4)
|
v1 = (3, 4)
|
||||||
v2 = (5,6)
|
v2 = (5, 6)
|
||||||
a.tvsecond(v1,v2)
|
a.tvsecond(v1, v2)
|
||||||
|
|
||||||
vs=("hi", "hello")
|
vs = ("hi", "hello")
|
||||||
vs
|
vs
|
||||||
a.tvidents(vs)
|
a.tvidents(vs)
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,29 @@
|
||||||
from director_string import *
|
from director_string import *
|
||||||
|
|
||||||
|
|
||||||
class B(A):
|
class B(A):
|
||||||
def __init__(self,string):
|
|
||||||
A.__init__(self,string)
|
|
||||||
|
|
||||||
def get_first(self):
|
def __init__(self, string):
|
||||||
return A.get_first(self) + " world!"
|
A.__init__(self, string)
|
||||||
|
|
||||||
def process_text(self, string):
|
def get_first(self):
|
||||||
A.process_text(self, string)
|
return A.get_first(self) + " world!"
|
||||||
self.smem = "hello"
|
|
||||||
|
def process_text(self, string):
|
||||||
|
A.process_text(self, string)
|
||||||
|
self.smem = "hello"
|
||||||
|
|
||||||
|
|
||||||
b = B("hello")
|
b = B("hello")
|
||||||
|
|
||||||
b.get(0)
|
b.get(0)
|
||||||
if b.get_first() != "hello world!":
|
if b.get_first() != "hello world!":
|
||||||
print b.get_first()
|
print b.get_first()
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
b.call_process_func()
|
b.call_process_func()
|
||||||
|
|
||||||
if b.smem != "hello":
|
if b.smem != "hello":
|
||||||
print smem
|
print smem
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
from director_thread import Foo
|
from director_thread import Foo
|
||||||
|
|
||||||
class Derived(Foo) :
|
|
||||||
|
class Derived(Foo):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Foo.__init__(self)
|
Foo.__init__(self)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import director_unroll
|
import director_unroll
|
||||||
|
|
||||||
|
|
||||||
class MyFoo(director_unroll.Foo):
|
class MyFoo(director_unroll.Foo):
|
||||||
def ping(self):
|
|
||||||
return "MyFoo::ping()"
|
def ping(self):
|
||||||
|
return "MyFoo::ping()"
|
||||||
|
|
||||||
|
|
||||||
a = MyFoo()
|
a = MyFoo()
|
||||||
|
|
@ -14,6 +16,5 @@ c = b.get()
|
||||||
|
|
||||||
|
|
||||||
if not (a.this == c.this):
|
if not (a.this == c.this):
|
||||||
print a, c
|
print a, c
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
from director_wstring import *
|
from director_wstring import *
|
||||||
|
|
||||||
|
|
||||||
class B(A):
|
class B(A):
|
||||||
def __init__(self,string):
|
|
||||||
A.__init__(self,string)
|
|
||||||
|
|
||||||
def get_first(self):
|
def __init__(self, string):
|
||||||
return A.get_first(self) + u" world!"
|
A.__init__(self, string)
|
||||||
|
|
||||||
def process_text(self, string):
|
def get_first(self):
|
||||||
self.smem = u"hello"
|
return A.get_first(self) + u" world!"
|
||||||
|
|
||||||
|
def process_text(self, string):
|
||||||
|
self.smem = u"hello"
|
||||||
|
|
||||||
|
|
||||||
b = B(u"hello")
|
b = B(u"hello")
|
||||||
|
|
||||||
b.get(0)
|
b.get(0)
|
||||||
if b.get_first() != u"hello world!":
|
if b.get_first() != u"hello world!":
|
||||||
print b.get_first()
|
print b.get_first()
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
b.call_process_func()
|
b.call_process_func()
|
||||||
|
|
||||||
if b.smem != u"hello":
|
if b.smem != u"hello":
|
||||||
print smem
|
print smem
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ if (not a.thisown):
|
||||||
|
|
||||||
a.thisown = tmp
|
a.thisown = tmp
|
||||||
if (a.thisown != tmp):
|
if (a.thisown != tmp):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
b = B()
|
b = B()
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,3 @@ y = b.blah()
|
||||||
a = dynamic_cast.do_test(y)
|
a = dynamic_cast.do_test(y)
|
||||||
if a != "Bar::test":
|
if a != "Bar::test":
|
||||||
print "Failed!!"
|
print "Failed!!"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
import enum_forward
|
import enum_forward
|
||||||
|
|
||||||
f1 = enum_forward.get_enum1();
|
|
||||||
f1 = enum_forward.test_function1(f1);
|
|
||||||
|
|
||||||
f2 = enum_forward.get_enum2();
|
f1 = enum_forward.get_enum1()
|
||||||
f2 = enum_forward.test_function2(f2);
|
f1 = enum_forward.test_function1(f1)
|
||||||
|
|
||||||
f3 = enum_forward.get_enum3();
|
f2 = enum_forward.get_enum2()
|
||||||
f3 = enum_forward.test_function3(f3);
|
f2 = enum_forward.test_function2(f2)
|
||||||
|
|
||||||
|
f3 = enum_forward.get_enum3()
|
||||||
|
f3 = enum_forward.test_function3(f3)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import enum_template
|
import enum_template
|
||||||
if enum_template.MakeETest() != 1:
|
if enum_template.MakeETest() != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if enum_template.TakeETest(0) != None:
|
if enum_template.TakeETest(0) != None:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,13 @@ _enums.bar3(1)
|
||||||
_enums.bar1(1)
|
_enums.bar1(1)
|
||||||
|
|
||||||
if _enums.cvar.enumInstance != 2:
|
if _enums.cvar.enumInstance != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if _enums.cvar.Slap != 10:
|
if _enums.cvar.Slap != 10:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if _enums.cvar.Mine != 11:
|
if _enums.cvar.Mine != 11:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if _enums.cvar.Thigh != 12:
|
if _enums.cvar.Thigh != 12:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,43 +3,42 @@ from exception_order import *
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
if is_python_builtin():
|
if is_python_builtin():
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
a = A()
|
a = A()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a.foo()
|
a.foo()
|
||||||
except E1,e:
|
except E1, e:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad exception order"
|
raise RuntimeError, "bad exception order"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a.bar()
|
a.bar()
|
||||||
except E2,e:
|
except E2, e:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad exception order"
|
raise RuntimeError, "bad exception order"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a.foobar()
|
a.foobar()
|
||||||
except RuntimeError,e:
|
except RuntimeError, e:
|
||||||
if e.args[0] != "postcatch unknown":
|
if e.args[0] != "postcatch unknown":
|
||||||
print "bad exception order",
|
print "bad exception order",
|
||||||
raise RuntimeError, e.args
|
raise RuntimeError, e.args
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a.barfoo(1)
|
a.barfoo(1)
|
||||||
except E1,e:
|
except E1, e:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad exception order"
|
raise RuntimeError, "bad exception order"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
a.barfoo(2)
|
a.barfoo(2)
|
||||||
except E2,e:
|
except E2, e:
|
||||||
pass
|
pass
|
||||||
except:
|
except:
|
||||||
raise RuntimeError, "bad exception order"
|
raise RuntimeError, "bad exception order"
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ import extend_placement
|
||||||
|
|
||||||
foo = extend_placement.Foo()
|
foo = extend_placement.Foo()
|
||||||
foo = extend_placement.Foo(1)
|
foo = extend_placement.Foo(1)
|
||||||
foo = extend_placement.Foo(1,1)
|
foo = extend_placement.Foo(1, 1)
|
||||||
foo.spam()
|
foo.spam()
|
||||||
foo.spam("hello")
|
foo.spam("hello")
|
||||||
foo.spam(1)
|
foo.spam(1)
|
||||||
foo.spam(1,1)
|
foo.spam(1, 1)
|
||||||
foo.spam(1,1,1)
|
foo.spam(1, 1, 1)
|
||||||
foo.spam(extend_placement.Foo())
|
foo.spam(extend_placement.Foo())
|
||||||
foo.spam(extend_placement.Foo(), 1.0)
|
foo.spam(extend_placement.Foo(), 1.0)
|
||||||
|
|
||||||
|
|
@ -17,20 +17,20 @@ bar = extend_placement.Bar(1)
|
||||||
bar.spam()
|
bar.spam()
|
||||||
bar.spam("hello")
|
bar.spam("hello")
|
||||||
bar.spam(1)
|
bar.spam(1)
|
||||||
bar.spam(1,1)
|
bar.spam(1, 1)
|
||||||
bar.spam(1,1,1)
|
bar.spam(1, 1, 1)
|
||||||
bar.spam(extend_placement.Bar())
|
bar.spam(extend_placement.Bar())
|
||||||
bar.spam(extend_placement.Bar(), 1.0)
|
bar.spam(extend_placement.Bar(), 1.0)
|
||||||
|
|
||||||
|
|
||||||
foo = extend_placement.FooTi()
|
foo = extend_placement.FooTi()
|
||||||
foo = extend_placement.FooTi(1)
|
foo = extend_placement.FooTi(1)
|
||||||
foo = extend_placement.FooTi(1,1)
|
foo = extend_placement.FooTi(1, 1)
|
||||||
foo.spam()
|
foo.spam()
|
||||||
foo.spam("hello")
|
foo.spam("hello")
|
||||||
foo.spam(1)
|
foo.spam(1)
|
||||||
foo.spam(1,1)
|
foo.spam(1, 1)
|
||||||
foo.spam(1,1,1)
|
foo.spam(1, 1, 1)
|
||||||
foo.spam(extend_placement.Foo())
|
foo.spam(extend_placement.Foo())
|
||||||
foo.spam(extend_placement.Foo(), 1.0)
|
foo.spam(extend_placement.Foo(), 1.0)
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ bar = extend_placement.BarTi(1)
|
||||||
bar.spam()
|
bar.spam()
|
||||||
bar.spam("hello")
|
bar.spam("hello")
|
||||||
bar.spam(1)
|
bar.spam(1)
|
||||||
bar.spam(1,1)
|
bar.spam(1, 1)
|
||||||
bar.spam(1,1,1)
|
bar.spam(1, 1, 1)
|
||||||
bar.spam(extend_placement.Bar())
|
bar.spam(extend_placement.Bar())
|
||||||
bar.spam(extend_placement.Bar(), 1.0)
|
bar.spam(extend_placement.Bar(), 1.0)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import extern_c
|
import extern_c
|
||||||
|
|
||||||
extern_c.RealFunction(2)
|
extern_c.RealFunction(2)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
import file_test
|
import file_test
|
||||||
|
|
||||||
if sys.version_info[0:2] < (3, 0):
|
if sys.version_info[0:2] < (3, 0):
|
||||||
file_test.nfile(sys.stdout)
|
file_test.nfile(sys.stdout)
|
||||||
|
|
||||||
cstdout = file_test.GetStdOut()
|
cstdout = file_test.GetStdOut()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,27 +2,36 @@ import friends
|
||||||
|
|
||||||
a = friends.A(2)
|
a = friends.A(2)
|
||||||
|
|
||||||
if friends.get_val1(a) != 2: raise RuntimeError
|
if friends.get_val1(a) != 2:
|
||||||
if friends.get_val2(a) != 4: raise RuntimeError
|
raise RuntimeError
|
||||||
if friends.get_val3(a) != 6: raise RuntimeError
|
if friends.get_val2(a) != 4:
|
||||||
|
raise RuntimeError
|
||||||
|
if friends.get_val3(a) != 6:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
# nice overload working fine
|
# nice overload working fine
|
||||||
if friends.get_val1(1,2,3) != 1: raise RuntimeError
|
if friends.get_val1(1, 2, 3) != 1:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
b = friends.B(3)
|
b = friends.B(3)
|
||||||
|
|
||||||
# David's case
|
# David's case
|
||||||
if friends.mix(a,b) != 5: raise RuntimeError
|
if friends.mix(a, b) != 5:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
di = friends.D_d(2)
|
di = friends.D_d(2)
|
||||||
dd = friends.D_d(3.3)
|
dd = friends.D_d(3.3)
|
||||||
|
|
||||||
# incredible template overloading working just fine
|
# incredible template overloading working just fine
|
||||||
if friends.get_val1(di) != 2: raise RuntimeError
|
if friends.get_val1(di) != 2:
|
||||||
if friends.get_val1(dd) != 3.3: raise RuntimeError
|
raise RuntimeError
|
||||||
|
if friends.get_val1(dd) != 3.3:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
friends.set(di, 4)
|
friends.set(di, 4)
|
||||||
friends.set(dd, 1.3)
|
friends.set(dd, 1.3)
|
||||||
|
|
||||||
if friends.get_val1(di) != 4: raise RuntimeError
|
if friends.get_val1(di) != 4:
|
||||||
if friends.get_val1(dd) != 1.3: raise RuntimeError
|
raise RuntimeError
|
||||||
|
if friends.get_val1(dd) != 1.3:
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
from funcptr_cpp import *
|
from funcptr_cpp import *
|
||||||
|
|
||||||
if call1(ADD_BY_VALUE, 10, 11) != 21:
|
if call1(ADD_BY_VALUE, 10, 11) != 21:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if call2(ADD_BY_POINTER, 12, 13) != 25:
|
if call2(ADD_BY_POINTER, 12, 13) != 25:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if call3(ADD_BY_REFERENCE, 14, 15) != 29:
|
if call3(ADD_BY_REFERENCE, 14, 15) != 29:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@ from fvirtual import *
|
||||||
|
|
||||||
sw = NodeSwitch()
|
sw = NodeSwitch()
|
||||||
n = Node()
|
n = Node()
|
||||||
i = sw.addChild(n);
|
i = sw.addChild(n)
|
||||||
|
|
||||||
if i != 2:
|
if i != 2:
|
||||||
raise RuntimeError, "addChild"
|
raise RuntimeError, "addChild"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,52 @@
|
||||||
from global_functions import *
|
from global_functions import *
|
||||||
|
|
||||||
|
|
||||||
def check(a, b):
|
def check(a, b):
|
||||||
if a != b:
|
if a != b:
|
||||||
raise RuntimeError("Failed: " + str(a) + " != " + str(b))
|
raise RuntimeError("Failed: " + str(a) + " != " + str(b))
|
||||||
global_void()
|
global_void()
|
||||||
check(global_one(1), 1)
|
check(global_one(1), 1)
|
||||||
check(global_two(2, 2), 4)
|
check(global_two(2, 2), 4)
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_void(1)
|
global_void(1)
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("argument count check failed")
|
raise RuntimeError("argument count check failed")
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_one()
|
global_one()
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("argument count check failed")
|
raise RuntimeError("argument count check failed")
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_one(2, 2)
|
global_one(2, 2)
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
|
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("argument count check failed")
|
raise RuntimeError("argument count check failed")
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_two(1)
|
global_two(1)
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
|
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("argument count check failed")
|
raise RuntimeError("argument count check failed")
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_two(3, 3, 3)
|
global_two(3, 3, 3)
|
||||||
except TypeError, e:
|
except TypeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
|
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("argument count check failed")
|
raise RuntimeError("argument count check failed")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
from global_namespace import *
|
from global_namespace import *
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
k1 = Klass1()
|
k1 = Klass1()
|
||||||
k2 = Klass2()
|
k2 = Klass2()
|
||||||
|
|
@ -12,9 +13,9 @@ k6 = Klass6()
|
||||||
k7 = Klass7()
|
k7 = Klass7()
|
||||||
|
|
||||||
if is_new_style_class(KlassMethods):
|
if is_new_style_class(KlassMethods):
|
||||||
KlassMethods_static = KlassMethods
|
KlassMethods_static = KlassMethods
|
||||||
else:
|
else:
|
||||||
KlassMethods_static = KlassMethods()
|
KlassMethods_static = KlassMethods()
|
||||||
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
||||||
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
||||||
|
|
||||||
|
|
@ -41,15 +42,17 @@ KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
|
||||||
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
|
||||||
|
|
||||||
if is_new_style_class(XYZMethods):
|
if is_new_style_class(XYZMethods):
|
||||||
XYZMethods_static = XYZMethods
|
XYZMethods_static = XYZMethods
|
||||||
else:
|
else:
|
||||||
XYZMethods_static = XYZMethods()
|
XYZMethods_static = XYZMethods()
|
||||||
XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
XYZMethods_static.methodA(
|
||||||
XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
||||||
|
XYZMethods_static.methodB(
|
||||||
|
XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
|
||||||
|
|
||||||
if is_new_style_class(TheEnumMethods):
|
if is_new_style_class(TheEnumMethods):
|
||||||
TheEnumMethods_static = TheEnumMethods
|
TheEnumMethods_static = TheEnumMethods
|
||||||
else:
|
else:
|
||||||
TheEnumMethods_static = TheEnumMethods()
|
TheEnumMethods_static = TheEnumMethods()
|
||||||
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
||||||
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,3 @@ from global_ns_arg import *
|
||||||
|
|
||||||
a = foo(1)
|
a = foo(1)
|
||||||
b = bar_fn()
|
b = bar_fn()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,33 +3,32 @@ import global_vars
|
||||||
global_vars.init()
|
global_vars.init()
|
||||||
b = global_vars.cvar.b
|
b = global_vars.cvar.b
|
||||||
if b != "string b":
|
if b != "string b":
|
||||||
raise RuntimeError("Unexpected string: " + b)
|
raise RuntimeError("Unexpected string: " + b)
|
||||||
global_vars.cvar.b = "a string value"
|
global_vars.cvar.b = "a string value"
|
||||||
b = global_vars.cvar.b
|
b = global_vars.cvar.b
|
||||||
if b != "a string value":
|
if b != "a string value":
|
||||||
raise RuntimeError("Unexpected string: " + b)
|
raise RuntimeError("Unexpected string: " + b)
|
||||||
|
|
||||||
x = global_vars.cvar.x
|
x = global_vars.cvar.x
|
||||||
if x != 1234:
|
if x != 1234:
|
||||||
raise RuntimeError("Unexpected x: " + str(x))
|
raise RuntimeError("Unexpected x: " + str(x))
|
||||||
global_vars.cvar.x = 9876
|
global_vars.cvar.x = 9876
|
||||||
x = global_vars.cvar.x
|
x = global_vars.cvar.x
|
||||||
if x != 9876:
|
if x != 9876:
|
||||||
raise RuntimeError("Unexpected string: " + str(x))
|
raise RuntimeError("Unexpected string: " + str(x))
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
global_vars.cvar.notexist = "something"
|
global_vars.cvar.notexist = "something"
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("AttributeError should have been thrown")
|
raise RuntimeError("AttributeError should have been thrown")
|
||||||
|
|
||||||
fail = True
|
fail = True
|
||||||
try:
|
try:
|
||||||
g = global_vars.cvar.notexist
|
g = global_vars.cvar.notexist
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
fail = False
|
fail = False
|
||||||
if fail:
|
if fail:
|
||||||
raise RuntimeError("AttributeError should have been thrown")
|
raise RuntimeError("AttributeError should have been thrown")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import iadd
|
||||||
f = iadd.Foo()
|
f = iadd.Foo()
|
||||||
|
|
||||||
f.AsA.x = 3
|
f.AsA.x = 3
|
||||||
f.AsA += f.AsA
|
f.AsA += f.AsA
|
||||||
|
|
||||||
if f.AsA.x != 6:
|
if f.AsA.x != 6:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
from implicittest import *
|
from implicittest import *
|
||||||
|
|
||||||
|
|
||||||
def check(a, b):
|
def check(a, b):
|
||||||
if a != b:
|
if a != b:
|
||||||
raise RuntimeError(str(a) + " does not equal " + str(b))
|
raise RuntimeError(str(a) + " does not equal " + str(b))
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
#### Class ####
|
#### Class ####
|
||||||
|
|
||||||
|
|
@ -20,7 +22,8 @@ try:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
# ValueError: invalid null reference in method 'new_A', argument 1 of type 'B const &'
|
||||||
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
# Arguably A(char *) should be chosen, but there is a bug to do with None passed to methods overloaded by value,
|
||||||
# references and pointers to different types, where pointers ought to be given a slightly higher precedence.
|
# references and pointers to different types, where pointers ought to be
|
||||||
|
# given a slightly higher precedence.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
check(1, get(1))
|
check(1, get(1))
|
||||||
|
|
@ -43,9 +46,9 @@ check(3, A_int(B()).get())
|
||||||
check(4, A_int("hello").get())
|
check(4, A_int("hello").get())
|
||||||
|
|
||||||
if is_new_style_class(A_int):
|
if is_new_style_class(A_int):
|
||||||
A_int_static = A_int
|
A_int_static = A_int
|
||||||
else:
|
else:
|
||||||
A_int_static = A_int(0)
|
A_int_static = A_int(0)
|
||||||
check(1, A_int_static.sget(1))
|
check(1, A_int_static.sget(1))
|
||||||
check(2, A_int_static.sget(1.0))
|
check(2, A_int_static.sget(1.0))
|
||||||
check(3, A_int_static.sget(B()))
|
check(3, A_int_static.sget(B()))
|
||||||
|
|
@ -59,10 +62,14 @@ except TypeError:
|
||||||
|
|
||||||
#### Global variable assignment ####
|
#### Global variable assignment ####
|
||||||
|
|
||||||
cvar.foo = Foo(1); check(cvar.foo.ii, 1)
|
cvar.foo = Foo(1)
|
||||||
cvar.foo = 1; check(cvar.foo.ii, 1)
|
check(cvar.foo.ii, 1)
|
||||||
cvar.foo = 1.0; check(cvar.foo.ii, 2)
|
cvar.foo = 1
|
||||||
cvar.foo = Foo("hello"); check(cvar.foo.ii, 3)
|
check(cvar.foo.ii, 1)
|
||||||
|
cvar.foo = 1.0
|
||||||
|
check(cvar.foo.ii, 2)
|
||||||
|
cvar.foo = Foo("hello")
|
||||||
|
check(cvar.foo.ii, 3)
|
||||||
|
|
||||||
# explicit constructor:
|
# explicit constructor:
|
||||||
try:
|
try:
|
||||||
|
|
@ -74,10 +81,14 @@ except TypeError:
|
||||||
#### Member variable assignment ####
|
#### Member variable assignment ####
|
||||||
# Note: also needs naturalvar
|
# Note: also needs naturalvar
|
||||||
|
|
||||||
b = Bar(); check(b.f.ii, 0)
|
b = Bar()
|
||||||
b.f = Foo("hello"); check(b.f.ii, 3)
|
check(b.f.ii, 0)
|
||||||
b.f = 1; check(b.f.ii, 1)
|
b.f = Foo("hello")
|
||||||
b.f = 1.0; check(b.f.ii, 2)
|
check(b.f.ii, 3)
|
||||||
|
b.f = 1
|
||||||
|
check(b.f.ii, 1)
|
||||||
|
b.f = 1.0
|
||||||
|
check(b.f.ii, 2)
|
||||||
|
|
||||||
# explicit constructor:
|
# explicit constructor:
|
||||||
try:
|
try:
|
||||||
|
|
@ -129,4 +140,3 @@ ccc = CCC(B())
|
||||||
check(ccc.checkvalue, 10)
|
check(ccc.checkvalue, 10)
|
||||||
check(ccc.xx(123), 11)
|
check(ccc.xx(123), 11)
|
||||||
check(ccc.yy(123, 123), 111)
|
check(ccc.yy(123, 123), 111)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@ from import_nomodule import *
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# The base class is needed for the builtin class hierarchy
|
# The base class is needed for the builtin class hierarchy
|
||||||
if is_python_builtin():
|
if is_python_builtin():
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
f = create_Foo()
|
f = create_Foo()
|
||||||
test1(f,42)
|
test1(f, 42)
|
||||||
delete_Foo(f)
|
delete_Foo(f)
|
||||||
|
|
||||||
b = Bar()
|
b = Bar()
|
||||||
test1(b,37)
|
test1(b, 37)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import import_stl_b
|
import import_stl_b
|
||||||
import import_stl_a
|
import import_stl_a
|
||||||
|
|
||||||
v_new = import_stl_b.process_vector([1,2,3])
|
v_new = import_stl_b.process_vector([1, 2, 3])
|
||||||
if v_new != (1,2,3,4):
|
if v_new != (1, 2, 3, 4):
|
||||||
raise RuntimeError, v_new
|
raise RuntimeError, v_new
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,4 @@ a1 = c.get_a(c)
|
||||||
a2 = c.get_a_type(c)
|
a2 = c.get_a_type(c)
|
||||||
|
|
||||||
if a1.hello() != a2.hello():
|
if a1.hello() != a2.hello():
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,30 @@ import inctest
|
||||||
|
|
||||||
error = 0
|
error = 0
|
||||||
try:
|
try:
|
||||||
a = inctest.A()
|
a = inctest.A()
|
||||||
except:
|
except:
|
||||||
print "didn't find A"
|
print "didn't find A"
|
||||||
print "therefore, I didn't include 'testdir/subdir1/hello.i'"
|
print "therefore, I didn't include 'testdir/subdir1/hello.i'"
|
||||||
error = 1
|
error = 1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
b = inctest.B()
|
b = inctest.B()
|
||||||
except:
|
except:
|
||||||
print "didn't find B"
|
print "didn't find B"
|
||||||
print "therefore, I didn't include 'testdir/subdir2/hello.i'"
|
print "therefore, I didn't include 'testdir/subdir2/hello.i'"
|
||||||
error = 1
|
error = 1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if error == 1:
|
if error == 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# Check the import in subdirectory worked
|
# Check the import in subdirectory worked
|
||||||
if inctest.importtest1(5) != 15:
|
if inctest.importtest1(5) != 15:
|
||||||
print "import test 1 failed"
|
print "import test 1 failed"
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if inctest.importtest2("black") != "white":
|
if inctest.importtest2("black") != "white":
|
||||||
print "import test 2 failed"
|
print "import test 2 failed"
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,20 @@ import inout
|
||||||
|
|
||||||
a = inout.AddOne1(1)
|
a = inout.AddOne1(1)
|
||||||
if a != 2:
|
if a != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a = inout.AddOne3(1,1,1)
|
a = inout.AddOne3(1, 1, 1)
|
||||||
if a != [2,2,2]:
|
if a != [2, 2, 2]:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a = inout.AddOne1p((1,1))
|
a = inout.AddOne1p((1, 1))
|
||||||
if a != (2,2):
|
if a != (2, 2):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a = inout.AddOne2p((1,1),1)
|
a = inout.AddOne2p((1, 1), 1)
|
||||||
if a != [(2,2),2]:
|
if a != [(2, 2), 2]:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a = inout.AddOne3p(1,(1,1),1)
|
|
||||||
if a != [2,(2,2),2]:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
|
a = inout.AddOne3p(1, (1, 1), 1)
|
||||||
|
if a != [2, (2, 2), 2]:
|
||||||
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@ a = inplaceadd.A(7)
|
||||||
|
|
||||||
a += 5
|
a += 5
|
||||||
if a.val != 12:
|
if a.val != 12:
|
||||||
print a.val
|
print a.val
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a -= 5
|
a -= 5
|
||||||
if a.val != 7:
|
if a.val != 7:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a *= 2
|
a *= 2
|
||||||
|
|
||||||
if a.val != 14:
|
if a.val != 14:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
a += a
|
a += a
|
||||||
if a.val != 28:
|
if a.val != 28:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,19 @@ from input import *
|
||||||
|
|
||||||
f = Foo()
|
f = Foo()
|
||||||
if f.foo(2) != 4:
|
if f.foo(2) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if f.foo(None)!= None:
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
if f.foo()!= None:
|
if f.foo(None) != None:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
if f.foo() != None:
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
if sfoo("Hello") != "Hello world":
|
if sfoo("Hello") != "Hello world":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if sfoo(None) != None:
|
if sfoo(None) != None:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if sfoo() != None:
|
if sfoo() != None:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -1,81 +1,81 @@
|
||||||
from kwargs_feature import *
|
from kwargs_feature import *
|
||||||
|
|
||||||
class MyFoo(Foo):
|
|
||||||
def __init__(self, a , b = 0):
|
|
||||||
Foo.__init__(self, a, b)
|
|
||||||
|
|
||||||
|
class MyFoo(Foo):
|
||||||
|
|
||||||
|
def __init__(self, a, b=0):
|
||||||
|
Foo.__init__(self, a, b)
|
||||||
|
|
||||||
|
|
||||||
# Simple class
|
# Simple class
|
||||||
f1 = MyFoo(2)
|
f1 = MyFoo(2)
|
||||||
|
|
||||||
f = Foo(b=2,a=1)
|
f = Foo(b=2, a=1)
|
||||||
|
|
||||||
if f.foo(b=1,a=2) != 3:
|
if f.foo(b=1, a=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if Foo_statfoo(b=2) != 3:
|
if Foo_statfoo(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if f.efoo(b=2) != 3:
|
if f.efoo(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if Foo_sfoo(b=2) != 3:
|
if Foo_sfoo(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
# Templated class
|
# Templated class
|
||||||
b = BarInt(b=2,a=1)
|
b = BarInt(b=2, a=1)
|
||||||
|
|
||||||
if b.bar(b=1,a=2) != 3:
|
if b.bar(b=1, a=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if BarInt_statbar(b=2) != 3:
|
if BarInt_statbar(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if b.ebar(b=2) != 3:
|
if b.ebar(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if BarInt_sbar(b=2) != 3:
|
if BarInt_sbar(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
if templatedfunction(b=2) != 3:
|
if templatedfunction(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foo_fn(a=1,b=2) != 3:
|
if foo_fn(a=1, b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foo_fn(b=2) != 3:
|
if foo_fn(b=2) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
#Functions with keywords
|
# Functions with keywords
|
||||||
|
|
||||||
if foo_kw(_from=2) != 4:
|
if foo_kw(_from=2) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foo_nu(_from=2, arg2=3) != 2:
|
if foo_nu(_from=2, arg2=3) != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foo_mm(min=2) != 4:
|
if foo_mm(min=2) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if foo_mm(max=3) != 4:
|
if foo_mm(max=3) != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
#Default args with references
|
# Default args with references
|
||||||
|
|
||||||
if rfoo(n=123) != 120:
|
if rfoo(n=123) != 120:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if rfoo(x=10) != -10:
|
if rfoo(x=10) != -10:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if rfoo(n=11, x=22) != -11:
|
if rfoo(n=11, x=22) != -11:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if rfoo(x=11, n=22) != 11:
|
if rfoo(x=11, n=22) != 11:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import sys
|
||||||
from langobj import *
|
from langobj import *
|
||||||
|
|
||||||
|
|
||||||
x ="hello"
|
x = "hello"
|
||||||
rx = sys.getrefcount(x)
|
rx = sys.getrefcount(x)
|
||||||
v = identity(x)
|
v = identity(x)
|
||||||
rv = sys.getrefcount(v)
|
rv = sys.getrefcount(v)
|
||||||
|
|
|
||||||
|
|
@ -2,73 +2,72 @@
|
||||||
|
|
||||||
import li_attribute
|
import li_attribute
|
||||||
|
|
||||||
aa = li_attribute.A(1,2,3)
|
aa = li_attribute.A(1, 2, 3)
|
||||||
|
|
||||||
if aa.a != 1:
|
if aa.a != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
aa.a = 3
|
aa.a = 3
|
||||||
if aa.a != 3:
|
if aa.a != 3:
|
||||||
print aa.a
|
print aa.a
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if aa.b != 2:
|
if aa.b != 2:
|
||||||
print aa.b
|
print aa.b
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
aa.b = 5
|
aa.b = 5
|
||||||
if aa.b != 5:
|
if aa.b != 5:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if aa.d != aa.b:
|
if aa.d != aa.b:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if aa.c != 3:
|
if aa.c != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
#aa.c = 5
|
#aa.c = 5
|
||||||
#if aa.c != 3:
|
# if aa.c != 3:
|
||||||
# raise RuntimeError
|
# raise RuntimeError
|
||||||
|
|
||||||
pi = li_attribute.Param_i(7)
|
pi = li_attribute.Param_i(7)
|
||||||
if pi.value != 7:
|
if pi.value != 7:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
pi.value=3
|
pi.value = 3
|
||||||
if pi.value != 3:
|
if pi.value != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
b = li_attribute.B(aa)
|
b = li_attribute.B(aa)
|
||||||
|
|
||||||
if b.a.c != 3:
|
if b.a.c != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# class/struct attribute with get/set methods using return/pass by reference
|
# class/struct attribute with get/set methods using return/pass by reference
|
||||||
myFoo = li_attribute.MyFoo()
|
myFoo = li_attribute.MyFoo()
|
||||||
myFoo.x = 8
|
myFoo.x = 8
|
||||||
myClass = li_attribute.MyClass()
|
myClass = li_attribute.MyClass()
|
||||||
myClass.Foo = myFoo
|
myClass.Foo = myFoo
|
||||||
if myClass.Foo.x != 8:
|
if myClass.Foo.x != 8:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# class/struct attribute with get/set methods using return/pass by value
|
# class/struct attribute with get/set methods using return/pass by value
|
||||||
myClassVal = li_attribute.MyClassVal()
|
myClassVal = li_attribute.MyClassVal()
|
||||||
if myClassVal.ReadWriteFoo.x != -1:
|
if myClassVal.ReadWriteFoo.x != -1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if myClassVal.ReadOnlyFoo.x != -1:
|
if myClassVal.ReadOnlyFoo.x != -1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
myClassVal.ReadWriteFoo = myFoo
|
myClassVal.ReadWriteFoo = myFoo
|
||||||
if myClassVal.ReadWriteFoo.x != 8:
|
if myClassVal.ReadWriteFoo.x != 8:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if myClassVal.ReadOnlyFoo.x != 8:
|
if myClassVal.ReadOnlyFoo.x != 8:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
# string attribute with get/set methods using return/pass by value
|
# string attribute with get/set methods using return/pass by value
|
||||||
myStringyClass = li_attribute.MyStringyClass("initial string")
|
myStringyClass = li_attribute.MyStringyClass("initial string")
|
||||||
if myStringyClass.ReadWriteString != "initial string":
|
if myStringyClass.ReadWriteString != "initial string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if myStringyClass.ReadOnlyString != "initial string":
|
if myStringyClass.ReadOnlyString != "initial string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
myStringyClass.ReadWriteString = "changed string"
|
myStringyClass.ReadWriteString = "changed string"
|
||||||
if myStringyClass.ReadWriteString != "changed string":
|
if myStringyClass.ReadWriteString != "changed string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if myStringyClass.ReadOnlyString != "changed string":
|
if myStringyClass.ReadOnlyString != "changed string":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,66 +2,67 @@
|
||||||
|
|
||||||
import li_attribute_template
|
import li_attribute_template
|
||||||
|
|
||||||
chell = li_attribute_template.Cintint(1,2,3)
|
chell = li_attribute_template.Cintint(1, 2, 3)
|
||||||
|
|
||||||
def rassert( what, master ):
|
|
||||||
|
def rassert(what, master):
|
||||||
if what != master:
|
if what != master:
|
||||||
print what
|
print what
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
## Testing primitive by value attribute
|
# Testing primitive by value attribute
|
||||||
rassert( chell.a, 1 )
|
rassert(chell.a, 1)
|
||||||
|
|
||||||
chell.a = 3
|
chell.a = 3
|
||||||
rassert( chell.a, 3 )
|
rassert(chell.a, 3)
|
||||||
|
|
||||||
## Testing primitive by ref attribute
|
# Testing primitive by ref attribute
|
||||||
|
|
||||||
rassert( chell.b, 2 )
|
rassert(chell.b, 2)
|
||||||
|
|
||||||
chell.b = 5
|
chell.b = 5
|
||||||
rassert( chell.b,5 )
|
rassert(chell.b, 5)
|
||||||
|
|
||||||
## Testing string
|
# Testing string
|
||||||
chell.str = "abc"
|
chell.str = "abc"
|
||||||
rassert( chell.str, "abc" )
|
rassert(chell.str, "abc")
|
||||||
|
|
||||||
# Testing class by value
|
# Testing class by value
|
||||||
|
|
||||||
rassert( chell.d.value, 1 )
|
rassert(chell.d.value, 1)
|
||||||
|
|
||||||
chell.d = li_attribute_template.Foo(2)
|
chell.d = li_attribute_template.Foo(2)
|
||||||
rassert( chell.d.value, 2 )
|
rassert(chell.d.value, 2)
|
||||||
|
|
||||||
# Testing class by reference
|
# Testing class by reference
|
||||||
|
|
||||||
rassert( chell.e.value, 2 )
|
rassert(chell.e.value, 2)
|
||||||
|
|
||||||
chell.e= li_attribute_template.Foo(3)
|
chell.e = li_attribute_template.Foo(3)
|
||||||
rassert( chell.e.value, 3 )
|
rassert(chell.e.value, 3)
|
||||||
|
|
||||||
chell.e.value = 4
|
chell.e.value = 4
|
||||||
rassert( chell.e.value, 4 )
|
rassert(chell.e.value, 4)
|
||||||
|
|
||||||
# Testing moderately complex template by value
|
# Testing moderately complex template by value
|
||||||
rassert( chell.f.first, 1 )
|
rassert(chell.f.first, 1)
|
||||||
rassert( chell.f.second, 2 )
|
rassert(chell.f.second, 2)
|
||||||
|
|
||||||
pair = li_attribute_template.pair_intint(3,4)
|
pair = li_attribute_template.pair_intint(3, 4)
|
||||||
chell.f = pair
|
chell.f = pair
|
||||||
rassert( chell.f.first, 3 )
|
rassert(chell.f.first, 3)
|
||||||
rassert( chell.f.second, 4 )
|
rassert(chell.f.second, 4)
|
||||||
|
|
||||||
# Testing moderately complex template by ref
|
# Testing moderately complex template by ref
|
||||||
rassert( chell.g.first, 2 )
|
rassert(chell.g.first, 2)
|
||||||
rassert( chell.g.second, 3 )
|
rassert(chell.g.second, 3)
|
||||||
|
|
||||||
pair = li_attribute_template.pair_intint(4,5)
|
pair = li_attribute_template.pair_intint(4, 5)
|
||||||
chell.g = pair
|
chell.g = pair
|
||||||
rassert( chell.g.first, 4 )
|
rassert(chell.g.first, 4)
|
||||||
rassert( chell.g.second, 5 )
|
rassert(chell.g.second, 5)
|
||||||
|
|
||||||
chell.g.first = 6
|
chell.g.first = 6
|
||||||
chell.g.second = 7
|
chell.g.second = 7
|
||||||
rassert( chell.g.first, 6 )
|
rassert(chell.g.first, 6)
|
||||||
rassert( chell.g.second, 7 )
|
rassert(chell.g.second, 7)
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,22 @@
|
||||||
from li_boost_shared_ptr_bits import *
|
from li_boost_shared_ptr_bits import *
|
||||||
|
|
||||||
|
|
||||||
def is_new_style_class(cls):
|
def is_new_style_class(cls):
|
||||||
return hasattr(cls, "__class__")
|
return hasattr(cls, "__class__")
|
||||||
|
|
||||||
|
|
||||||
def check(nd):
|
def check(nd):
|
||||||
nd.i = 200
|
nd.i = 200
|
||||||
i = nd.i
|
i = nd.i
|
||||||
|
|
||||||
try:
|
try:
|
||||||
nd.notexist = 100
|
nd.notexist = 100
|
||||||
passed = 0
|
passed = 0
|
||||||
except:
|
except:
|
||||||
passed = 1
|
passed = 1
|
||||||
|
|
||||||
if not passed:
|
if not passed:
|
||||||
raise "Test failed"
|
raise "Test failed"
|
||||||
|
|
||||||
nd = NonDynamic()
|
nd = NonDynamic()
|
||||||
check(nd)
|
check(nd)
|
||||||
|
|
@ -30,11 +32,10 @@ v.push_back(IntHolder(33))
|
||||||
|
|
||||||
sum = sum(v)
|
sum = sum(v)
|
||||||
if sum != 66:
|
if sum != 66:
|
||||||
raise "sum is wrong"
|
raise "sum is wrong"
|
||||||
|
|
||||||
################################
|
################################
|
||||||
if is_new_style_class(HiddenDestructor):
|
if is_new_style_class(HiddenDestructor):
|
||||||
p = HiddenDestructor.create()
|
p = HiddenDestructor.create()
|
||||||
else:
|
else:
|
||||||
p = HiddenDestructor_create()
|
p = HiddenDestructor_create()
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -3,28 +3,28 @@ from li_boost_shared_ptr_template import *
|
||||||
b = BaseINTEGER()
|
b = BaseINTEGER()
|
||||||
d = DerivedINTEGER()
|
d = DerivedINTEGER()
|
||||||
if b.bar() != 1:
|
if b.bar() != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if d.bar() != 2:
|
if d.bar() != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if bar_getter(b) != 1:
|
if bar_getter(b) != 1:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
# Fix reverted in rev 12953
|
# Fix reverted in rev 12953
|
||||||
#if bar_getter(d) != 2:
|
# if bar_getter(d) != 2:
|
||||||
# raise RuntimeError
|
# raise RuntimeError
|
||||||
|
|
||||||
b = BaseDefaultInt()
|
b = BaseDefaultInt()
|
||||||
d = DerivedDefaultInt()
|
d = DerivedDefaultInt()
|
||||||
d2 = DerivedDefaultInt2()
|
d2 = DerivedDefaultInt2()
|
||||||
if b.bar2() != 3:
|
if b.bar2() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if d.bar2() != 4:
|
if d.bar2() != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if d2.bar2() != 4:
|
if d2.bar2() != 4:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
if bar2_getter(b) != 3:
|
if bar2_getter(b) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
# Fix reverted in rev 12953
|
# Fix reverted in rev 12953
|
||||||
#if bar2_getter(d) != 4:
|
# if bar2_getter(d) != 4:
|
||||||
# raise RuntimeError
|
# raise RuntimeError
|
||||||
#if bar2_getter(d2) != 4:
|
# if bar2_getter(d2) != 4:
|
||||||
# raise RuntimeError
|
# raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,4 @@ m = malloc(256)
|
||||||
memmove(m, s)
|
memmove(m, s)
|
||||||
ss = cdata(m, 7)
|
ss = cdata(m, 7)
|
||||||
if ss != "ABC abc":
|
if ss != "ABC abc":
|
||||||
raise "failed"
|
raise "failed"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from li_cpointer import *
|
||||||
|
|
||||||
|
|
||||||
p = new_intp()
|
p = new_intp()
|
||||||
intp_assign(p,3)
|
intp_assign(p, 3)
|
||||||
|
|
||||||
if intp_value(p) != 3:
|
if intp_value(p) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from li_cstring import *
|
||||||
|
|
||||||
|
|
||||||
if count("ab\0ab\0ab\0", 0) != 3:
|
if count("ab\0ab\0ab\0", 0) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test1() != "Hello World":
|
if test1() != "Hello World":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
@ -17,16 +17,15 @@ if test3("hello") != "hello-suffix":
|
||||||
if test4("hello") != "hello-suffix":
|
if test4("hello") != "hello-suffix":
|
||||||
print test4("hello")
|
print test4("hello")
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test5(4) != 'xxxx':
|
if test5(4) != 'xxxx':
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test6(10) != 'xxxxx':
|
if test6(10) != 'xxxxx':
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test7() !="Hello world!":
|
if test7() != "Hello world!":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
|
if test8() != " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
from li_cwstring import *
|
from li_cwstring import *
|
||||||
|
|
||||||
if count(u"ab\0ab\0ab\0", 0) != 3:
|
if count(u"ab\0ab\0ab\0", 0) != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test1() != u"Hello World":
|
if test1() != u"Hello World":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
@ -14,16 +14,15 @@ if test3("hello") != u"hello-suffix":
|
||||||
|
|
||||||
if test4("hello") != u"hello-suffix":
|
if test4("hello") != u"hello-suffix":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test5(4) != u'xxxx':
|
if test5(4) != u'xxxx':
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test6(10) != u'xxxxx':
|
if test6(10) != u'xxxxx':
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test7() != u"Hello world!":
|
if test7() != u"Hello world!":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
|
if test8() != u" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,8 @@ ad, get(ad)
|
||||||
ab, get(ab)
|
ab, get(ab)
|
||||||
|
|
||||||
if get(ai) != get(1):
|
if get(ai) != get(1):
|
||||||
raise RuntimeError,"bad implicit type"
|
raise RuntimeError, "bad implicit type"
|
||||||
if get(ad) != get(2.0):
|
if get(ad) != get(2.0):
|
||||||
raise RuntimeError,"bad implicit type"
|
raise RuntimeError, "bad implicit type"
|
||||||
if get(ab) != get(b):
|
if get(ab) != get(b):
|
||||||
raise RuntimeError,"bad implicit type"
|
raise RuntimeError, "bad implicit type"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,15 @@ from li_std_auto_ptr import *
|
||||||
k1 = makeKlassAutoPtr("first")
|
k1 = makeKlassAutoPtr("first")
|
||||||
k2 = makeKlassAutoPtr("second")
|
k2 = makeKlassAutoPtr("second")
|
||||||
if Klass_getTotal_count() != 2:
|
if Klass_getTotal_count() != 2:
|
||||||
raise "number of objects should be 2"
|
raise "number of objects should be 2"
|
||||||
|
|
||||||
del k1
|
del k1
|
||||||
if Klass_getTotal_count() != 1:
|
if Klass_getTotal_count() != 1:
|
||||||
raise "number of objects should be 1"
|
raise "number of objects should be 1"
|
||||||
|
|
||||||
if k2.getLabel() != "second":
|
if k2.getLabel() != "second":
|
||||||
raise "wrong object label"
|
raise "wrong object label"
|
||||||
|
|
||||||
del k2
|
del k2
|
||||||
if Klass_getTotal_count() != 0:
|
if Klass_getTotal_count() != 0:
|
||||||
raise "no objects should be left"
|
raise "no objects should be left"
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from li_std_carray import *
|
||||||
|
|
||||||
|
|
||||||
v3 = Vector3()
|
v3 = Vector3()
|
||||||
for i in range(0,len(v3)):
|
for i in range(0, len(v3)):
|
||||||
v3[i] = i
|
v3[i] = i
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -14,9 +14,9 @@ for d in v3:
|
||||||
|
|
||||||
m3 = Matrix3()
|
m3 = Matrix3()
|
||||||
|
|
||||||
for i in range(0,len(m3)):
|
for i in range(0, len(m3)):
|
||||||
v3 = m3[i]
|
v3 = m3[i]
|
||||||
for j in range(0,len(v3)):
|
for j in range(0, len(v3)):
|
||||||
v3[j] = i + j
|
v3[j] = i + j
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
@ -30,12 +30,10 @@ for v3 in m3:
|
||||||
i = i + 1
|
i = i + 1
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for i in range(0,len(m3)):
|
for i in range(0, len(m3)):
|
||||||
for j in range(0,len(m3)):
|
for j in range(0, len(m3)):
|
||||||
if m3[i][j] != i + j:
|
if m3[i][j] != i + j:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
da = Vector3((1,2,3))
|
da = Vector3((1, 2, 3))
|
||||||
ma = Matrix3(((1,2,3),(4,5,6),(7,8,9)))
|
ma = Matrix3(((1, 2, 3), (4, 5, 6), (7, 8, 9)))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,158 +1,170 @@
|
||||||
# Check std::vector and std::list behaves the same as Python iterable types (list)
|
# Check std::vector and std::list behaves the same as Python iterable
|
||||||
|
# types (list)
|
||||||
|
|
||||||
from li_std_containers_int import *
|
from li_std_containers_int import *
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def failed(a, b, msg):
|
def failed(a, b, msg):
|
||||||
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
|
||||||
|
|
||||||
|
|
||||||
def compare_sequences(a, b):
|
def compare_sequences(a, b):
|
||||||
if len(a) != len(b):
|
if len(a) != len(b):
|
||||||
failed(a, b, "different sizes")
|
failed(a, b, "different sizes")
|
||||||
for i in range(len(a)):
|
for i in range(len(a)):
|
||||||
if a[i] != b[i]:
|
if a[i] != b[i]:
|
||||||
failed(a, b, "elements are different")
|
failed(a, b, "elements are different")
|
||||||
|
|
||||||
|
|
||||||
def compare_containers(pythonlist, swigvector, swiglist):
|
def compare_containers(pythonlist, swigvector, swiglist):
|
||||||
compare_sequences(pythonlist, swigvector)
|
compare_sequences(pythonlist, swigvector)
|
||||||
compare_sequences(pythonlist, swiglist)
|
compare_sequences(pythonlist, swiglist)
|
||||||
|
|
||||||
|
# Check std::vector and std::list assignment behaves same as Python list
|
||||||
|
# assignment including exceptions
|
||||||
|
|
||||||
|
|
||||||
# Check std::vector and std::list assignment behaves same as Python list assignment including exceptions
|
|
||||||
def container_insert_step(i, j, step, newval):
|
def container_insert_step(i, j, step, newval):
|
||||||
ps = range(6)
|
ps = range(6)
|
||||||
iv = vector_int(ps)
|
iv = vector_int(ps)
|
||||||
il = list_int(ps)
|
il = list_int(ps)
|
||||||
|
|
||||||
# Python slice
|
# Python slice
|
||||||
try:
|
try:
|
||||||
if step == None:
|
if step == None:
|
||||||
if j == None:
|
if j == None:
|
||||||
ps[i] = newval
|
ps[i] = newval
|
||||||
else:
|
else:
|
||||||
ps[i:j] = newval
|
ps[i:j] = newval
|
||||||
else:
|
else:
|
||||||
if j == None:
|
if j == None:
|
||||||
ps[i::step] = newval
|
ps[i::step] = newval
|
||||||
else:
|
else:
|
||||||
ps[i:j:step] = newval
|
ps[i:j:step] = newval
|
||||||
ps_error = None
|
ps_error = None
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
ps_error = e
|
ps_error = e
|
||||||
except IndexError, e:
|
except IndexError, e:
|
||||||
ps_error = e
|
ps_error = e
|
||||||
|
|
||||||
# std::vector<int>
|
# std::vector<int>
|
||||||
try:
|
try:
|
||||||
if step == None:
|
if step == None:
|
||||||
if j == None:
|
if j == None:
|
||||||
iv[i] = newval
|
iv[i] = newval
|
||||||
else:
|
else:
|
||||||
iv[i:j] = newval
|
iv[i:j] = newval
|
||||||
else:
|
else:
|
||||||
if j == None:
|
if j == None:
|
||||||
iv[i::step] = newval
|
iv[i::step] = newval
|
||||||
else:
|
else:
|
||||||
iv[i:j:step] = newval
|
iv[i:j:step] = newval
|
||||||
iv_error = None
|
iv_error = None
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
iv_error = e
|
iv_error = e
|
||||||
except IndexError, e:
|
except IndexError, e:
|
||||||
iv_error = e
|
iv_error = e
|
||||||
|
|
||||||
# std::list<int>
|
# std::list<int>
|
||||||
try:
|
try:
|
||||||
if step == None:
|
if step == None:
|
||||||
if j == None:
|
if j == None:
|
||||||
il[i] = newval
|
il[i] = newval
|
||||||
else:
|
else:
|
||||||
il[i:j] = newval
|
il[i:j] = newval
|
||||||
else:
|
else:
|
||||||
if j == None:
|
if j == None:
|
||||||
il[i::step] = newval
|
il[i::step] = newval
|
||||||
else:
|
else:
|
||||||
il[i:j:step] = newval
|
il[i:j:step] = newval
|
||||||
il_error = None
|
il_error = None
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
il_error = e
|
il_error = e
|
||||||
except IndexError, e:
|
except IndexError, e:
|
||||||
il_error = e
|
il_error = e
|
||||||
|
|
||||||
|
# Python 2.6 contains bug fixes in extended slicing syntax:
|
||||||
|
# http://docs.python.org/2/whatsnew/2.6.html
|
||||||
|
skip_check = ps_error != None and(
|
||||||
|
iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
|
||||||
|
if not(skip_check):
|
||||||
|
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||||
|
raise RuntimeError, "ValueError exception not consistently thrown: " + \
|
||||||
|
str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||||
|
|
||||||
|
compare_containers(ps, iv, il)
|
||||||
|
|
||||||
|
|
||||||
|
# Check std::vector and std::list delete behaves same as Python list
|
||||||
|
# delete including exceptions
|
||||||
|
def container_delete_step(i, j, step):
|
||||||
|
ps = range(6)
|
||||||
|
iv = vector_int(ps)
|
||||||
|
il = list_int(ps)
|
||||||
|
|
||||||
|
# Python slice
|
||||||
|
try:
|
||||||
|
if step == None:
|
||||||
|
if j == None:
|
||||||
|
del ps[i]
|
||||||
|
else:
|
||||||
|
del ps[i:j]
|
||||||
|
else:
|
||||||
|
if j == None:
|
||||||
|
del ps[i::step]
|
||||||
|
else:
|
||||||
|
del ps[i:j:step]
|
||||||
|
ps_error = None
|
||||||
|
except ValueError, e:
|
||||||
|
ps_error = e
|
||||||
|
except IndexError, e:
|
||||||
|
ps_error = e
|
||||||
|
|
||||||
|
# std::vector<int>
|
||||||
|
try:
|
||||||
|
if step == None:
|
||||||
|
if j == None:
|
||||||
|
del iv[i]
|
||||||
|
else:
|
||||||
|
del iv[i:j]
|
||||||
|
else:
|
||||||
|
if j == None:
|
||||||
|
del iv[i::step]
|
||||||
|
else:
|
||||||
|
del iv[i:j:step]
|
||||||
|
iv_error = None
|
||||||
|
except ValueError, e:
|
||||||
|
iv_error = e
|
||||||
|
except IndexError, e:
|
||||||
|
iv_error = e
|
||||||
|
|
||||||
|
# std::list<int>
|
||||||
|
try:
|
||||||
|
if step == None:
|
||||||
|
if j == None:
|
||||||
|
del il[i]
|
||||||
|
else:
|
||||||
|
del il[i:j]
|
||||||
|
else:
|
||||||
|
if j == None:
|
||||||
|
del il[i::step]
|
||||||
|
else:
|
||||||
|
del il[i:j:step]
|
||||||
|
il_error = None
|
||||||
|
except ValueError, e:
|
||||||
|
il_error = e
|
||||||
|
except IndexError, e:
|
||||||
|
il_error = e
|
||||||
|
|
||||||
# Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html
|
|
||||||
skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
|
|
||||||
if not(skip_check):
|
|
||||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
||||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
raise RuntimeError, "ValueError exception not consistently thrown: " + \
|
||||||
|
str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
||||||
|
|
||||||
compare_containers(ps, iv, il)
|
compare_containers(ps, iv, il)
|
||||||
|
|
||||||
|
|
||||||
# Check std::vector and std::list delete behaves same as Python list delete including exceptions
|
ps = [0, 1, 2, 3, 4, 5]
|
||||||
def container_delete_step(i, j, step):
|
|
||||||
ps = range(6)
|
|
||||||
iv = vector_int(ps)
|
|
||||||
il = list_int(ps)
|
|
||||||
|
|
||||||
# Python slice
|
|
||||||
try:
|
|
||||||
if step == None:
|
|
||||||
if j == None:
|
|
||||||
del ps[i]
|
|
||||||
else:
|
|
||||||
del ps[i:j]
|
|
||||||
else:
|
|
||||||
if j == None:
|
|
||||||
del ps[i::step]
|
|
||||||
else:
|
|
||||||
del ps[i:j:step]
|
|
||||||
ps_error = None
|
|
||||||
except ValueError, e:
|
|
||||||
ps_error = e
|
|
||||||
except IndexError, e:
|
|
||||||
ps_error = e
|
|
||||||
|
|
||||||
# std::vector<int>
|
|
||||||
try:
|
|
||||||
if step == None:
|
|
||||||
if j == None:
|
|
||||||
del iv[i]
|
|
||||||
else:
|
|
||||||
del iv[i:j]
|
|
||||||
else:
|
|
||||||
if j == None:
|
|
||||||
del iv[i::step]
|
|
||||||
else:
|
|
||||||
del iv[i:j:step]
|
|
||||||
iv_error = None
|
|
||||||
except ValueError, e:
|
|
||||||
iv_error = e
|
|
||||||
except IndexError, e:
|
|
||||||
iv_error = e
|
|
||||||
|
|
||||||
# std::list<int>
|
|
||||||
try:
|
|
||||||
if step == None:
|
|
||||||
if j == None:
|
|
||||||
del il[i]
|
|
||||||
else:
|
|
||||||
del il[i:j]
|
|
||||||
else:
|
|
||||||
if j == None:
|
|
||||||
del il[i::step]
|
|
||||||
else:
|
|
||||||
del il[i:j:step]
|
|
||||||
il_error = None
|
|
||||||
except ValueError, e:
|
|
||||||
il_error = e
|
|
||||||
except IndexError, e:
|
|
||||||
il_error = e
|
|
||||||
|
|
||||||
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
|
|
||||||
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
|
|
||||||
|
|
||||||
compare_containers(ps, iv, il)
|
|
||||||
|
|
||||||
|
|
||||||
ps = [0,1,2,3,4,5]
|
|
||||||
|
|
||||||
iv = vector_int(ps)
|
iv = vector_int(ps)
|
||||||
il = list_int(ps)
|
il = list_int(ps)
|
||||||
|
|
@ -164,7 +176,7 @@ compare_containers(ps[1:3], iv[1:3], il[1:3])
|
||||||
compare_containers(ps[2:4], iv[2:4], il[2:4])
|
compare_containers(ps[2:4], iv[2:4], il[2:4])
|
||||||
compare_containers(ps[0:3], iv[0:3], il[0:3])
|
compare_containers(ps[0:3], iv[0:3], il[0:3])
|
||||||
compare_containers(ps[3:6], iv[3:6], il[3:6])
|
compare_containers(ps[3:6], iv[3:6], il[3:6])
|
||||||
compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range
|
compare_containers(ps[3:10], iv[3:10], il[3:10]) # beyond end of range
|
||||||
|
|
||||||
# before beginning of range (negative indexing)
|
# before beginning of range (negative indexing)
|
||||||
compare_containers(ps[-1:7], iv[-1:7], il[-1:7])
|
compare_containers(ps[-1:7], iv[-1:7], il[-1:7])
|
||||||
|
|
@ -172,7 +184,8 @@ compare_containers(ps[-2:7], iv[-2:7], il[-2:7])
|
||||||
compare_containers(ps[-5:7], iv[-5:7], il[-5:7])
|
compare_containers(ps[-5:7], iv[-5:7], il[-5:7])
|
||||||
compare_containers(ps[-6:7], iv[-6:7], il[-6:7])
|
compare_containers(ps[-6:7], iv[-6:7], il[-6:7])
|
||||||
|
|
||||||
# before beginning of range (negative indexing, negative index is > container size)
|
# before beginning of range (negative indexing, negative index is >
|
||||||
|
# container size)
|
||||||
compare_containers(ps[-7:7], iv[-7:7], il[-7:7])
|
compare_containers(ps[-7:7], iv[-7:7], il[-7:7])
|
||||||
compare_containers(ps[-100:7], iv[-100:7], il[-100:7])
|
compare_containers(ps[-100:7], iv[-100:7], il[-100:7])
|
||||||
|
|
||||||
|
|
@ -222,48 +235,52 @@ compare_containers(ps[::-5], iv[::-5], il[::-5])
|
||||||
|
|
||||||
# insert sequences (growing, shrinking and staying same size)
|
# insert sequences (growing, shrinking and staying same size)
|
||||||
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||||
# single element set/replace
|
# single element set/replace
|
||||||
container_insert_step(start, None, None, 111)
|
container_insert_step(start, None, None, 111)
|
||||||
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666, 777])
|
container_insert_step(
|
||||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666])
|
start, end, None, [111, 222, 333, 444, 555, 666, 777])
|
||||||
container_insert_step(start, end, None, [111, 222, 333, 444, 555])
|
container_insert_step(start, end, None, [111, 222, 333, 444, 555, 666])
|
||||||
container_insert_step(start, end, None, [111, 222, 333, 444])
|
container_insert_step(start, end, None, [111, 222, 333, 444, 555])
|
||||||
container_insert_step(start, end, None, [111, 222, 333])
|
container_insert_step(start, end, None, [111, 222, 333, 444])
|
||||||
container_insert_step(start, end, None, [111, 222])
|
container_insert_step(start, end, None, [111, 222, 333])
|
||||||
container_insert_step(start, end, None, [111])
|
container_insert_step(start, end, None, [111, 222])
|
||||||
container_insert_step(start, end, None, [])
|
container_insert_step(start, end, None, [111])
|
||||||
|
container_insert_step(start, end, None, [])
|
||||||
|
|
||||||
# delete sequences (growing, shrinking and staying same size)
|
# delete sequences (growing, shrinking and staying same size)
|
||||||
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||||
# single element delete
|
# single element delete
|
||||||
container_delete_step(start, None, None)
|
container_delete_step(start, None, None)
|
||||||
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
for end in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]:
|
||||||
container_delete_step(start, end, None)
|
container_delete_step(start, end, None)
|
||||||
for step in range(-7,7):
|
for step in range(-7, 7):
|
||||||
container_delete_step(start, end, step)
|
container_delete_step(start, end, step)
|
||||||
|
|
||||||
ps = range(6)
|
ps = range(6)
|
||||||
iv = vector_int(ps)
|
iv = vector_int(ps)
|
||||||
il = list_int(ps)
|
il = list_int(ps)
|
||||||
del ps[:]; del iv[:]; del il[:]
|
del ps[:]
|
||||||
|
del iv[:]
|
||||||
|
del il[:]
|
||||||
compare_containers(ps, iv, il)
|
compare_containers(ps, iv, il)
|
||||||
|
|
||||||
for end in range(7):
|
for end in range(7):
|
||||||
for step in range(-7,7):
|
for step in range(-7, 7):
|
||||||
for start in range(7):
|
for start in range(7):
|
||||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666, 777])
|
container_insert_step(
|
||||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555, 666])
|
start, end, step, [111, 222, 333, 444, 555, 666, 777])
|
||||||
container_insert_step(start, end, step, [111, 222, 333, 444, 555])
|
container_insert_step(
|
||||||
container_insert_step(start, end, step, [111, 222, 333, 444])
|
start, end, step, [111, 222, 333, 444, 555, 666])
|
||||||
container_insert_step(start, end, step, [111, 222, 333])
|
container_insert_step(start, end, step, [111, 222, 333, 444, 555])
|
||||||
container_insert_step(start, end, step, [111, 222])
|
container_insert_step(start, end, step, [111, 222, 333, 444])
|
||||||
container_insert_step(start, end, step, [111])
|
container_insert_step(start, end, step, [111, 222, 333])
|
||||||
container_insert_step(start, end, step, [])
|
container_insert_step(start, end, step, [111, 222])
|
||||||
|
container_insert_step(start, end, step, [111])
|
||||||
|
container_insert_step(start, end, step, [])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
x = iv[::0]
|
x = iv[::0]
|
||||||
raise RuntimeError("Zero step not caught")
|
raise RuntimeError("Zero step not caught")
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,29 @@ from li_std_except_as_class import *
|
||||||
# This test is expected to fail with -builtin option.
|
# This test is expected to fail with -builtin option.
|
||||||
# Throwing builtin classes as exceptions not supported
|
# Throwing builtin classes as exceptions not supported
|
||||||
if is_python_builtin():
|
if is_python_builtin():
|
||||||
try: test_domain_error()
|
try:
|
||||||
except RuntimeError: pass
|
test_domain_error()
|
||||||
try: test_domain_error()
|
except RuntimeError:
|
||||||
except RuntimeError: pass
|
pass
|
||||||
try: test_domain_error()
|
try:
|
||||||
except RuntimeError: pass
|
test_domain_error()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
test_domain_error()
|
||||||
|
except RuntimeError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
# std::domain_error hierarchy
|
# std::domain_error hierarchy
|
||||||
try: test_domain_error()
|
try:
|
||||||
except domain_error: pass
|
test_domain_error()
|
||||||
try: test_domain_error()
|
except domain_error:
|
||||||
except logic_error: pass
|
pass
|
||||||
try: test_domain_error()
|
try:
|
||||||
except exception: pass
|
test_domain_error()
|
||||||
|
except logic_error:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
test_domain_error()
|
||||||
|
except exception:
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ import li_std_map_member
|
||||||
a = li_std_map_member.mapita()
|
a = li_std_map_member.mapita()
|
||||||
a[1] = li_std_map_member.TestA()
|
a[1] = li_std_map_member.TestA()
|
||||||
|
|
||||||
if (a[1].i != 1) :
|
if (a[1].i != 1):
|
||||||
raise RuntimeError("a[1] != 1")
|
raise RuntimeError("a[1] != 1")
|
||||||
|
|
||||||
a[1].i = 2
|
a[1].i = 2
|
||||||
if (a[1].i != 2) :
|
if (a[1].i != 2):
|
||||||
raise RuntimeError("a[1] != 2")
|
raise RuntimeError("a[1] != 2")
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ a1 = li_std_map.A(3)
|
||||||
a2 = li_std_map.A(7)
|
a2 = li_std_map.A(7)
|
||||||
|
|
||||||
|
|
||||||
p0 = li_std_map.pairii(1,2)
|
p0 = li_std_map.pairii(1, 2)
|
||||||
p1 = li_std_map.pairA(1,a1.this)
|
p1 = li_std_map.pairA(1, a1.this)
|
||||||
m = {}
|
m = {}
|
||||||
m[1] = a1
|
m[1] = a1
|
||||||
m[2] = a2
|
m[2] = a2
|
||||||
|
|
@ -14,38 +14,33 @@ pp1 = li_std_map.p_identa(p1)
|
||||||
mm = li_std_map.m_identa(m)
|
mm = li_std_map.m_identa(m)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m = li_std_map.mapA()
|
m = li_std_map.mapA()
|
||||||
m[1] = a1
|
m[1] = a1
|
||||||
m[2] = a2
|
m[2] = a2
|
||||||
|
|
||||||
|
|
||||||
pm ={}
|
pm = {}
|
||||||
for k in m:
|
for k in m:
|
||||||
pm[k] = m[k]
|
pm[k] = m[k]
|
||||||
|
|
||||||
for k in m:
|
|
||||||
if pm[k].this != m[k].this:
|
|
||||||
print pm[k], m[k]
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for k in m:
|
||||||
|
if pm[k].this != m[k].this:
|
||||||
|
print pm[k], m[k]
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
m = {}
|
m = {}
|
||||||
m[1] = (1,2)
|
m[1] = (1, 2)
|
||||||
m["foo"] = "hello"
|
m["foo"] = "hello"
|
||||||
|
|
||||||
pm = li_std_map.pymap()
|
pm = li_std_map.pymap()
|
||||||
|
|
||||||
for k in m:
|
for k in m:
|
||||||
pm[k] = m[k]
|
pm[k] = m[k]
|
||||||
|
|
||||||
for k in pm:
|
|
||||||
if (pm[k] != m[k]):
|
|
||||||
raise RuntimeError
|
|
||||||
|
|
||||||
|
for k in pm:
|
||||||
|
if (pm[k] != m[k]):
|
||||||
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
mii = li_std_map.IntIntMap()
|
mii = li_std_map.IntIntMap()
|
||||||
|
|
@ -54,5 +49,4 @@ mii[1] = 1
|
||||||
mii[1] = 2
|
mii[1] = 2
|
||||||
|
|
||||||
if mii[1] != 2:
|
if mii[1] != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,59 +1,58 @@
|
||||||
import li_std_pair_extra
|
import li_std_pair_extra
|
||||||
|
|
||||||
p = (1,2)
|
p = (1, 2)
|
||||||
p1 = li_std_pair_extra.p_inout(p)
|
p1 = li_std_pair_extra.p_inout(p)
|
||||||
p2 = li_std_pair_extra.p_inoutd(p1)
|
p2 = li_std_pair_extra.p_inoutd(p1)
|
||||||
|
|
||||||
d1 = li_std_pair_extra.d_inout(2)
|
d1 = li_std_pair_extra.d_inout(2)
|
||||||
|
|
||||||
i,d2 = li_std_pair_extra.d_inout2(2)
|
i, d2 = li_std_pair_extra.d_inout2(2)
|
||||||
|
|
||||||
i,p = li_std_pair_extra.p_inout2(p)
|
i, p = li_std_pair_extra.p_inout2(p)
|
||||||
p3,p4 = li_std_pair_extra.p_inout3(p1,p1)
|
p3, p4 = li_std_pair_extra.p_inout3(p1, p1)
|
||||||
|
|
||||||
psi = li_std_pair_extra.SIPair("hello",1)
|
psi = li_std_pair_extra.SIPair("hello", 1)
|
||||||
pci = li_std_pair_extra.CIPair(1,1)
|
pci = li_std_pair_extra.CIPair(1, 1)
|
||||||
|
|
||||||
|
|
||||||
#psi.first = "hi"
|
#psi.first = "hi"
|
||||||
|
|
||||||
|
|
||||||
psi = li_std_pair_extra.SIPair("hi",1)
|
psi = li_std_pair_extra.SIPair("hi", 1)
|
||||||
if psi != ("hi",1):
|
if psi != ("hi", 1):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
psii = li_std_pair_extra.SIIPair(psi,1)
|
psii = li_std_pair_extra.SIIPair(psi, 1)
|
||||||
|
|
||||||
a = li_std_pair_extra.A()
|
a = li_std_pair_extra.A()
|
||||||
b = li_std_pair_extra.B()
|
b = li_std_pair_extra.B()
|
||||||
|
|
||||||
pab = li_std_pair_extra.ABPair(a,b);
|
pab = li_std_pair_extra.ABPair(a, b)
|
||||||
|
|
||||||
pab.first = a
|
pab.first = a
|
||||||
pab.first.val = 2
|
pab.first.val = 2
|
||||||
|
|
||||||
if pab.first.val != 2:
|
if pab.first.val != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
pci = li_std_pair_extra.CIntPair(1,0)
|
|
||||||
|
pci = li_std_pair_extra.CIntPair(1, 0)
|
||||||
|
|
||||||
a = li_std_pair_extra.A(5)
|
a = li_std_pair_extra.A(5)
|
||||||
p1 = li_std_pair_extra.pairP1(1,a.this)
|
p1 = li_std_pair_extra.pairP1(1, a.this)
|
||||||
p2 = li_std_pair_extra.pairP2(a,1)
|
p2 = li_std_pair_extra.pairP2(a, 1)
|
||||||
p3 = li_std_pair_extra.pairP3(a,a)
|
p3 = li_std_pair_extra.pairP3(a, a)
|
||||||
|
|
||||||
|
|
||||||
if a.val != li_std_pair_extra.p_identa(p1.this)[1].val:
|
if a.val != li_std_pair_extra.p_identa(p1.this)[1].val:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
p = li_std_pair_extra.IntPair(1,10)
|
p = li_std_pair_extra.IntPair(1, 10)
|
||||||
p.first = 1
|
p.first = 1
|
||||||
|
|
||||||
p = li_std_pair_extra.paircA1(1,a)
|
p = li_std_pair_extra.paircA1(1, a)
|
||||||
p.first
|
p.first
|
||||||
p.second
|
p.second
|
||||||
|
|
||||||
p = li_std_pair_extra.paircA2(1,a)
|
p = li_std_pair_extra.paircA2(1, a)
|
||||||
pp = li_std_pair_extra.pairiiA(1,p)
|
pp = li_std_pair_extra.pairiiA(1, p)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,4 @@ two_tuple = ("two", 2)
|
||||||
two = StringIntPair(two_tuple)
|
two = StringIntPair(two_tuple)
|
||||||
|
|
||||||
if bounce(one) != one_tuple:
|
if bounce(one) != one_tuple:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ if i.next() != "c":
|
||||||
b = s.begin()
|
b = s.begin()
|
||||||
e = s.end()
|
e = s.end()
|
||||||
sum = ""
|
sum = ""
|
||||||
while (b != e):
|
while (b != e):
|
||||||
sum = sum + b.next()
|
sum = sum + b.next()
|
||||||
if sum != "abc":
|
if sum != "abc":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
@ -33,14 +33,13 @@ if sum != "abc":
|
||||||
b = s.rbegin()
|
b = s.rbegin()
|
||||||
e = s.rend()
|
e = s.rend()
|
||||||
sum = ""
|
sum = ""
|
||||||
while (b != e):
|
while (b != e):
|
||||||
sum = sum + b.next()
|
sum = sum + b.next()
|
||||||
|
|
||||||
if sum != "cba":
|
if sum != "cba":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
si = set_int()
|
si = set_int()
|
||||||
|
|
||||||
si.append(1)
|
si.append(1)
|
||||||
|
|
@ -56,8 +55,6 @@ if i.next() != 3:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i = s.begin()
|
i = s.begin()
|
||||||
i.next()
|
i.next()
|
||||||
s.erase(i)
|
s.erase(i)
|
||||||
|
|
@ -65,7 +62,7 @@ s.erase(i)
|
||||||
b = s.begin()
|
b = s.begin()
|
||||||
e = s.end()
|
e = s.end()
|
||||||
sum = ""
|
sum = ""
|
||||||
while (b != e):
|
while (b != e):
|
||||||
sum = sum + b.next()
|
sum = sum + b.next()
|
||||||
if sum != "ac":
|
if sum != "ac":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
@ -75,22 +72,21 @@ b = s.begin()
|
||||||
e = s.end()
|
e = s.end()
|
||||||
if e - b != 2:
|
if e - b != 2:
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
m = b + 1
|
m = b + 1
|
||||||
if m.value() != "c":
|
if m.value() != "c":
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
s = pyset()
|
s = pyset()
|
||||||
s.insert((1,2))
|
s.insert((1, 2))
|
||||||
s.insert(1)
|
s.insert(1)
|
||||||
s.insert("hello")
|
s.insert("hello")
|
||||||
|
|
||||||
|
|
||||||
sum = ()
|
sum = ()
|
||||||
for i in s:
|
for i in s:
|
||||||
sum = sum + (i,)
|
sum = sum + (i,)
|
||||||
|
|
||||||
if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) :
|
if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)):
|
||||||
raise RuntimeError
|
raise RuntimeError
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue