Merge branch 'master' into doxygen

The way Python docstrings are indented has changed on master, so use the
standard inspect module in Python autodoc unit test to ignore the differences
in their indentation level between -builtin and non-builtin cases to make the
test still pass with the branch version, which avoids the use of different
(but almost identical) values in the test itself.
This commit is contained in:
Vadim Zeitlin 2016-12-05 02:14:51 +01:00
commit e668c47b70
45 changed files with 39369 additions and 11462 deletions

View file

@ -11,7 +11,7 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
PEP8_FLAGS = --ignore=E30,E402,E501,E731,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
@ -58,11 +58,18 @@ CPP_TEST_CASES += \
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 \
@ -127,11 +134,11 @@ py2_runme = $(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifneq (,$(PEP8))
check_pep8 = $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8 = $(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py
check_pep8_multi_cpp = \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
$(PEP8) $(PEP8_FLAGS) $$f.py; \
$(COMPILETOOL) $(PEP8) $(PEP8_FLAGS) $$f.py; \
done
endif
@ -166,7 +173,7 @@ endif
@if test "x$(SCRIPTDIR)" != "x$(srcdir)"; then rm -f $(SCRIPTDIR)/$(py2_runme); fi
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR="$(SRCDIR)" python_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

View file

@ -1,5 +1,6 @@
from autodoc import *
import commentVerifier
import inspect
import sys
def check(got, expected, expected_builtin=None, skip=False):
@ -12,174 +13,191 @@ def check(got, expected, expected_builtin=None, skip=False):
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")
check(A.func1.__doc__, "func1(A self, short arg2, Tuple hello) -> int")
check(A.func2.__doc__,
check(inspect.getdoc(A), "Proxy of C++ A class.", "::A")
check(inspect.getdoc(A.funk), "just a string.")
check(inspect.getdoc(A.func0),
"func0(self, arg2, hello) -> int")
check(inspect.getdoc(A.func1),
"func1(A self, short arg2, Tuple hello) -> int")
check(inspect.getdoc(A.func2),
"func2(self, arg2, hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
check(A.func3.__doc__,
"Parameters\n"
"----------\n"
"arg2: short\n"
"hello: int tuple[2]")
check(inspect.getdoc(A.func3),
"func3(A self, short arg2, Tuple hello) -> int\n"
"\n"
"Parameters:\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"Parameters\n"
"----------\n"
"arg2: short\n"
"hello: int tuple[2]")
check(A.func0default.__doc__,
check(inspect.getdoc(A.func0default),
"func0default(self, e, arg3, hello, f=2) -> int\n"
"func0default(self, e, arg3, hello) -> int"
)
check(A.func1default.__doc__,
"func0default(self, e, arg3, hello) -> int")
check(inspect.getdoc(A.func1default),
"func1default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"func1default(A self, A e, short arg3, Tuple hello) -> int"
)
check(A.func2default.__doc__,
"func1default(A self, A e, short arg3, Tuple hello) -> int")
check(inspect.getdoc(A.func2default),
"func2default(self, e, arg3, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\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"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
check(A.func3default.__doc__,
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]")
check(inspect.getdoc(A.func3default),
"func3default(A self, A e, short arg3, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
" f: double\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"
" e: A *\n"
" arg3: short\n"
" hello: int tuple[2]\n"
)
"Parameters\n"
"----------\n"
"e: A *\n"
"arg3: short\n"
"hello: int tuple[2]")
check(A.func0static.__doc__,
check(inspect.getdoc(A.func0static),
"func0static(e, arg2, hello, f=2) -> int\n"
"func0static(e, arg2, hello) -> int"
)
check(A.func1static.__doc__,
"func0static(e, arg2, hello) -> int")
check(inspect.getdoc(A.func1static),
"func1static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"func1static(A e, short arg2, Tuple hello) -> int"
)
check(A.func2static.__doc__,
"func1static(A e, short arg2, Tuple hello) -> int")
check(inspect.getdoc(A.func2static),
"func2static(e, arg2, hello, f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\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"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
check(A.func3static.__doc__,
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]")
check(inspect.getdoc(A.func3static),
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
"\n"
"Parameters:\n"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
" f: double\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"
" e: A *\n"
" arg2: short\n"
" hello: int tuple[2]\n"
)
"Parameters\n"
"----------\n"
"e: A *\n"
"arg2: short\n"
"hello: int tuple[2]")
if sys.version_info[0:2] > (2, 4):
# Python 2.4 does not seem to work
check(A.variable_a.__doc__,
check(inspect.getdoc(A.variable_a),
"A_variable_a_get(self) -> int",
"A.variable_a"
)
check(A.variable_b.__doc__,
check(inspect.getdoc(A.variable_b),
"A_variable_b_get(A self) -> int",
"A.variable_b"
)
check(A.variable_c.__doc__,
check(inspect.getdoc(A.variable_c),
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n",
"Parameters\n"
"----------\n"
"self: A *",
"A.variable_c"
)
check(A.variable_d.__doc__,
)
check(inspect.getdoc(A.variable_d),
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n",
"Parameters\n"
"----------\n"
"self: A *",
"A.variable_d"
)
)
check(B.__doc__,
"Proxy of C++ B class",
check(inspect.getdoc(B),
"Proxy of C++ B class.",
"::B"
)
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C", None, skip)
check(D.__init__.__doc__,
check(inspect.getdoc(C.__init__), "__init__(self, a, b, h) -> C", None, skip)
check(inspect.getdoc(D.__init__),
"__init__(D self, int a, int b, Hola h) -> D", None, skip)
check(E.__init__.__doc__,
check(inspect.getdoc(E.__init__),
"__init__(self, a, b, h) -> E\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n",
None, skip
"__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", None, skip
)
check(F.__init__.__doc__,
check(inspect.getdoc(F.__init__),
"__init__(F self, int a, int b, Hola h) -> F\n"
"\n"
"Parameters:\n"
" a: special comment for parameter a\n"
" b: another special comment for parameter b\n"
" h: enum Hola\n",
None, skip
"__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", None, skip
)
check(B.funk.__doc__, "funk(B self, int c, int d) -> int")
check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int")
check(funkdefaults.__doc__,
check(inspect.getdoc(B.funk),
"funk(B self, int c, int d) -> int")
check(inspect.getdoc(funk), "funk(A e, short arg2, int c, int d) -> int")
check(inspect.getdoc(funkdefaults),
"funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n"
"funkdefaults(A e, short arg2, int c, int d) -> int"
)
"funkdefaults(A e, short arg2, int c, int d) -> int")
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(banana.__doc__, "banana(S a, S b, int c, Integer d)")
check(inspect.getdoc(func_input), "func_input(int * INPUT) -> int")
check(inspect.getdoc(func_output), "func_output() -> int")
check(inspect.getdoc(func_inout), "func_inout(int * INOUT) -> int")
check(inspect.getdoc(func_cb), "func_cb(int c, int d) -> int")
check(inspect.getdoc(banana), "banana(S a, S b, int c, Integer d)")

View file

@ -4,9 +4,14 @@ 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*
@ -21,6 +26,8 @@ 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":

View file

@ -17,3 +17,6 @@ if defaults2.ret(10.0) != 10.0:
if defaults2.ret() != -1.0:
raise RuntimeError
if defaults2.nodefault(-2) != -2:
raise RuntimeError

View file

@ -18,3 +18,11 @@ if constant_directive.TYPE1_CONSTANT2.val != 2:
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,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,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,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

@ -13,5 +13,31 @@ else:
StaticFunctionTest().static_func()
StaticFunctionTest().static_func_2(1)
StaticFunctionTest().static_func_3(1, 2)
StaticMemberTest.static_int = 10
assert StaticMemberTest.static_int == 10
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,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

@ -136,5 +136,23 @@ def run(module_name):
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

@ -69,7 +69,7 @@ class TargetLangOrphanPerson(OrphanPerson):
class TargetLangOrphanChild(OrphanChild):
def __init__(self):
Child.__init__(self)
OrphanChild.__init__(self)
def id(self):
identifier = "TargetLangOrphanChild"

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,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 @@
import empty_c

View file

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

View file

@ -6,3 +6,5 @@ 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,4 @@
#!/usr/bin/env python
import keyword_rename_c
keyword_rename_c._in(1)
keyword_rename_c._except(1)

View file

@ -71,3 +71,13 @@ if myStringyClass.ReadWriteString != "changed string":
raise RuntimeError
if myStringyClass.ReadOnlyString != "changed string":
raise RuntimeError
# Check a proper AttributeError is raised for non-existent attributes, old versions used to raise unhelpful error:
# AttributeError: type object 'object' has no attribute '__getattr__'
try:
x = myFoo.does_not_exist
raise RuntimeError
except AttributeError, e:
if str(e).find("does_not_exist") == -1:
raise RuntimeError

View file

@ -521,7 +521,6 @@ class li_boost_shared_ptr_runme:
li_boost_shared_ptr.cvar.GlobalPointer = None
# plain reference
kglobal
k = li_boost_shared_ptr.Klass("global reference")
li_boost_shared_ptr.cvar.GlobalReference = k

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