Merge remote-tracking branch 'origin/master' into gsoc2012-scilab

Conflicts:
	Examples/Makefile.in
This commit is contained in:
Sylvestre Ledru 2013-08-06 10:06:31 +02:00
commit 21e17eaa73
795 changed files with 16905 additions and 11792 deletions

View file

@ -110,16 +110,19 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Rules for the different types of tests
%.cpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.ctest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
%.multicpptest:
+$(convert_testcase)
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
@ -139,17 +142,17 @@ run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PY
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
ifeq (,$(PY3))
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(run_python);\
fi
ifeq (,$(PY3))
convert_testcase =
else
run_testcase = \
convert_testcase = \
if [ -f $(py2_runme) ]; then \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme) && $(run_python); \
elif [ -f $(py3_runme) ]; then \
$(run_python); \
$(MAKE) -f $(srcdir)/Makefile $(py3_runme); \
fi
endif

View file

@ -1,4 +1,5 @@
from autodoc import *
import sys
def check(got, expected):
if expected != got:
@ -121,22 +122,24 @@ check(A.func3static.__doc__, "\n"
" "
)
check(A.variable_a.__doc__, "A_variable_a_get(self) -> int")
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
check(A.variable_c.__doc__, "\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
)
check(A.variable_d.__doc__, "\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\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")
check(A.variable_b.__doc__, "A_variable_b_get(A self) -> int")
check(A.variable_c.__doc__, "\n"
"A_variable_c_get(self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
)
check(A.variable_d.__doc__, "\n"
"A_variable_d_get(A self) -> int\n"
"\n"
"Parameters:\n"
" self: A *\n"
"\n"
)
check(B.__doc__, "Proxy of C++ B class")
check(C.__init__.__doc__, "__init__(self, a, b, h) -> C")

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

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

View file

@ -0,0 +1,73 @@
from implicittest import *
def check(a, b):
if a != b:
raise RuntimeError(str(a) + " does not equal " + str(b))
#### 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())
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())
check(1, A_int.sget(1))
check(2, A_int.sget(1.0))
check(3, A_int.sget(B()))
# explicit constructor:
try:
check(4, A_int.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

View file

@ -0,0 +1,67 @@
# Check usage of template attributes
import li_attribute_template
chell = li_attribute_template.Cintint(1,2,3)
def rassert( what, master ):
if what != master:
print what
raise RuntimeError
## Testing primitive by value attribute
rassert( chell.a, 1 )
chell.a = 3
rassert( chell.a, 3 )
## Testing primitive by ref attribute
rassert( chell.b, 2 )
chell.b = 5
rassert( chell.b,5 )
## Testing string
chell.str = "abc"
rassert( chell.str, "abc" )
# Testing class by value
rassert( chell.d.value, 1 )
chell.d = li_attribute_template.Foo(2)
rassert( chell.d.value, 2 )
# Testing class by reference
rassert( chell.e.value, 2 )
chell.e= li_attribute_template.Foo(3)
rassert( chell.e.value, 3 )
chell.e.value = 4
rassert( chell.e.value, 4 )
# Testing moderately complex template by value
rassert( chell.f.first, 1 )
rassert( chell.f.second, 2 )
pair = li_attribute_template.pair_intint(3,4)
chell.f = pair
rassert( chell.f.first, 3 )
rassert( chell.f.second, 4 )
# Testing moderately complex template by ref
rassert( chell.g.first, 2 )
rassert( chell.g.second, 3 )
pair = li_attribute_template.pair_intint(4,5)
chell.g = pair
rassert( chell.g.first, 4 )
rassert( chell.g.second, 5 )
chell.g.first = 6
chell.g.second = 7
rassert( chell.g.first, 6 )
rassert( chell.g.second, 7 )

View file

@ -1,6 +1,7 @@
# Check std::vector and std::list behaves the same as Python iterable types (list)
from li_std_containers_int import *
import sys
def failed(a, b, msg):
raise RuntimeError, msg + " " + str(list(a)) + " " + str(list(b))
@ -76,10 +77,13 @@ def container_insert_step(i, j, step, newval):
except IndexError, e:
il_error = e
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
# Python 2.6 contains bug fixes in extended slicing syntax: http://docs.python.org/2/whatsnew/2.6.html
skip_check = ps_error != None and(iv_error == il_error == None) and step > 0 and (sys.version_info[0:2] < (2, 6))
if not(skip_check):
if not((type(ps_error) == type(iv_error)) and (type(ps_error) == type(il_error))):
raise RuntimeError, "ValueError exception not consistently thrown: " + str(ps_error) + " " + str(iv_error) + " " + str(il_error)
compare_containers(ps, iv, il)
compare_containers(ps, iv, il)
# Check std::vector and std::list delete behaves same as Python list delete including exceptions

View file

@ -0,0 +1,9 @@
from li_std_except_as_class import *
# std::domain_error hierarchy
try: test_domain_error()
except domain_error: pass
try: test_domain_error()
except logic_error: pass
try: test_domain_error()
except exception: pass

View file

@ -0,0 +1,10 @@
from li_std_pair_using import *
one_tuple = ("one", "numero uno")
one = StringStringPair(one_tuple)
two_tuple = ("two", 2)
two = StringIntPair(two_tuple)
if bounce(one) != one_tuple:
raise RuntimeError

View file

@ -275,10 +275,22 @@ try:
except TypeError:
if a != t.var_char:
error = 1
pass
pass
if error:
raise RuntimeError, "bad char typemap"
try:
error = 0
a = t.var_ushort
t.var_ushort = -1
error = 1
except OverflowError:
if a != t.var_ushort:
error = 1
pass
if error:
raise RuntimeError, "bad ushort typemap"
try:
error = 0
a = t.var_uint
@ -287,10 +299,34 @@ try:
except OverflowError:
if a != t.var_uint:
error = 1
pass
pass
if error:
raise RuntimeError, "bad uint typemap"
try:
error = 0
a = t.var_sizet
t.var_sizet = -1
error = 1
except OverflowError:
if a != t.var_sizet:
error = 1
pass
if error:
raise RuntimeError, "bad sizet typemap"
try:
error = 0
a = t.var_ulong
t.var_ulong = -1
error = 1
except OverflowError:
if a != t.var_ulong:
error = 1
pass
if error:
raise RuntimeError, "bad ulong typemap"
#
#
try:
@ -301,7 +337,7 @@ try:
except TypeError:
if a != t.var_namet:
error = 1
pass
pass
if error:
raise RuntimeError, "bad namet typemap"

View file

@ -10,3 +10,11 @@ assert issubclass(IntSet, MutableSet)
assert issubclass(IntMultiset, MutableSet)
assert issubclass(IntVector, MutableSequence)
assert issubclass(IntList, MutableSequence)
mapii = Mapii()
multimapii = Multimapii()
intset = IntSet()
intmultiset = IntMultiset()
intvector = IntVector()
intlist = IntList()

View file

@ -2,3 +2,6 @@ import python_varargs_typemap
if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
raise RuntimeError("testfunc failed!")
if (python_varargs_typemap.testfunc(1, 2.0, "three", "four", "five") != "threefourfive") :
raise RuntimeError("testfunc failed! {}")

View file

@ -9,6 +9,8 @@ if special_variable_macros.testJill(name) != "jilly":
raise "test failed"
if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
raise "test failed"
if special_variable_macros.testJames(name) != "SWIGTYPE_Name":
raise "test failed"
if special_variable_macros.testJim(name) != "multiname num":
raise "test failed"

View file

@ -23,10 +23,12 @@ except RuntimeError,e:
try:
t.hosed()
except threads_exception.Exc,e:
if e.code != 42:
raise RuntimeError
if e.msg != "Hosed":
raise RuntimeError, "bad... msg: %s" % e.msg
code = e.code
if code != 42:
raise RuntimeError, "bad... code: %d" % code
msg = e.msg
if msg != "Hosed":
raise RuntimeError, "bad... msg: '%s' len: %d" % (msg, len(msg))
for i in range(1,4):
try: