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

This commit is contained in:
Sylvestre Ledru 2013-09-13 09:18:06 +02:00
commit 9c5bac9887
83 changed files with 2913 additions and 7441 deletions

View file

@ -58,7 +58,7 @@ CPP_TEST_CASES += \
li_std_wstream \
li_std_wstring \
primitive_types \
python_abstractbase \
python_abstractbase \
python_append \
python_director \
python_nondynamic \
@ -165,6 +165,9 @@ endif
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile 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'

View file

@ -11,6 +11,14 @@ 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))
@ -71,3 +79,47 @@ try:
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

@ -13,6 +13,12 @@ if li_std_wstring.test_ccvalue(x) != x:
if li_std_wstring.test_cvalue(x) != x:
raise RuntimeError("bad string mapping")
if li_std_wstring.test_wchar_overload(x) != x:
raise RuntimeError("bad string mapping")
if li_std_wstring.test_wchar_overload("not unicode") != "not unicode":
raise RuntimeError("bad string mapping")
if li_std_wstring.test_value(x) != x:
print x, li_std_wstring.test_value(x)
raise RuntimeError("bad string mapping")

View file

@ -0,0 +1,43 @@
from overload_numeric import *
import math
nums = Nums()
limits = Limits()
def check(got, expected):
if got != expected:
raise RuntimeError("got: " + got + " expected: " + expected)
check(nums.over(0), "signed char")
check(nums.over(0.0), "float")
check(nums.over(limits.schar_min()), "signed char")
check(nums.over(limits.schar_max()), "signed char")
check(nums.over(limits.schar_min()-1), "short")
check(nums.over(limits.schar_max()+1), "short")
check(nums.over(limits.shrt_min()), "short")
check(nums.over(limits.shrt_max()), "short")
check(nums.over(limits.shrt_min()-1), "int")
check(nums.over(limits.shrt_max()+1), "int")
check(nums.over(limits.int_min()), "int")
check(nums.over(limits.int_max()), "int")
check(nums.over(limits.flt_min()), "float")
check(nums.over(limits.flt_max()), "float")
check(nums.over(limits.flt_max()*10), "double")
check(nums.over(-limits.flt_max()*10), "double")
check(nums.over(limits.dbl_max()), "double")
check(nums.over(-limits.dbl_max()), "double")
check(nums.over(float("inf")), "float")
check(nums.over(float("-inf")), "float")
check(nums.over(float("nan")), "float")
# Just check if the following are accepted without exceptions being thrown
nums.doublebounce(float("inf"))
nums.doublebounce(float("-inf"))
nums.doublebounce(float("nan"))

View file

@ -2,3 +2,10 @@ from python_append import *
t=Test()
t.func()
t.static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError
if grabstaticpath() != os.path.basename(mypath):
raise RuntimeError