Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,202 @@
#######################################################################
# Makefile for python test-suite
#######################################################################
ifeq (,$(PY3))
PYBIN = @PYTHON@
else
PYBIN = @PYTHON3@
endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
PY3SCRIPTSUFFIX = _runme3.py
PY2TO3 = 2to3 -x import
ifeq (,$(PY3))
SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
else
SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
endif
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
argcargvtest \
callback \
complextest \
director_stl \
director_wstring \
file_test \
iadd \
implicittest \
inout \
inplaceadd \
input \
li_cstring \
li_cwstring \
li_factory \
li_implicit \
li_std_containers_int \
li_std_map_member \
li_std_multimap \
li_std_pair_extra \
li_std_set \
li_std_stream \
li_std_string_extra \
li_std_vectora \
li_std_vector_extra \
li_std_wstream \
li_std_wstring \
primitive_types \
python_abstractbase \
python_append \
python_builtin \
python_destructor_exception \
python_director \
python_docstring \
python_extranative \
python_moduleimport \
python_nondynamic \
python_overload_simple_cast \
python_pickle \
python_pythoncode \
python_richcompare \
python_strict_unicode \
simutry \
std_containers \
swigobject \
template_matrix
# li_std_carray
# director_profile
# python_pybuf
C_TEST_CASES += \
file_test \
li_cstring \
li_cwstring \
python_nondynamic \
python_varargs_typemap
#
# This test only works with modern C compilers
#
#C_TEST_CASES += \
# complextest
include $(srcdir)/../common.mk
# Overridden variables here
SCRIPTDIR = .
LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_cpp)
$(check_pep8)
$(run_testcase)
%.ctest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_c)
$(check_pep8)
$(run_testcase)
%.multicpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
$(check_pep8_multi_cpp)
$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
py_runme = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifneq (,$(PEP8))
check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \
done
endif
run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(py_runme)
run_testcase = \
if [ -f $(SCRIPTDIR)/$(py_runme) ]; then \
$(run_python);\
fi
# No copying/conversion needed for in-source-tree Python 2 scripts
ifeq ($(SCRIPTDIR)|$(SCRIPTSUFFIX),$(srcdir)|$(PY2SCRIPTSUFFIX))
convert_testcase =
else
convert_testcase = \
if [ -f $(srcdir)/$(py2_runme) ]; then \
$(MAKE) $(SCRIPTDIR)/$(py_runme); \
fi
$(SCRIPTDIR)/$(SCRIPTPREFIX)%$(SCRIPTSUFFIX): $(srcdir)/$(SCRIPTPREFIX)%$(PY2SCRIPTSUFFIX)
test x$< = x$@ || cp $< $@ || exit 1
test x$(PY3) = x || $(PY2TO3) -w $@ >/dev/null 2>&1 || exit 1
endif
# Clean: remove the generated .py file
# We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
%.clean:
@rm -f $*.py
@if test -f $(srcdir)/$(py2_runme); then rm -f $(SCRIPTDIR)/$(py3_runme) $(SCRIPTDIR)/$(py3_runme).bak; fi
@if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' python_clean
rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
rm -f clientdata_prop_a.py clientdata_prop_b.py import_stl_a.py import_stl_b.py
rm -f imports_a.py imports_b.py mod_a.py mod_b.py multi_import_a.py
rm -f multi_import_b.py packageoption_a.py packageoption_b.py packageoption_c.py
cvsignore:
@echo '*wrap* *.pyc *.so *.dll *.exp *.lib'
@echo Makefile
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.py; done
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.py CVS/Entries ; then echo $${i}_runme.py; fi; done
@echo clientdata_prop_a.py
@echo clientdata_prop_b.py
@echo imports_a.py
@echo imports_b.py
@echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:
perl hugemod.pl $(hugemod_runme)
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
sh -c "time $(PYTHON) $(hugemod_runme)"
sh -c "time $(PYTHON) $(hugemod_runme)"

View File

@@ -0,0 +1,8 @@
See ../README for common README file.
Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run.
If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test.
You can run make with PY3=y to run test case with Python 3.x, eg.
$ make voidtest.cpptest PY3=y

View File

@@ -0,0 +1,5 @@
import abstract_access
d = abstract_access.D()
if d.do_x() != 1:
raise RuntimeError

View File

@@ -0,0 +1,3 @@
from abstract_typedef2 import *
a = A_UF()

View File

@@ -0,0 +1,8 @@
from abstract_typedef import *
e = Engine()
a = A()
if a.write(e) != 1:
raise RuntimeError

View File

@@ -0,0 +1,6 @@
from abstract_virtual import *
d = D()
e = E()

View File

@@ -0,0 +1,26 @@
from argcargvtest import *
largs = ['hi', 'hola', 'hello']
if mainc(largs) != 3:
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
print(mainv(targs, 1))
raise RuntimeError("bad main typemap")
targs = ('hi', 'hola')
if mainv(targs, 1) != 'hola':
raise RuntimeError("bad main typemap")
try:
error = 0
mainv('hello', 1)
error = 1
except TypeError:
pass
if error:
raise RuntimeError("bad main typemap")
initializeApp(largs)

View File

@@ -0,0 +1,18 @@
from array_member import *
f = Foo()
f.data = cvar.global_data
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"
for i in range(0, 8):
set_value(f.data, i, -i)
cvar.global_data = f.data
for i in range(0, 8):
if get_value(f.data, i) != get_value(cvar.global_data, i):
raise RuntimeError, "Bad array assignment"

View File

@@ -0,0 +1,20 @@
import arrays_global
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i
from arrays_global import *
BeginString_FIX44a
cvar.BeginString_FIX44b
BeginString_FIX44c
cvar.BeginString_FIX44d
cvar.BeginString_FIX44d
cvar.BeginString_FIX44b = "12"'\0'"45"
cvar.BeginString_FIX44b
cvar.BeginString_FIX44d
cvar.BeginString_FIX44e
BeginString_FIX44f
test_a("hello", "hi", "chello", "chi")
test_b("1234567", "hi")

View File

@@ -0,0 +1,367 @@
from autodoc import *
import sys
def check(got, expected, expected_builtin=None, skip=False):
if not skip:
expect = expected
if is_python_builtin() and expected_builtin != None:
expect = expected_builtin
if expect != got:
raise RuntimeError(
"\n" + "Expected: [" + str(expect) + "]\n" + "Got : [" + str(got) + "]")
def is_new_style_class(cls):
return hasattr(cls, "__class__")
def is_fastproxy(module):
return "new_instancemethod" in module
if not is_new_style_class(A):
# Missing static methods make this hard to test... skip if -classic is
# used!
sys.exit(0)
if is_fastproxy(dir()):
# Detect when -fastproxy is specified and skip test as it changes the function names making it
# hard to test... skip until the number of options are reduced in SWIG-3.1 and autodoc is improved
sys.exit(0)
# 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.funk.__doc__, "just a string.")
check(A.func0.__doc__,
"func0(self, arg2, hello) -> int",
"func0(arg2, hello) -> int")
check(A.func1.__doc__,
"func1(A self, short arg2, Tuple hello) -> int",
"func1(short arg2, Tuple hello) -> int")
check(A.func2.__doc__,
"\n"
" func2(self, arg2, hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2(arg2, hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
check(A.func3.__doc__,
"\n"
" func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3(short arg2, Tuple hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
check(A.func0default.__doc__,
"\n"
" func0default(self, e, arg3, hello, f=2) -> int\n"
" func0default(self, e, arg3, hello) -> int\n"
" ",
"\n"
"func0default(e, arg3, hello, f=2) -> int\n"
"func0default(e, arg3, hello) -> int\n"
""
)
check(A.func1default.__doc__,
"\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"
" ",
"\n"
"func1default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A e, short arg3, Tuple hello) -> int\n"
""
)
check(A.func2default.__doc__,
"\n"
" func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2default(self, e, arg3, hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2default(e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
"f: double\n"
"\n"
"func2default(e, arg3, hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
check(A.func3default.__doc__,
"\n"
" func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3default(A self, A e, short arg3, Tuple hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3default(A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
"f: double\n"
"\n"
"func3default(A e, short arg3, Tuple hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
check(A.func0static.__doc__,
"\n"
" func0static(e, arg2, hello, f=2) -> int\n"
" func0static(e, arg2, hello) -> int\n"
" ",
"\n"
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int\n"
""
)
check(A.func1static.__doc__,
"\n"
" func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
" func1static(A e, short arg2, Tuple hello) -> int\n"
" ",
"\n"
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int\n"
""
)
check(A.func2static.__doc__,
"\n"
" func2static(e, arg2, hello, f=2) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func2static(e, arg2, hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double\n"
"\n"
"func2static(e, arg2, hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
check(A.func3static.__doc__,
"\n"
" func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\n"
"\n"
" func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
" Parameters\n"
" ----------\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
"\n"
" ",
"\n"
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"f: double\n"
"\n"
"func3static(A e, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]\n"
"\n"
""
)
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
check(A.variable_a.__doc__,
"A_variable_a_get(self) -> int",
"A.variable_a"
)
check(A.variable_b.__doc__,
"A_variable_b_get(A self) -> int",
"A.variable_b"
)
check(A.variable_c.__doc__,
"\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *\n"
"\n",
"A.variable_c"
)
check(A.variable_d.__doc__,
"\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters\n"
"----------\n"
"self: A *\n"
"\n",
"A.variable_d"
)
check(B.__doc__,
"Proxy of C++ B class.",
"::B"
)
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(E.__init__.__doc__,
"\n"
" __init__(self, a, b, h) -> E\n"
"\n"
" Parameters\n"
" ----------\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" ", None, skip
)
check(F.__init__.__doc__,
"\n"
" __init__(F self, int a, int b, Hola h) -> F\n"
"\n"
" Parameters\n"
" ----------\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n"
"\n"
" ", None, skip
)
check(B.funk.__doc__,
"funk(B self, 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(funkdefaults.__doc__,
"\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"
" ",
"\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"
""
)
check(func_input.__doc__, "func_input(int * INPUT) -> int")
check(func_output.__doc__, "func_output() -> int")
check(func_inout.__doc__, "func_inout(int * INOUT) -> int")
check(func_cb.__doc__, "func_cb(int c, int d) -> int")
check(banana.__doc__, "banana(S a, S b, int c, Integer d)")

View File

@@ -0,0 +1,31 @@
import _callback
from callback import *
if foo(2) != 2:
raise RuntimeError
if A_bar(2) != 4:
raise RuntimeError
if foobar(3, _callback.foo) != foo(3):
raise RuntimeError
if foobar(3, foo) != foo(3):
raise RuntimeError
if foobar(3, A_bar) != A_bar(3):
raise RuntimeError
if foobar(3, foof) != foof(3):
raise RuntimeError
if foobar_i(3, foo_i) != foo_i(3):
raise RuntimeError
if foobar_d(3.5, foo_d) != foo_d(3.5):
raise RuntimeError
a = A()
if foobarm(3, a, A.foom_cb_ptr) != a.foom(3):
raise RuntimeError

View File

@@ -0,0 +1,42 @@
from char_binary import *
t = Test()
if t.strlen('hile') != 4:
print t.strlen('hile')
raise RuntimeError, "bad multi-arg typemap"
if t.ustrlen('hile') != 4:
print t.ustrlen('hile')
raise RuntimeError, "bad multi-arg typemap"
if t.strlen('hil\0') != 4:
raise RuntimeError, "bad multi-arg typemap"
if t.ustrlen('hil\0') != 4:
raise RuntimeError, "bad multi-arg typemap"
#
# creating a raw char*
#
pc = new_pchar(5)
pchar_setitem(pc, 0, 'h')
pchar_setitem(pc, 1, 'o')
pchar_setitem(pc, 2, 'l')
pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
if t.strlen(pc) != 4:
raise RuntimeError, "bad multi-arg typemap"
if t.ustrlen(pc) != 4:
raise RuntimeError, "bad multi-arg typemap"
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
raise RuntimeError, "bad pointer case"
cvar.var_namet = pc
# if cvar.var_namet != "hola\0":
if cvar.var_namet != "hola":
raise RuntimeError, "bad pointer case"
delete_pchar(pc)

View File

@@ -0,0 +1,6 @@
import class_ignore
a = class_ignore.Bar()
if class_ignore.do_blah(a) != "Bar::blah":
raise RuntimeError

View File

@@ -0,0 +1,6 @@
import class_scope_weird
f = class_scope_weird.Foo()
g = class_scope_weird.Foo(3)
if f.bar(3) != 3:
raise RuntimeError

View File

@@ -0,0 +1,22 @@
from compactdefaultargs import *
defaults1 = Defaults1(1000)
defaults1 = Defaults1()
if defaults1.ret(10.0) != 10.0:
raise RuntimeError
if defaults1.ret() != -1.0:
raise RuntimeError
defaults2 = Defaults2(1000)
defaults2 = Defaults2()
if defaults2.ret(10.0) != 10.0:
raise RuntimeError
if defaults2.ret() != -1.0:
raise RuntimeError
if defaults2.nodefault(-2) != -2:
raise RuntimeError

View File

@@ -0,0 +1,17 @@
import complextest
a = complex(-1, 2)
if complextest.Conj(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
if complextest.Conjf(a) != a.conjugate():
raise RuntimeError, "bad complex mapping"
v = (complex(1, 2), complex(2, 3), complex(4, 3), 1)
try:
complextest.Copy_h(v)
except:
pass

View File

@@ -0,0 +1,28 @@
import constant_directive
if not isinstance(constant_directive.TYPE1_CONSTANT1, constant_directive.Type1):
raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(
type(constant_directive.TYPE1_CONSTANT1)))
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:
raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" %
constant_directive.TYPE1_CONSTANT1.val)
if constant_directive.TYPE1_CONSTANT2.val != 2:
raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" %
constant_directive.TYPE1_CONSTANT2.val)
if constant_directive.TYPE1_CONSTANT3.val != 3:
raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" %
constant_directive.TYPE1_CONSTANT3.val)
if constant_directive.TYPE1CONST_CONSTANT1.val != 1:
raise RuntimeError("constant_directive.TYPE1CONST_CONSTANT1.val is %r (should be 1)" %
constant_directive.TYPE1CONST_CONSTANT1.val)
if constant_directive.TYPE1CPTR_CONSTANT1.val != 1:
raise RuntimeError("constant_directive.TYPE1CPTR_CONSTANT1.val is %r (should be 1)" %
constant_directive.TYPE1CPTR_CONSTANT1.val)

View File

@@ -0,0 +1,36 @@
import constover
import sys
error = 0
p = constover.test("test")
if p != "test":
print "test failed!"
error = 1
p = constover.test_pconst("test")
if p != "test_pconst":
print "test_pconst failed!"
error = 1
f = constover.Foo()
p = f.test("test")
if p != "test":
print "member-test failed!"
error = 1
p = f.test_pconst("test")
if p != "test_pconst":
print "member-test_pconst failed!"
error = 1
p = f.test_constm("test")
if p != "test_constmethod":
print "member-test_constm failed!"
error = 1
p = f.test_pconstm("test")
if p != "test_pconstmethod":
print "member-test_pconstm failed!"
error = 1
sys.exit(error)

View File

@@ -0,0 +1,37 @@
from constructor_copy import *
f1 = Foo1(3)
f11 = Foo1(f1)
if f1.x != f11.x:
raise RuntimeError
f8 = Foo8()
try:
f81 = Foo8(f8)
good = 0
except:
good = 1
if not good:
raise RuntimeError
bi = Bari(5)
bc = Bari(bi)
if (bi.x != bc.x):
raise RuntimeError
bd = Bard(5)
try:
bc = Bard(bd)
good = 0
except:
good = 1
if not good:
raise RuntimeError

View File

@@ -0,0 +1,3 @@
from constructor_rename import *
x = RenamedConstructor()

View File

@@ -0,0 +1,142 @@
import contract
contract.test_preassert(1, 2)
try:
contract.test_preassert(-1)
print "Failed! Preassertions are broken"
except:
pass
contract.test_postassert(3)
try:
contract.test_postassert(-3)
print "Failed! Postassertions are broken"
except:
pass
contract.test_prepost(2, 3)
contract.test_prepost(5, -4)
try:
contract.test_prepost(-3, 4)
print "Failed! Preassertions are broken"
except:
pass
try:
contract.test_prepost(4, -10)
print "Failed! Postassertions are broken"
except:
pass
f = contract.Foo()
f.test_preassert(4, 5)
try:
f.test_preassert(-2, 3)
print "Failed! Method preassertion."
except:
pass
f.test_postassert(4)
try:
f.test_postassert(-4)
print "Failed! Method postassertion"
except:
pass
f.test_prepost(3, 4)
f.test_prepost(4, -3)
try:
f.test_prepost(-4, 2)
print "Failed! Method preassertion."
except:
pass
try:
f.test_prepost(4, -10)
print "Failed! Method postassertion."
except:
pass
contract.Foo_stest_prepost(4, 0)
try:
contract.Foo_stest_prepost(-4, 2)
print "Failed! Static method preassertion"
except:
pass
try:
contract.Foo_stest_prepost(4, -10)
print "Failed! Static method posteassertion"
except:
pass
b = contract.Bar()
try:
b.test_prepost(2, -4)
print "Failed! Inherited preassertion."
except:
pass
d = contract.D()
try:
d.foo(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.foo(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.foo(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.foo(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.foo(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.bar(-1, 1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.bar(1, -1, 1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.bar(1, 1, -1, 1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.bar(1, 1, 1, -1, 1)
print "Failed! Inherited preassertion (D)."
except:
pass
try:
d.bar(1, 1, 1, 1, -1)
print "Failed! Inherited preassertion (D)."
except:
pass
# Namespace
my = contract.myClass(1)
try:
my = contract.myClass(0)
print "Failed! constructor preassertion"
except:
pass

View File

@@ -0,0 +1,14 @@
import cpp11_alternate_function_syntax
a = cpp11_alternate_function_syntax.SomeStruct()
res = a.addNormal(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addNormal(4,5) returns ",
res, " should be 9.")
res = a.addAlternate(4, 5)
if res != 9:
raise RuntimeError, ("SomeStruct::addAlternate(4,5) returns ",
res, " should be 9.")

View File

@@ -0,0 +1,18 @@
import cpp11_decltype
a = cpp11_decltype.A()
a.i = 5
if a.i != 5:
raise RuntimeError, "Assignment to a.i failed."
a.j = 10
if a.j != 10:
raise RuntimeError, "Assignment to a.j failed."
b = a.foo(5)
if b != 10:
raise RuntimeError, "foo(5) should return 10."
b = a.foo(6)
if b != 0:
raise RuntimeError, "foo(6) should return 0."

View File

@@ -0,0 +1,28 @@
import cpp11_function_objects
import sys
class Test1(cpp11_function_objects.Test):
def __init__(self):
cpp11_function_objects.Test.__init__(self)
def __call__(self, a, b):
self.value = a * b
t = cpp11_function_objects.Test()
if t.value != 0:
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
if t.value != 3:
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 3, but is " + str(t.value))
t2 = Test1()
a = cpp11_function_objects.testit1(t2, 4, 3)
if a != 12:
raise RuntimeError(
"Runtime cpp11_function_objects failed. t.value not changed - should be 12, but is " + str(a))

View File

@@ -0,0 +1,3 @@
import cpp11_initializer_list_extend
c = cpp11_initializer_list_extend.Container([10, 20, 30, 40])

View File

@@ -0,0 +1,4 @@
import cpp11_initializer_list
a = cpp11_initializer_list.A()
a = cpp11_initializer_list.A(11.1)

View File

@@ -0,0 +1,163 @@
from cpp11_li_std_array import *
import sys
def failed(a, b, msg):
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
def compare_sequences(a, b):
if len(a) != len(b):
failed(a, b, "different sizes")
for i in range(len(a)):
if a[i] != b[i]:
failed(a, b, "elements are different")
def compare_containers(pythonlist, swigarray):
compare_sequences(pythonlist, swigarray)
def steps_exception(swigarray, i, j, step):
try:
if i == None and j == None:
a = swigarray[::step]
elif i == None:
a = swigarray[:j:step]
elif j == None:
a = swigarray[i::step]
else:
a = swigarray[i:j:step]
raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed steps exception for " + str(list(swigarray))
except ValueError, e:
# print("exception: {}".format(e))
pass
def del_exception(swigarray, i, j, step):
try:
if i == None and j == None:
del swigarray[::step]
elif j == None and step == None:
del swigarray[i]
elif i == None:
del swigarray[:j:step]
elif j == None:
del swigarray[i::step]
else:
del swigarray[i:j:step]
raise RuntimeError, "swigarray[" + str(i) + ":" + str(j) + ":" + str(step) + "] missed del exception for " + str(list(swigarray))
except ValueError, e:
# print("exception: {}".format(e))
pass
def setslice_exception(swigarray, newval):
try:
swigarray[::] = newval
raise RuntimeError, "swigarray[::] = " + str(newval) + " missed set exception for swigarray:" + str(list(swigarray))
except TypeError, e:
# print("exception: {}".format(e))
pass
# Check std::array has similar behaviour to a Python list
# except it is not resizable
ps = [0, 1, 2, 3, 4, 5]
ai = ArrayInt6(ps)
compare_containers(ps, ai)
# slices
compare_containers(ps[0:6], ai[0:6])
compare_containers(ps[0:10], ai[0:10])
compare_containers(ps[-10:6], ai[-10:6])
compare_containers(ps[-10:10], ai[-10:10])
compare_containers(ps[0:6:1], ai[0:6:1])
compare_containers(ps[::], ai[::])
compare_containers(ps[::1], ai[::1])
compare_containers([x for x in ps], [x for x in ai])
# Reverse
compare_containers(ps[::-1], ai[::-1])
compare_containers(ps[5::-1], ai[5::-1])
compare_containers(ps[10::-1], ai[10::-1])
# Steps other than +1 and -1 not supported
steps_exception(ai, 0, 6, 3)
steps_exception(ai, None, None, 0)
steps_exception(ai, None, None, 2)
steps_exception(ai, None, None, -2)
steps_exception(ai, 1, 3, 1)
steps_exception(ai, 3, 1, -1)
# Modify content
for i in range(len(ps)):
ps[i] = (ps[i] + 1) * 10
ai[i] = (ai[i] + 1) * 10
compare_containers(ps, ai)
# Delete
del_exception(ai, 0, 6, 3)
del_exception(ai, None, None, 0)
del_exception(ai, None, None, 2)
del_exception(ai, None, None, -2)
del_exception(ai, 1, 3, 1)
del_exception(ai, 3, 1, -1)
del_exception(ai, 0, None, None)
del_exception(ai, 5, None, None)
# Empty
ai = ArrayInt6()
compare_containers([0, 0, 0, 0, 0, 0], ai)
# Set slice
newvals = [10, 20, 30, 40, 50, 60]
ai[::] = newvals
compare_containers(ai, newvals)
newvals = [100, 200, 300, 400, 500, 600]
ai[0:6:1] = newvals
compare_containers(ai, newvals)
newvals = [1000, 2000, 3000, 4000, 5000, 6000]
ai[::-1] = newvals
compare_containers(ai, newvals[::-1])
newvals = [10000, 20000, 30000, 40000, 50000, 60000]
ai[-10:100:1] = newvals
compare_containers(ai, newvals[-10:100:1])
setslice_exception(ai, [1, 2, 3, 4, 5, 6, 7])
setslice_exception(ai, [1, 2, 3, 4, 5])
setslice_exception(ai, [1, 2, 3, 4])
setslice_exception(ai, [1, 2, 3])
setslice_exception(ai, [1, 2])
setslice_exception(ai, [1])
setslice_exception(ai, [])
# Check return
compare_containers(arrayOutVal(), [-2, -1, 0, 0, 1, 2])
compare_containers(arrayOutConstRef(), [-2, -1, 0, 0, 1, 2])
compare_containers(arrayOutRef(), [-2, -1, 0, 0, 1, 2])
compare_containers(arrayOutPtr(), [-2, -1, 0, 0, 1, 2])
# Check passing arguments
ai = arrayInVal([9, 8, 7, 6, 5, 4])
compare_containers(ai, [90, 80, 70, 60, 50, 40])
ai = arrayInConstRef([9, 8, 7, 6, 5, 4])
compare_containers(ai, [90, 80, 70, 60, 50, 40])
ai = ArrayInt6([9, 8, 7, 6, 5, 4])
arrayInRef(ai)
compare_containers(ai, [90, 80, 70, 60, 50, 40])
ai = ArrayInt6([9, 8, 7, 6, 5, 4])
arrayInPtr(ai)
compare_containers(ai, [90, 80, 70, 60, 50, 40])
# fill
ai.fill(111)
compare_containers(ai, [111, 111, 111, 111, 111, 111])

View File

@@ -0,0 +1,17 @@
import cpp11_null_pointer_constant
a = cpp11_null_pointer_constant.A()
if a._myA != None:
raise RuntimeError, (
"cpp11_null_pointer_constant: _myA should be None, but is ", a._myA)
b = cpp11_null_pointer_constant.A()
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)
a._myA = cpp11_null_pointer_constant.A()
if a._myA == None:
raise RuntimeError, (
"cpp11_null_pointer_constant: _myA should be object, but is None")

View File

@@ -0,0 +1,48 @@
from cpp11_raw_string_literals import *
if cvar.L != 100:
raise RuntimeError
if cvar.u8 != 100:
raise RuntimeError
if cvar.u != 100:
raise RuntimeError
if UStruct.U != 100:
raise RuntimeError
if cvar.R != 100:
raise RuntimeError
if cvar.LR != 100:
raise RuntimeError
if cvar.u8R != 100:
raise RuntimeError
if cvar.uR != 100:
raise RuntimeError
if URStruct.UR != 100:
raise RuntimeError
if cvar.aa != "Wide string":
raise RuntimeError
if cvar.bb != "UTF-8 string":
raise RuntimeError, cvar.wide
if cvar.xx != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.xx
if cvar.ee != ")I'm an \"ascii\" \\ string.":
raise RuntimeError, cvar.ee
if cvar.ff != "I'm a \"raw wide\" \\ string.":
raise RuntimeError, cvar.ff
if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
raise RuntimeError, cvar.gg

View File

@@ -0,0 +1,11 @@
import cpp11_result_of
result = cpp11_result_of.test_result(cpp11_result_of.SQUARE, 3.0)
if result != 9.0:
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)
if result != 9.0:
raise RuntimeError, "test_result_alternative1(square, 3.0) is not 9.0. Got: " + str(
result)

View File

@@ -0,0 +1,27 @@
import cpp11_rvalue_reference
a = cpp11_rvalue_reference.A()
a.setAcopy(5)
if a.getAcopy() != 5:
raise RunTimeError, ("int A::getAcopy() value is ",
a.getAcopy(), " should be 5")
ptr = a.getAptr()
a.setAptr(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAptr(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
a.setAref(ptr)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAref(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")
rvalueref = a.getAmove()
a.setAmove(rvalueref)
if a.getAcopy() != 5:
raise RunTimeError, ("after A::setAmove(): int A::getAcopy() value is ", a.getAcopy(
), " should be 5")

View File

@@ -0,0 +1,165 @@
from cpp11_strongly_typed_enumerations import *
def enumCheck(actual, expected):
if actual != expected:
raise RuntimeError(
"Enum value mismatch. Expected " + str(expected) + " Actual: " + str(actual))
return expected + 1
val = 0
val = enumCheck(Enum1_Val1, val)
val = enumCheck(Enum1_Val2, val)
val = enumCheck(Enum1_Val3, 13)
val = enumCheck(Enum1_Val4, val)
val = enumCheck(Enum1_Val5a, 13)
val = enumCheck(Enum1_Val6a, val)
val = 0
val = enumCheck(Enum2_Val1, val)
val = enumCheck(Enum2_Val2, val)
val = enumCheck(Enum2_Val3, 23)
val = enumCheck(Enum2_Val4, val)
val = enumCheck(Enum2_Val5b, 23)
val = enumCheck(Enum2_Val6b, val)
val = 0
val = enumCheck(Val1, val)
val = enumCheck(Val2, val)
val = enumCheck(Val3, 43)
val = enumCheck(Val4, val)
val = 0
val = enumCheck(Enum5_Val1, val)
val = enumCheck(Enum5_Val2, val)
val = enumCheck(Enum5_Val3, 53)
val = enumCheck(Enum5_Val4, val)
val = 0
val = enumCheck(Enum6_Val1, val)
val = enumCheck(Enum6_Val2, val)
val = enumCheck(Enum6_Val3, 63)
val = enumCheck(Enum6_Val4, val)
val = 0
val = enumCheck(Enum7td_Val1, val)
val = enumCheck(Enum7td_Val2, val)
val = enumCheck(Enum7td_Val3, 73)
val = enumCheck(Enum7td_Val4, val)
val = 0
val = enumCheck(Enum8_Val1, val)
val = enumCheck(Enum8_Val2, val)
val = enumCheck(Enum8_Val3, 83)
val = enumCheck(Enum8_Val4, val)
val = 0
val = enumCheck(Enum10_Val1, val)
val = enumCheck(Enum10_Val2, val)
val = enumCheck(Enum10_Val3, 103)
val = enumCheck(Enum10_Val4, val)
val = 0
val = enumCheck(Class1.Enum12_Val1, 1121)
val = enumCheck(Class1.Enum12_Val2, 1122)
val = enumCheck(Class1.Enum12_Val3, val)
val = enumCheck(Class1.Enum12_Val4, val)
val = enumCheck(Class1.Enum12_Val5c, 1121)
val = enumCheck(Class1.Enum12_Val6c, val)
val = 0
val = enumCheck(Class1.Val1, 1131)
val = enumCheck(Class1.Val2, 1132)
val = enumCheck(Class1.Val3, val)
val = enumCheck(Class1.Val4, val)
val = enumCheck(Class1.Val5d, 1131)
val = enumCheck(Class1.Val6d, val)
val = 0
val = enumCheck(Class1.Enum14_Val1, 1141)
val = enumCheck(Class1.Enum14_Val2, 1142)
val = enumCheck(Class1.Enum14_Val3, val)
val = enumCheck(Class1.Enum14_Val4, val)
val = enumCheck(Class1.Enum14_Val5e, 1141)
val = enumCheck(Class1.Enum14_Val6e, val)
# Requires nested class support to work
#val = 0
#val = enumCheck(Class1.Struct1.Enum12_Val1, 3121)
#val = enumCheck(Class1.Struct1.Enum12_Val2, 3122)
#val = enumCheck(Class1.Struct1.Enum12_Val3, val)
#val = enumCheck(Class1.Struct1.Enum12_Val4, val)
#val = enumCheck(Class1.Struct1.Enum12_Val5f, 3121)
#val = enumCheck(Class1.Struct1.Enum12_Val6f, val)
#
#val = 0
#val = enumCheck(Class1.Struct1.Val1, 3131)
#val = enumCheck(Class1.Struct1.Val2, 3132)
#val = enumCheck(Class1.Struct1.Val3, val)
#val = enumCheck(Class1.Struct1.Val4, val)
#
#val = 0
#val = enumCheck(Class1.Struct1.Enum14_Val1, 3141)
#val = enumCheck(Class1.Struct1.Enum14_Val2, 3142)
#val = enumCheck(Class1.Struct1.Enum14_Val3, val)
#val = enumCheck(Class1.Struct1.Enum14_Val4, val)
#val = enumCheck(Class1.Struct1.Enum14_Val5g, 3141)
#val = enumCheck(Class1.Struct1.Enum14_Val6g, val)
val = 0
val = enumCheck(Class2.Enum12_Val1, 2121)
val = enumCheck(Class2.Enum12_Val2, 2122)
val = enumCheck(Class2.Enum12_Val3, val)
val = enumCheck(Class2.Enum12_Val4, val)
val = enumCheck(Class2.Enum12_Val5h, 2121)
val = enumCheck(Class2.Enum12_Val6h, val)
val = 0
val = enumCheck(Class2.Val1, 2131)
val = enumCheck(Class2.Val2, 2132)
val = enumCheck(Class2.Val3, val)
val = enumCheck(Class2.Val4, val)
val = enumCheck(Class2.Val5i, 2131)
val = enumCheck(Class2.Val6i, val)
val = 0
val = enumCheck(Class2.Enum14_Val1, 2141)
val = enumCheck(Class2.Enum14_Val2, 2142)
val = enumCheck(Class2.Enum14_Val3, val)
val = enumCheck(Class2.Enum14_Val4, val)
val = enumCheck(Class2.Enum14_Val5j, 2141)
val = enumCheck(Class2.Enum14_Val6j, val)
# Requires nested class support to work
#val = 0
#val = enumCheck(Class2.Struct1.Enum12_Val1, 4121)
#val = enumCheck(Class2.Struct1.Enum12_Val2, 4122)
#val = enumCheck(Class2.Struct1.Enum12_Val3, val)
#val = enumCheck(Class2.Struct1.Enum12_Val4, val)
#val = enumCheck(Class2.Struct1.Enum12_Val5k, 4121)
#val = enumCheck(Class2.Struct1.Enum12_Val6k, val)
#
#val = 0
#val = enumCheck(Class2.Struct1.Val1, 4131)
#val = enumCheck(Class2.Struct1.Val2, 4132)
#val = enumCheck(Class2.Struct1.Val3, val)
#val = enumCheck(Class2.Struct1.Val4, val)
#val = enumCheck(Class2.Struct1.Val5l, 4131)
#val = enumCheck(Class2.Struct1.Val6l, val)
#
#val = 0
#val = enumCheck(Class2.Struct1.Enum14_Val1, 4141)
#val = enumCheck(Class2.Struct1.Enum14_Val2, 4142)
#val = enumCheck(Class2.Struct1.Enum14_Val3, val)
#val = enumCheck(Class2.Struct1.Enum14_Val4, val)
#val = enumCheck(Class2.Struct1.Enum14_Val5m, 4141)
#val = enumCheck(Class2.Struct1.Enum14_Val6m, val)
class1 = Class1()
enumCheck(class1.class1Test1(Enum1_Val5a), 13)
enumCheck(class1.class1Test2(Class1.Enum12_Val5c), 1121)
#enumCheck(class1.class1Test3(Class1.Struct1.Enum12_Val5f), 3121)
enumCheck(globalTest1(Enum1_Val5a), 13)
enumCheck(globalTest2(Class1.Enum12_Val5c), 1121)
#enumCheck(globalTest3(Class1.Struct1.Enum12_Val5f), 3121)

View File

@@ -0,0 +1,43 @@
from cpp11_template_typedefs import *
t = create_TypedefName()
if type(t).__name__ != "SomeTypeInt5":
raise RuntimeError("type(t) is '%s' and should be 'SomeTypeInt5'" % type(t).__name__)
if t.a != "hello":
raise RuntimeError("t.a should be 'hello'")
if t.b != 10:
raise RuntimeError("t.b should be 10")
if t.get_n() != 5:
raise RuntimeError("t.get_n() should be 5")
t_bool = create_TypedefNameBool()
if type(t_bool).__name__ != "SomeTypeBool5":
raise RuntimeError("type(t_bool) is '%s' and should be 'SomeTypeBool5'" % type(t_bool).__name__)
if t_bool.a != "hello":
raise RuntimeError("t_bool.a should be 'hello'")
if t_bool.b != True:
raise RuntimeError("t_bool.b should be True")
if t_bool.get_n() != 15:
raise RuntimeError("t_bool.get_n() should be 15")
if get_SomeType_b(t) != 10:
raise RuntimeError("get_SomeType_b(t) should be 10")
if get_SomeType_b2(t) != 10:
raise RuntimeError("get_SomeType_b2(t) should be 10")
t2 = SomeTypeInt4()
t2.b = 0
t3 = identity(t2)
t3.b = 5
if t2.b != 5:
raise RuntimeError("t2.b should be 5")
if get_bucket_allocator1() != 1:
raise RuntimeError("bucket_allocator1 should be 1")
# SWIG doesn't handle ::MyClass as a template argument. Skip this test.
#if get_bucket_allocator2() != 2:
# raise RuntimeError("bucket_allocator2 should be 2")

View File

@@ -0,0 +1,37 @@
from cpp11_thread_local import *
t = ThreadLocals()
if t.stval != 11:
raise RuntimeError
if t.tsval != 22:
raise RuntimeError
if t.tscval99 != 99:
raise RuntimeError
cvar.etval = -11
if cvar.etval != -11:
raise RuntimeError
cvar.stval = -22
if cvar.stval != -22:
raise RuntimeError
cvar.tsval = -33
if cvar.tsval != -33:
raise RuntimeError
cvar.etval = -44
if cvar.etval != -44:
raise RuntimeError
cvar.teval = -55
if cvar.teval != -55:
raise RuntimeError
cvar.ectval = -66
if cvar.ectval != -66:
raise RuntimeError
cvar.ecpptval = -66
if cvar.ecpptval != -66:
raise RuntimeError

View File

@@ -0,0 +1,32 @@
from cpp11_type_aliasing import *
if get_host_target().bits != 32:
raise RuntimeError("get_host_target().bits should return 32")
if mult2(10) != 20:
raise RuntimeError("mult2(10) should return 20")
int_ptr = allocate_int()
inplace_mult2(int_ptr)
if read_int(int_ptr) != 24:
raise RuntimeError("read_int should return 24")
free_int(int_ptr)
pair = PairSubclass(3, 4)
if pair.first() != 3:
raise RuntimeError("pair.first() should return 3")
if pair.second() != 4:
raise RuntimeError("pair.second() should return 4")
if pair.a != 3:
raise RuntimeError("pair.a should be 3")
if plus1(5) != 6:
raise RuntimeError("plus1(5) should return 6")
if call(mult2_cb, 7) != 14:
raise RuntimeError("call(mult2_cb, 7) should return 14")
if call(get_callback(), 7) != 14:
raise RuntimeError("call(get_callback(), 7) should return 14")

View File

@@ -0,0 +1,7 @@
from cpp11_type_traits import *
if Elaborate(0, 0) != 1:
raise RuntimeError("Elaborate should have returned 1")
if Elaborate(0, 0.0) != 2:
raise RuntimeError("Elaborate should have returned 2")

View File

@@ -0,0 +1,21 @@
import cpp11_uniform_initialization
var1 = cpp11_uniform_initialization.cvar.var1
if var1.x != 5:
raise RuntimeError
var2 = cpp11_uniform_initialization.cvar.var2
if var2.getX() != 2:
raise RuntimeError
m = cpp11_uniform_initialization.MoreInit()
if m.charptr != None:
raise RuntimeError, m.charptr
m.charptr = "hello sir"
if m.charptr != "hello sir":
raise RuntimeError, m.charptr
if m.more1(m.vi) != 15:
raise RuntimeError, m.vi
if m.more1([-1, 1, 2]) != 2:
raise RuntimeError, m.vi
if m.more1() != 10:
raise RuntimeError

View File

@@ -0,0 +1,23 @@
import cpp_enum
f = cpp_enum.Foo()
if f.hola != f.Hello:
print f.hola
raise RuntimeError
f.hola = f.Hi
if f.hola != f.Hi:
print f.hola
raise RuntimeError
f.hola = f.Hello
if f.hola != f.Hello:
print f.hola
raise RuntimeError
cpp_enum.cvar.hi = cpp_enum.Hello
if cpp_enum.cvar.hi != cpp_enum.Hello:
print cpp_enum.cvar.hi
raise RuntimeError

View File

@@ -0,0 +1,43 @@
# Note: This example assumes that namespaces are flattened
import cpp_namespace
n = cpp_namespace.fact(4)
if n != 24:
raise RuntimeError("Bad return value!")
if cpp_namespace.cvar.Foo != 42:
raise RuntimeError("Bad variable value!")
t = cpp_namespace.Test()
if t.method() != "Test::method":
raise RuntimeError("Bad method return value!")
if cpp_namespace.do_method(t) != "Test::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method2(t) != "Test::method":
raise RuntimeError("Bad return value!")
cpp_namespace.weird("hello", 4)
del t
t2 = cpp_namespace.Test2()
t3 = cpp_namespace.Test3()
t4 = cpp_namespace.Test4()
t5 = cpp_namespace.Test5()
if cpp_namespace.foo3(42) != 42:
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t2, 40) != "Test2::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t3, 40) != "Test3::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t4, 40) != "Test4::method":
raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t5, 40) != "Test5::method":
raise RuntimeError("Bad return value!")

View File

@@ -0,0 +1,43 @@
#!/usr/bin/evn python
from cpp_static import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
if is_new_style_class(StaticFunctionTest):
StaticFunctionTest.static_func()
StaticFunctionTest.static_func_2(1)
StaticFunctionTest.static_func_3(1, 2)
else:
StaticFunctionTest().static_func()
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1, 2)
if is_python_builtin():
if not StaticMemberTest.static_int == 99: raise RuntimeError("static_int not 99")
StaticMemberTest.static_int = 10
if not StaticMemberTest.static_int == 10: raise RuntimeError("static_int not 10")
if not StaticBase.statty == 11: raise RuntimeError("statty not 11")
if not StaticDerived.statty == 111: raise RuntimeError("statty not 111")
StaticBase.statty = 22
StaticDerived.statty = 222
if not StaticBase.statty == 22: raise RuntimeError("statty not 22")
if not StaticDerived.statty == 222: raise RuntimeError("statty not 222")
# Restore
StaticMemberTest.static_int = 99
StaticBase.statty = 11
StaticDerived.statty = 111
if not cvar.StaticMemberTest_static_int == 99: raise RuntimeError("cvar static_int not 99")
cvar.StaticMemberTest_static_int = 10
if not cvar.StaticMemberTest_static_int == 10: raise RuntimeError("cvar static_int not 10")
if not cvar.StaticBase_statty == 11: raise RuntimeError("cvar statty not 11")
if not cvar.StaticDerived_statty == 111: raise RuntimeError("cvar statty not 111")
cvar.StaticBase_statty = 22
cvar.StaticDerived_statty = 222
if not cvar.StaticBase_statty == 22: raise RuntimeError("cvar statty not 22")
if not cvar.StaticDerived_statty == 222: raise RuntimeError("cvar statty not 222")

View File

@@ -0,0 +1,28 @@
from default_arg_values import *
d = Display()
if d.draw1() != 0:
raise RuntimeError
if d.draw1(12) != 12:
raise RuntimeError
p = createPtr(123)
if d.draw2() != 0:
raise RuntimeError
if d.draw2(p) != 123:
raise RuntimeError
if d.bool0() != False or type(d.bool0()) != type(False):
raise RuntimeError
if d.bool1() != True or type(d.bool1()) != type(True):
raise RuntimeError
if d.mybool0() != False or type(d.mybool0()) != type(False):
raise RuntimeError
if d.mybool1() != True or type(d.mybool1()) != type(True):
raise RuntimeError

View File

@@ -0,0 +1,6 @@
import default_args_c
if default_args_c.foo1() != 1:
raise RuntimeError("failed")
if default_args_c.foo43() != 43:
raise RuntimeError("failed")

View File

@@ -0,0 +1,158 @@
# 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):
return hasattr(cls, "__class__")
def run(module_name):
default_args = __import__(module_name)
ec = default_args.EnumClass()
if not ec.blah():
raise RuntimeError("EnumClass::blah() default arguments don't work")
de = default_args.DerivedEnumClass()
de.accelerate()
de.accelerate(default_args.EnumClass.SLOW)
if default_args.Statics_staticMethod() != 60:
raise RuntimeError
if default_args.cfunc1(1) != 2:
raise RuntimeError
if default_args.cfunc2(1) != 3:
raise RuntimeError
if default_args.cfunc3(1) != 4:
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
# It is difficult to test the python:cdefaultargs feature properly as -builtin
# and -fastproxy do not use the Python layer for default args
if default_args.CDA().cdefaultargs_test1() != 1:
raise RuntimeError
if default_args.CDA().cdefaultargs_test2() != 1:
raise RuntimeError
if default_args.chartest1() != 'x':
raise RuntimeError
if default_args.chartest2() != '\0':
raise RuntimeError
if default_args.chartest3() != '\1':
raise RuntimeError
if default_args.chartest4() != '\n':
raise RuntimeError
if default_args.chartest5() != 'B':
raise RuntimeError
if default_args.chartest6() != 'C':
raise RuntimeError
if __name__ == "__main__":
run('default_args')

View File

@@ -0,0 +1,107 @@
import _default_constructor
# This test is expected to fail with -builtin option.
# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
# which is not provided with the -builtin option.
if _default_constructor.is_python_builtin():
exit(0)
dc = _default_constructor
a = dc.new_A()
dc.delete_A(a)
aa = dc.new_AA()
dc.delete_AA(aa)
try:
b = dc.new_B()
print "Whoa. new_BB created."
except:
pass
del_b = dc.delete_B
try:
bb = dc.new_BB()
print "Whoa. new_BB created."
except:
pass
del_bb = dc.delete_BB
try:
c = dc.new_C()
print "Whoa. new_C created."
except:
pass
del_c = dc.delete_C
cc = dc.new_CC()
dc.delete_CC(cc)
try:
d = dc.new_D()
print "Whoa. new_D created"
except:
pass
del_d = dc.delete_D
try:
dd = dc.new_DD()
print "Whoa. new_DD created"
except:
pass
dd = dc.delete_DD
try:
ad = dc.new_AD()
print "Whoa. new_AD created"
except:
pass
del_ad = dc.delete_AD
e = dc.new_E()
dc.delete_E(e)
ee = dc.new_EE()
dc.delete_EE(ee)
try:
eb = dc.new_EB()
print "Whoa. new_EB created"
except:
pass
del_eb = dc.delete_EB
f = dc.new_F()
try:
del_f = dc.delete_F
print "Whoa. delete_F created"
except AttributeError:
pass
dc.F_destroy(f)
g = dc.new_G()
try:
del_g = dc.delete_G
print "Whoa. delete_G created"
except AttributeError:
pass
dc.G_destroy(g)
gg = dc.new_GG()
dc.delete_GG(gg)
import default_constructor
hh = default_constructor.HH(1, 1)

View File

@@ -0,0 +1,91 @@
import director_abstract
def is_new_style_class(cls):
return hasattr(cls, "__class__")
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
def ping(self):
return "MyFoo::ping()"
a = MyFoo()
if a.ping() != "MyFoo::ping()":
raise RuntimeError, a.ping()
if a.pong() != "Foo::pong();MyFoo::ping()":
raise RuntimeError, a.pong()
class MyExample1(director_abstract.Example1):
def Color(self, r, g, b):
return r
class MyExample2(director_abstract.Example2):
def Color(self, r, g, b):
return g
class MyExample3(director_abstract.Example3_i):
def Color(self, r, g, b):
return b
me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1, 2, 3) != 1:
raise RuntimeError
if is_new_style_class(MyExample2):
MyExample2_static = MyExample2
else:
MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1, 2)
if MyExample2_static.get_color(me2, 1, 2, 3) != 2:
raise RuntimeError
if is_new_style_class(MyExample3):
MyExample3_static = MyExample3
else:
MyExample3_static = MyExample3()
me3 = MyExample3()
if MyExample3_static.get_color(me3, 1, 2, 3) != 3:
raise RuntimeError
error = 1
try:
me1 = director_abstract.Example1()
except:
error = 0
if (error):
raise RuntimeError
error = 1
try:
me2 = director_abstract.Example2()
except:
error = 0
if (error):
raise RuntimeError
error = 1
try:
me3 = director_abstract.Example3_i()
except:
error = 0
if (error):
raise RuntimeError
try:
f = director_abstract.A.f
except:
raise RuntimeError

View File

@@ -0,0 +1,5 @@
from director_alternating import *
id = getBar().id()
if id != idFromGetBar():
raise RuntimeError, "Got wrong id: " + str(id)

View File

@@ -0,0 +1,93 @@
import director_basic
class PyFoo(director_basic.Foo):
def ping(self):
return "PyFoo::ping()"
a = PyFoo()
if a.ping() != "PyFoo::ping()":
raise RuntimeError, a.ping()
if a.pong() != "Foo::pong();PyFoo::ping()":
raise RuntimeError, a.pong()
b = director_basic.Foo()
if b.ping() != "Foo::ping()":
raise RuntimeError, b.ping()
if b.pong() != "Foo::pong();Foo::ping()":
raise RuntimeError, b.pong()
a = director_basic.A1(1)
if a.rg(2) != 2:
raise RuntimeError
class PyClass(director_basic.MyClass):
def method(self, vptr):
self.cmethod = 7
pass
def vmethod(self, b):
b.x = b.x + 31
return b
b = director_basic.Bar(3)
d = director_basic.MyClass()
c = PyClass()
cc = director_basic.MyClass_get_self(c)
dd = director_basic.MyClass_get_self(d)
bc = cc.cmethod(b)
bd = dd.cmethod(b)
cc.method(b)
if c.cmethod != 7:
raise RuntimeError
if bc.x != 34:
raise RuntimeError
if bd.x != 16:
raise RuntimeError
class PyMulti(director_basic.Foo, director_basic.MyClass):
def __init__(self):
director_basic.Foo.__init__(self)
director_basic.MyClass.__init__(self)
pass
def vmethod(self, b):
b.x = b.x + 31
return b
def ping(self):
return "PyFoo::ping()"
a = 0
for i in range(0, 100):
pymult = PyMulti()
pymult.pong()
del pymult
pymult = PyMulti()
p1 = director_basic.Foo_get_self(pymult)
p2 = director_basic.MyClass_get_self(pymult)
p1.ping()
p2.vmethod(bc)

View File

@@ -0,0 +1,167 @@
from director_classic import *
class TargetLangPerson(Person):
def __init__(self):
Person.__init__(self)
def id(self):
identifier = "TargetLangPerson"
return identifier
class TargetLangChild(Child):
def __init__(self):
Child.__init__(self)
def id(self):
identifier = "TargetLangChild"
return identifier
class TargetLangGrandChild(GrandChild):
def __init__(self):
GrandChild.__init__(self)
def id(self):
identifier = "TargetLangGrandChild"
return identifier
# Semis - don't override id() in target language
class TargetLangSemiPerson(Person):
def __init__(self):
Person.__init__(self)
# No id() override
class TargetLangSemiChild(Child):
def __init__(self):
Child.__init__(self)
# No id() override
class TargetLangSemiGrandChild(GrandChild):
def __init__(self):
GrandChild.__init__(self)
# No id() override
# Orphans - don't override id() in C++
class TargetLangOrphanPerson(OrphanPerson):
def __init__(self):
OrphanPerson.__init__(self)
def id(self):
identifier = "TargetLangOrphanPerson"
return identifier
class TargetLangOrphanChild(OrphanChild):
def __init__(self):
OrphanChild.__init__(self)
def id(self):
identifier = "TargetLangOrphanChild"
return identifier
def check(person, expected):
debug = 0
# Normal target language polymorphic call
ret = person.id()
if (debug):
print(ret)
if (ret != expected):
raise RuntimeError(
"Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call from C++
caller = Caller()
caller.setCallback(person)
ret = caller.call()
if (debug):
print(ret)
if (ret != expected):
raise RuntimeError(
"Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call of object created in target language and passed to C++
# and back again
baseclass = caller.baseClass()
ret = baseclass.id()
if (debug):
print(ret)
if (ret != expected):
raise RuntimeError(
"Failed. Received: " + str(ret) + " Expected: " + expected)
caller.resetCallback()
if (debug):
print("----------------------------------------")
person = Person()
check(person, "Person")
del person
person = Child()
check(person, "Child")
del person
person = GrandChild()
check(person, "GrandChild")
del person
person = TargetLangPerson()
check(person, "TargetLangPerson")
del person
person = TargetLangChild()
check(person, "TargetLangChild")
del person
person = TargetLangGrandChild()
check(person, "TargetLangGrandChild")
del person
# Semis - don't override id() in target language
person = TargetLangSemiPerson()
check(person, "Person")
del person
person = TargetLangSemiChild()
check(person, "Child")
del person
person = TargetLangSemiGrandChild()
check(person, "GrandChild")
del person
# Orphans - don't override id() in C++
person = OrphanPerson()
check(person, "Person")
del person
person = OrphanChild()
check(person, "Child")
del person
person = TargetLangOrphanPerson()
check(person, "TargetLangOrphanPerson")
del person
person = TargetLangOrphanChild()
check(person, "TargetLangOrphanChild")
del person

View File

@@ -0,0 +1,9 @@
from director_default import *
f = Foo()
f = Foo(1)
f = Bar()
f = Bar(1)

View File

@@ -0,0 +1,38 @@
import director_detect
class MyBar(director_detect.Bar):
def __init__(self, val=2):
director_detect.Bar.__init__(self)
self.val = val
def get_value(self):
self.val = self.val + 1
return self.val
def get_class(self):
self.val = self.val + 1
return director_detect.A()
def just_do_it(self):
self.val = self.val + 1
def clone(self):
return MyBar(self.val)
pass
b = MyBar()
f = b.baseclass()
v = f.get_value()
a = f.get_class()
f.just_do_it()
c = b.clone()
vc = c.get_value()
if (v != 3) or (b.val != 5) or (vc != 6):
raise RuntimeError, "Bad virtual detection"

View File

@@ -0,0 +1,14 @@
import director_enum
class MyFoo(director_enum.Foo):
def say_hi(self, val):
return val
b = director_enum.Foo()
a = MyFoo()
if a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi):
raise RuntimeError

View File

@@ -0,0 +1,88 @@
from director_exception import *
class MyException(Exception):
def __init__(self, a, b):
self.msg = a + b
class MyFoo(Foo):
def ping(self):
raise NotImplementedError, "MyFoo::ping() EXCEPTION"
class MyFoo2(Foo):
def ping(self):
return True
pass # error: should return a string
class MyFoo3(Foo):
def ping(self):
raise MyException("foo", "bar")
# Check that the NotImplementedError raised by MyFoo.ping() is returned by
# MyFoo.pong().
ok = 0
a = MyFoo()
b = launder(a)
try:
b.pong()
except NotImplementedError, e:
if str(e) == "MyFoo::ping() EXCEPTION":
ok = 1
else:
print "Unexpected error message: %s" % str(e)
except:
pass
if not ok:
raise RuntimeError
# Check that the director returns the appropriate TypeError if the return type
# is wrong.
ok = 0
a = MyFoo2()
b = launder(a)
try:
b.pong()
except TypeError, e:
if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
ok = 1
else:
print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
# Check that the director can return an exception which requires two arguments
# to the constructor, without mangling it.
ok = 0
a = MyFoo3()
b = launder(a)
try:
b.pong()
except MyException, e:
if e.msg == 'foobar':
ok = 1
else:
print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
# This is expected to fail with -builtin option
# Throwing builtin classes as exceptions not supported
if not is_python_builtin():
try:
raise Exception2()
except Exception2:
pass
try:
raise Exception1()
except Exception1:
pass

View File

@@ -0,0 +1,22 @@
# Test case from bug #1506850
#"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
# program that waits on the mutex to be unlocked."
from director_extend import *
class MyObject(SpObject):
def __init__(self):
SpObject.__init__(self)
return
def getFoo(self):
return 123
m = MyObject()
if m.dummy() != 666:
raise RuntimeError, "1st call"
if m.dummy() != 666: # Locked system
raise RuntimeError, "2nd call"

View File

@@ -0,0 +1,51 @@
from director_finalizer import *
class MyFoo(Foo):
def __del__(self):
self.orStatus(2)
try:
Foo.__del__(self)
except:
pass
resetStatus()
a = MyFoo()
del a
if getStatus() != 3:
raise RuntimeError
resetStatus()
a = MyFoo()
launder(a)
if getStatus() != 0:
raise RuntimeError
del a
if getStatus() != 3:
raise RuntimeError
resetStatus()
a = MyFoo().__disown__()
deleteFoo(a)
if getStatus() != 3:
raise RuntimeError
resetStatus()
a = MyFoo().__disown__()
deleteFoo(launder(a))
if getStatus() != 3:
raise RuntimeError
resetStatus()

View File

@@ -0,0 +1,7 @@
from director_frob import *
foo = Bravo()
s = foo.abs_method()
if s != "Bravo::abs_method()":
raise RuntimeError, s

View File

@@ -0,0 +1,4 @@
from director_keywords import *
f = Foo()
f.check_self(20)

View File

@@ -0,0 +1,64 @@
from director_nested import *
class A(FooBar_int):
def do_step(self):
return "A::do_step;"
def get_value(self):
return "A::get_value"
pass
a = A()
if a.step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;":
raise RuntimeError, "Bad A virtual resolution"
class B(FooBar_int):
def do_advance(self):
return "B::do_advance;" + self.do_step()
def do_step(self):
return "B::do_step;"
def get_value(self):
return 1
pass
b = B()
if b.step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;":
raise RuntimeError, "Bad B virtual resolution"
class C(FooBar_int):
def do_advance(self):
return "C::do_advance;" + FooBar_int.do_advance(self)
def do_step(self):
return "C::do_step;"
def get_value(self):
return 2
def get_name(self):
return FooBar_int.get_name(self) + " hello"
pass
cc = C()
c = FooBar_int_get_self(cc)
c.advance()
if c.get_name() != "FooBar::get_name hello":
raise RuntimeError
if c.name() != "FooBar::get_name hello":
raise RuntimeError

View File

@@ -0,0 +1,13 @@
import director_pass_by_value
passByVal = None
class director_pass_by_value_Derived(director_pass_by_value.DirectorPassByValueAbstractBase):
def virtualMethod(self, b):
global passByVal
passByVal = b
# bug was the passByVal global object was destroyed after the call to virtualMethod had finished.
director_pass_by_value.Caller().call_virtualMethod(director_pass_by_value_Derived())
ret = passByVal.getVal();
if ret != 0x12345678:
raise RuntimeError("Bad return value, got " + hex(ret))

View File

@@ -0,0 +1,41 @@
import director_profile
class MyB(director_profile.B):
def vfi(self, a):
return a + 3
a = director_profile.A()
myb = MyB()
b = director_profile.B.get_self(myb)
fi = b.fi
i = 50000
a = 1
while i:
a = fi(a) # 1
a = fi(a) # 2
a = fi(a) # 3
a = fi(a) # 4
a = fi(a) # 5
a = fi(a) # 6
a = fi(a) # 7
a = fi(a) # 8
a = fi(a) # 9
a = fi(a) # 10
a = fi(a) # 1
a = fi(a) # 2
a = fi(a) # 3
a = fi(a) # 4
a = fi(a) # 5
a = fi(a) # 6
a = fi(a) # 7
a = fi(a) # 8
a = fi(a) # 9
a = fi(a) # 20
i -= 1
print a

View File

@@ -0,0 +1,19 @@
import director_property
class PyFoo(director_property.Foo):
a = property(director_property.Foo.getA, director_property.Foo.setA)
def ping(self):
return "PyFoo::ping()"
foo = PyFoo()
foo.setA("BLABLA")
if foo.getA() != "BLABLA":
raise RuntimeError
foo.a = "BIBI"
if foo.a != "BIBI":
raise RuntimeError

View File

@@ -0,0 +1,132 @@
from director_protected import *
class FooBar(Bar):
def ping(self):
return "FooBar::ping();"
class FooBar2(Bar):
def ping(self):
return "FooBar2::ping();"
def pang(self):
return "FooBar2::pang();"
class FooBar3(Bar):
def cheer(self):
return "FooBar3::cheer();"
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
fb3 = FooBar3()
try:
s = fb.used()
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();":
raise RuntimeError
pass
except:
raise RuntimeError, "bad FooBar::used"
try:
s = fb2.used()
if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
raise RuntimeError
pass
except:
raise RuntimeError, "bad FooBar2::used"
try:
s = b.pong()
if s != "Bar::pong();Foo::pong();Bar::ping();":
raise RuntimeError
pass
except:
raise RuntimeError, "bad Bar::pong"
try:
s = f.pong()
if s != "Bar::pong();Foo::pong();Bar::ping();":
raise RuntimeError
pass
except:
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:
b.ping()
protected = 0
except:
pass
if not protected:
raise RuntimeError, "Foo::ping is protected"
protected = 1
try:
f.ping()
protected = 0
except:
pass
if not protected:
raise RuntimeError, "Foo::ping is protected"
protected = 1
try:
f.pang()
protected = 0
except:
pass
if not protected:
raise RuntimeError, "FooBar::pang is protected"
protected = 1
try:
b.cheer()
protected = 0
except:
pass
if not protected:
raise RuntimeError, "Bar::cheer is protected"
protected = 1
try:
f.cheer()
protected = 0
except:
pass
if not protected:
raise RuntimeError, "Foo::cheer is protected"
if fb3.cheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3::cheer"
if fb2.callping() != "FooBar2::ping();":
raise RuntimeError, "bad fb2.callping"
if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
raise RuntimeError, "bad fb2.callcheer"
if fb3.callping() != "Bar::ping();":
raise RuntimeError, "bad fb3.callping"
if fb3.callcheer() != "FooBar3::cheer();":
raise RuntimeError, "bad fb3.callcheer"

View File

@@ -0,0 +1,37 @@
from director_smartptr import *
class director_smartptr_MyBarFoo(Foo):
def ping(self):
return "director_smartptr_MyBarFoo.ping()"
def pong(self):
return "director_smartptr_MyBarFoo.pong();" + self.ping()
def upcall(self, fooBarPtr):
return "override;" + fooBarPtr.FooBarDo()
def makeFoo(self):
return Foo()
def check(got, expected):
if (got != expected):
raise RuntimeError, "Failed, got: " + got + " expected: " + expected
fooBar = FooBar()
myBarFoo = director_smartptr_MyBarFoo()
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()")
check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()")
check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()")
myFoo = myBarFoo.makeFoo()
check(myFoo.pong(), "Foo::pong();Foo::ping()")
check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()")
check(myFoo.upcall(FooBar()), "Bar::Foo2::Foo2Bar()")
myFoo2 = Foo().makeFoo()
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
check(myFoo2.upcall(FooBar()), "Bar::Foo2::Foo2Bar()")

View File

@@ -0,0 +1,41 @@
import director_stl
class MyFoo(director_stl.Foo):
def ping(self, s):
return "MyFoo::ping():" + s
def pident(self, arg):
return arg
def vident(self, v):
return v
def vidents(self, v):
return v
def vsecond(self, v1, v2):
return v2
a = MyFoo()
a.tping("hello")
a.tpong("hello")
p = (1, 2)
a.pident(p)
v = (3, 4)
a.vident(v)
a.tpident(p)
a.tvident(v)
v1 = (3, 4)
v2 = (5, 6)
a.tvsecond(v1, v2)
vs = ("hi", "hello")
vs
a.tvidents(vs)

View File

@@ -0,0 +1,29 @@
from director_string import *
class B(A):
def __init__(self, string):
A.__init__(self, string)
def get_first(self):
return A.get_first(self) + " world!"
def process_text(self, string):
A.process_text(self, string)
self.smem = "hello"
b = B("hello")
b.get(0)
if b.get_first() != "hello world!":
print b.get_first()
raise RuntimeError
b.call_process_func()
if b.smem != "hello":
print smem
raise RuntimeError

View File

@@ -0,0 +1,20 @@
from director_thread import Foo
class Derived(Foo):
def __init__(self):
Foo.__init__(self)
def do_foo(self):
self.val = self.val - 1
d = Derived()
d.run()
if d.val >= 0:
print d.val
raise RuntimeError
d.stop()

View File

@@ -0,0 +1,20 @@
import director_unroll
class MyFoo(director_unroll.Foo):
def ping(self):
return "MyFoo::ping()"
a = MyFoo()
b = director_unroll.Bar()
b.set(a)
c = b.get()
if not (a.this == c.this):
print a, c
raise RuntimeError

View File

@@ -0,0 +1,28 @@
from director_wstring import *
class B(A):
def __init__(self, string):
A.__init__(self, string)
def get_first(self):
return A.get_first(self) + u" world!"
def process_text(self, string):
self.smem = u"hello"
b = B(u"hello")
b.get(0)
if b.get_first() != u"hello world!":
print b.get_first()
raise RuntimeError
b.call_process_func()
if b.smem != u"hello":
print smem
raise RuntimeError

View File

@@ -0,0 +1,25 @@
from disown import *
a = A()
tmp = a.thisown
a.thisown = 0
if a.thisown:
raise RuntimeError
a.thisown = 1
if (not a.thisown):
raise RuntimeError
a.thisown = tmp
if (a.thisown != tmp):
raise RuntimeError
b = B()
b.acquire(a)
if a.thisown:
raise RuntimeError

View File

@@ -0,0 +1,11 @@
import dynamic_cast
f = dynamic_cast.Foo()
b = dynamic_cast.Bar()
x = f.blah()
y = b.blah()
a = dynamic_cast.do_test(y)
if a != "Bar::test":
print "Failed!!"

View File

@@ -0,0 +1 @@
import empty_c

View File

@@ -0,0 +1 @@
import empty

View File

@@ -0,0 +1,10 @@
import enum_forward
f1 = enum_forward.get_enum1()
f1 = enum_forward.test_function1(f1)
f2 = enum_forward.get_enum2()
f2 = enum_forward.test_function2(f2)
f3 = enum_forward.get_enum3()
f3 = enum_forward.test_function3(f3)

View File

@@ -0,0 +1,6 @@
import enum_template
if enum_template.MakeETest() != 1:
raise RuntimeError
if enum_template.TakeETest(0) != None:
raise RuntimeError

View File

@@ -0,0 +1,18 @@
import _enums
_enums.bar2(1)
_enums.bar3(1)
_enums.bar1(1)
if _enums.cvar.enumInstance != 2:
raise RuntimeError
if _enums.cvar.Slap != 10:
raise RuntimeError
if _enums.cvar.Mine != 11:
raise RuntimeError
if _enums.cvar.Thigh != 12:
raise RuntimeError

View File

@@ -0,0 +1,5 @@
import exception_classname
a = exception_classname.Exception()
if a.testfunc() != 42:
raise RuntimeError("Not 42!")

View File

@@ -0,0 +1,44 @@
from exception_order import *
# This test is expected to fail with -builtin option.
# Throwing builtin classes as exceptions not supported
if is_python_builtin():
exit(0)
a = A()
try:
a.foo()
except E1, e:
pass
except:
raise RuntimeError, "bad exception order"
try:
a.bar()
except E2, e:
pass
except:
raise RuntimeError, "bad exception order"
try:
a.foobar()
except RuntimeError, e:
if e.args[0] != "postcatch unknown":
print "bad exception order",
raise RuntimeError, e.args
try:
a.barfoo(1)
except E1, e:
pass
except:
raise RuntimeError, "bad exception order"
try:
a.barfoo(2)
except E2, e:
pass
except:
raise RuntimeError, "bad exception order"

View File

@@ -0,0 +1,46 @@
import extend_placement
foo = extend_placement.Foo()
foo = extend_placement.Foo(1)
foo = extend_placement.Foo(1, 1)
foo.spam()
foo.spam("hello")
foo.spam(1)
foo.spam(1, 1)
foo.spam(1, 1, 1)
foo.spam(extend_placement.Foo())
foo.spam(extend_placement.Foo(), 1.0)
bar = extend_placement.Bar()
bar = extend_placement.Bar(1)
bar.spam()
bar.spam("hello")
bar.spam(1)
bar.spam(1, 1)
bar.spam(1, 1, 1)
bar.spam(extend_placement.Bar())
bar.spam(extend_placement.Bar(), 1.0)
foo = extend_placement.FooTi()
foo = extend_placement.FooTi(1)
foo = extend_placement.FooTi(1, 1)
foo.spam()
foo.spam("hello")
foo.spam(1)
foo.spam(1, 1)
foo.spam(1, 1, 1)
foo.spam(extend_placement.Foo())
foo.spam(extend_placement.Foo(), 1.0)
bar = extend_placement.BarTi()
bar = extend_placement.BarTi(1)
bar.spam()
bar.spam("hello")
bar.spam(1)
bar.spam(1, 1)
bar.spam(1, 1, 1)
bar.spam(extend_placement.Bar())
bar.spam(extend_placement.Bar(), 1.0)

View File

@@ -0,0 +1,45 @@
from extend_template_method import *
em = ExtendMe()
ret_double = em.do_stuff_double(1, 1.1)
if ret_double != 1.1:
raise RuntimeError("double failed " + ret_double)
ret_string = em.do_stuff_string(1, "hello there")
if ret_string != "hello there":
raise RuntimeError("string failed " + ret_string)
ret_double = em.do_overloaded_stuff(1.1)
if ret_double != 1.1:
raise RuntimeError("double failed " + ret_double)
ret_string = em.do_overloaded_stuff("hello there")
if ret_string != "hello there":
raise RuntimeError("string failed " + ret_string)
if ExtendMe.static_method(123) != 123:
raise RuntimeError("static_method failed")
em2 = ExtendMe(123)
em = TemplateExtend()
ret_double = em.do_template_stuff_double(1, 1.1)
if ret_double != 1.1:
raise RuntimeError("double failed " + ret_double)
ret_string = em.do_template_stuff_string(1, "hello there")
if ret_string != "hello there":
raise RuntimeError("string failed " + ret_string)
ret_double = em.do_template_overloaded_stuff(1.1)
if ret_double != 1.1:
raise RuntimeError("double failed " + ret_double)
ret_string = em.do_template_overloaded_stuff("hello there")
if ret_string != "hello there":
raise RuntimeError("string failed " + ret_string)
if TemplateExtend.static_template_method(123) != 123:
raise RuntimeError("static_template_method failed")
em2 = TemplateExtend(123)

View File

@@ -0,0 +1,7 @@
from extend_template_ns import *
f = Foo_One()
if f.test1(37) != 37:
raise RuntimeError
if f.test2(42) != 42:
raise RuntimeError

View File

@@ -0,0 +1,8 @@
import extend_template
f = extend_template.Foo_0()
if f.test1(37) != 37:
raise RuntimeError
if f.test2(42) != 42:
raise RuntimeError

View File

@@ -0,0 +1,4 @@
from extend_variable import *
if Foo.Bar != 42:
raise RuntimeError

View File

@@ -0,0 +1,3 @@
import extern_c
extern_c.RealFunction(2)

View File

@@ -0,0 +1,10 @@
import sys
import file_test
if sys.version_info[0:2] < (3, 0):
file_test.nfile(sys.stdout)
cstdout = file_test.GetStdOut()
file_test.nfile(cstdout)
file_test.nfile_name("test.dat")

View File

@@ -0,0 +1,37 @@
import friends
a = friends.A(2)
if friends.get_val1(a) != 2:
raise RuntimeError
if friends.get_val2(a) != 4:
raise RuntimeError
if friends.get_val3(a) != 6:
raise RuntimeError
# nice overload working fine
if friends.get_val1(1, 2, 3) != 1:
raise RuntimeError
b = friends.B(3)
# David's case
if friends.mix(a, b) != 5:
raise RuntimeError
di = friends.D_d(2)
dd = friends.D_d(3.3)
# incredible template overloading working just fine
if friends.get_val1(di) != 2:
raise RuntimeError
if friends.get_val1(dd) != 3.3:
raise RuntimeError
friends.set(di, 4)
friends.set(dd, 1.3)
if friends.get_val1(di) != 4:
raise RuntimeError
if friends.get_val1(dd) != 1.3:
raise RuntimeError

View File

@@ -0,0 +1,10 @@
from funcptr_cpp import *
if call1(ADD_BY_VALUE, 10, 11) != 21:
raise RuntimeError
if call2(ADD_BY_POINTER, 12, 13) != 25:
raise RuntimeError
if call3(ADD_BY_REFERENCE, 14, 15) != 29:
raise RuntimeError
if call1(ADD_BY_VALUE_C, 2, 3) != 5:
raise RuntimeError

View File

@@ -0,0 +1,8 @@
from fvirtual import *
sw = NodeSwitch()
n = Node()
i = sw.addChild(n)
if i != 2:
raise RuntimeError, "addChild"

View File

@@ -0,0 +1,52 @@
from global_functions import *
def check(a, b):
if a != b:
raise RuntimeError("Failed: " + str(a) + " != " + str(b))
global_void()
check(global_one(1), 1)
check(global_two(2, 2), 4)
fail = True
try:
global_void(1)
except TypeError, e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
fail = True
try:
global_one()
except TypeError, e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
fail = True
try:
global_one(2, 2)
except TypeError, e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
fail = True
try:
global_two(1)
except TypeError, e:
fail = False
if fail:
raise RuntimeError("argument count check failed")
fail = True
try:
global_two(3, 3, 3)
except TypeError, e:
fail = False
if fail:
raise RuntimeError("argument count check failed")

View File

@@ -0,0 +1,58 @@
from global_namespace import *
def is_new_style_class(cls):
return hasattr(cls, "__class__")
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
k4 = Klass4()
k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
if is_new_style_class(KlassMethods):
KlassMethods_static = KlassMethods
else:
KlassMethods_static = KlassMethods()
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1A()
k2 = getKlass2A()
k3 = getKlass3A()
k4 = getKlass4A()
k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
k3 = getKlass3B()
k4 = getKlass4B()
k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
if is_new_style_class(XYZMethods):
XYZMethods_static = XYZMethods
else:
XYZMethods_static = XYZMethods()
XYZMethods_static.methodA(
XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
XYZMethods_static.methodB(
XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
if is_new_style_class(TheEnumMethods):
TheEnumMethods_static = TheEnumMethods
else:
TheEnumMethods_static = TheEnumMethods()
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)

View File

@@ -0,0 +1,4 @@
from global_ns_arg import *
a = foo(1)
b = bar_fn()

View File

@@ -0,0 +1,34 @@
import global_vars
global_vars.init()
b = global_vars.cvar.b
if b != "string b":
raise RuntimeError("Unexpected string: " + b)
global_vars.cvar.b = "a string value"
b = global_vars.cvar.b
if b != "a string value":
raise RuntimeError("Unexpected string: " + b)
x = global_vars.cvar.x
if x != 1234:
raise RuntimeError("Unexpected x: " + str(x))
global_vars.cvar.x = 9876
x = global_vars.cvar.x
if x != 9876:
raise RuntimeError("Unexpected string: " + str(x))
fail = True
try:
global_vars.cvar.notexist = "something"
except AttributeError, e:
fail = False
if fail:
raise RuntimeError("AttributeError should have been thrown")
fail = True
try:
g = global_vars.cvar.notexist
except AttributeError, e:
fail = False
if fail:
raise RuntimeError("AttributeError should have been thrown")

View File

@@ -0,0 +1,14 @@
import grouping
x = grouping.test1(42)
if x != 42:
raise RuntimeError
grouping.test2(42)
x = grouping.do_unary(37, grouping.NEGATE)
if x != -37:
raise RuntimeError
grouping.cvar.test3 = 42
grouping.test3 = 42

View File

@@ -0,0 +1,55 @@
#!/usr/bin/perl
use strict;
my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod
my $runme = shift @ARGV;
open HEADER, ">hugemod.h" or die "error";
open TEST, ">$runme" or die "error";
open I1, ">hugemod_a.i" or die "error";
open I2, ">hugemod_b.i" or die "error";
print TEST "import hugemod_a\n";
print TEST "import hugemod_b\n";
print I1 "\%module hugemod_a;\n";
print I1 "\%include \"hugemod.h\";\n";
print I1 "\%{ #include \"hugemod.h\" \%}\n";
print I2 "\%module hugemod_b;\n";
print I2 "\%import \"hugemod.h\";\n";
print I2 "\%{ #include \"hugemod.h\" \%}\n";
print I2 "\%inline \%{\n";
my $i;
for ($i = 0; $i < $modsize; $i++) {
my $t = $i * 4;
print HEADER "class type$i { public: int a; };\n";
print I2 "class dtype$i : public type$i { public: int b; };\n";
print TEST "c = hugemod_a.type$i()\n";
print TEST "c.a = $t\n";
print TEST "if c.a != $t:\n";
print TEST " raise RuntimeError\n";
print TEST "c = hugemod_b.dtype$i()\n";
print TEST "c.a = $t\n";
print TEST "if c.a != $t:\n";
print TEST " raise RuntimeError\n";
$t = -$t;
print TEST "c.b = $t\n";
print TEST "if c.b != $t:\n";
print TEST " raise RuntimeError\n\n";
}
print I2 "\%}\n";
close HEADER;
close TEST;
close I1;
close I2;

View File

@@ -0,0 +1,9 @@
import iadd
f = iadd.Foo()
f.AsA.x = 3
f.AsA += f.AsA
if f.AsA.x != 6:
raise RuntimeError

View File

@@ -0,0 +1,142 @@
from implicittest import *
def check(a, b):
if a != b:
raise RuntimeError(str(a) + " does not equal " + str(b))
def is_new_style_class(cls):
return hasattr(cls, "__class__")
#### Class ####
# No implicit conversion
check(1, A(1).get())
check(2, A(1.0).get())
check(3, A(B()).get())
check(4, A("hello").get())
try:
check(3, A(None).get())
raise RuntimeError
except ValueError:
# 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,
# references and pointers to different types, where pointers ought to be
# given a slightly higher precedence.
pass
check(1, get(1))
check(2, get(1.0))
check(3, get(B()))
# Explicit constructor:
try:
check(4, get("hello"))
raise RuntimeError
except TypeError:
pass
#### Template Class ####
# No implicit conversion
check(1, A_int(1).get())
check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
if is_new_style_class(A_int):
A_int_static = A_int
else:
A_int_static = A_int(0)
check(1, A_int_static.sget(1))
check(2, A_int_static.sget(1.0))
check(3, A_int_static.sget(B()))
# explicit constructor:
try:
check(4, A_int_static.sget("hello"))
raise RuntimeError
except TypeError:
pass
#### Global variable assignment ####
cvar.foo = Foo(1)
check(cvar.foo.ii, 1)
cvar.foo = 1
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:
try:
cvar.foo = "hello"
raise RuntimeError
except TypeError:
pass
#### Member variable assignment ####
# Note: also needs naturalvar
b = Bar()
check(b.f.ii, 0)
b.f = Foo("hello")
check(b.f.ii, 3)
b.f = 1
check(b.f.ii, 1)
b.f = 1.0
check(b.f.ii, 2)
# explicit constructor:
try:
b.f = "hello"
raise RuntimeError
except TypeError:
pass
#### Class testing None ####
# No implicit conversion
check(1, AA(1).get())
check(2, AA(1.0).get())
check(3, AA(B()).get())
check(3, AA(None).get())
check(4, AA("hello").get())
check(5, AA(BB()).get())
check(1, get_AA_val(1))
check(2, get_AA_val(1.0))
check(3, get_AA_val(B()))
check(3, get_AA_val(None))
check(5, get_AA_val(BB()))
# Explicit constructor:
try:
check(4, get_AA_val("hello"))
raise RuntimeError
except TypeError:
pass
check(1, get_AA_ref(1))
check(2, get_AA_ref(1.0))
check(3, get_AA_ref(B()))
check(3, get_AA_ref(None))
check(5, get_AA_ref(BB()))
# Explicit constructor:
try:
check(4, get_AA_ref("hello"))
raise RuntimeError
except TypeError:
pass
### overloading priority test ###
ccc = CCC(B())
check(ccc.checkvalue, 10)
check(ccc.xx(123), 11)
check(ccc.yy(123, 123), 111)

View File

@@ -0,0 +1,13 @@
from import_nomodule import *
# This test is expected to fail with -builtin option.
# The base class is needed for the builtin class hierarchy
if is_python_builtin():
exit(0)
f = create_Foo()
test1(f, 42)
delete_Foo(f)
b = Bar()
test1(b, 37)

View File

@@ -0,0 +1,6 @@
import import_stl_b
import import_stl_a
v_new = import_stl_b.process_vector([1, 2, 3])
if v_new != (1, 2, 3, 4):
raise RuntimeError, v_new

View File

@@ -0,0 +1,17 @@
# This is the import runtime testcase.
import imports_b
import imports_a
import sys
x = imports_b.B()
imports_a.A.hello(x)
a = imports_a.A()
c = imports_b.C()
a1 = c.get_a(c)
a2 = c.get_a_type(c)
if a1.hello() != a2.hello():
raise RuntimeError

View File

@@ -0,0 +1,31 @@
import inctest
error = 0
try:
a = inctest.A()
except:
print "didn't find A"
print "therefore, I didn't include 'testdir/subdir1/hello.i'"
error = 1
pass
try:
b = inctest.B()
except:
print "didn't find B"
print "therefore, I didn't include 'testdir/subdir2/hello.i'"
error = 1
pass
if error == 1:
raise RuntimeError
# Check the import in subdirectory worked
if inctest.importtest1(5) != 15:
print "import test 1 failed"
raise RuntimeError
if inctest.importtest2("black") != "white":
print "import test 2 failed"
raise RuntimeError

View File

@@ -0,0 +1,19 @@
import inherit_missing
a = inherit_missing.new_Foo()
b = inherit_missing.Bar()
c = inherit_missing.Spam()
x = inherit_missing.do_blah(a)
if x != "Foo::blah":
print "Whoa! Bad return", x
x = inherit_missing.do_blah(b)
if x != "Bar::blah":
print "Whoa! Bad return", x
x = inherit_missing.do_blah(c)
if x != "Spam::blah":
print "Whoa! Bad return", x
inherit_missing.delete_Foo(a)

View File

@@ -0,0 +1,21 @@
import inout
a = inout.AddOne1(1)
if a != 2:
raise RuntimeError
a = inout.AddOne3(1, 1, 1)
if a != [2, 2, 2]:
raise RuntimeError
a = inout.AddOne1p((1, 1))
if a != (2, 2):
raise RuntimeError
a = inout.AddOne2p((1, 1), 1)
if a != [(2, 2), 2]:
raise RuntimeError
a = inout.AddOne3p(1, (1, 1), 1)
if a != [2, (2, 2), 2]:
raise RuntimeError

Some files were not shown because too many files have changed in this diff Show More