The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
64 changed files with 125431 additions and 43485 deletions
5
SWIG/Examples/test-suite/python/.cvsignore
Normal file
5
SWIG/Examples/test-suite/python/.cvsignore
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
*wrap*
|
||||
*.py
|
||||
*.pyc
|
||||
*.so
|
||||
*.dll
|
||||
44
SWIG/Examples/test-suite/python/Makefile
Normal file
44
SWIG/Examples/test-suite/python/Makefile
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#######################################################################
|
||||
# $Header$
|
||||
# Makefile for python test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = python
|
||||
SCRIPTSUFFIX = _runme.py
|
||||
|
||||
include ../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
TARGETSUFFIX =
|
||||
SWIGOPT = -I$(TOP)/$(TEST_SUITE)
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
$(setup) \
|
||||
($(swig_and_compile_cpp); ); \
|
||||
$(run_testcase)
|
||||
|
||||
%.ctest:
|
||||
$(setup) \
|
||||
($(swig_and_compile_c); ); \
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup) \
|
||||
($(swig_and_compile_multi_cpp); ); \
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.py appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $*\_runme.py ]; then ( \
|
||||
env LD_LIBRARY_PATH=$(DYNAMIC_LIB_PATH):$$LD_LIBRARY_PATH python $*\_runme.py;) \
|
||||
fi;
|
||||
|
||||
# Clean: remove the generated .py file
|
||||
%.clean:
|
||||
@rm -f $*.py;
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile python_clean
|
||||
|
||||
4
SWIG/Examples/test-suite/python/README
Normal file
4
SWIG/Examples/test-suite/python/README
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
See ../README for common README file.
|
||||
|
||||
Any testcases which have _runme.py appended after the testcase name will be detected and run.
|
||||
|
||||
11
SWIG/Examples/test-suite/python/abstract_typedef_runme.py
Normal file
11
SWIG/Examples/test-suite/python/abstract_typedef_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from abstract_typedef import *
|
||||
e = Engine()
|
||||
|
||||
a = A()
|
||||
|
||||
|
||||
if a.write(e) != 1:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
|
||||
6
SWIG/Examples/test-suite/python/class_ignore_runme.py
Normal file
6
SWIG/Examples/test-suite/python/class_ignore_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import class_ignore
|
||||
|
||||
a = class_ignore.Bar()
|
||||
|
||||
if class_ignore.do_blah(a) != "Bar::blah":
|
||||
raise RuntimeError
|
||||
38
SWIG/Examples/test-suite/python/constover_runme.py
Normal file
38
SWIG/Examples/test-suite/python/constover_runme.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
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)
|
||||
|
||||
|
||||
45
SWIG/Examples/test-suite/python/cpp_namespace_runme.py
Normal file
45
SWIG/Examples/test-suite/python/cpp_namespace_runme.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Note: This example assumes that namespaces are flattened
|
||||
import cpp_namespace
|
||||
|
||||
n = cpp_namespace.fact(4)
|
||||
if n != 24:
|
||||
raise "Bad return value!"
|
||||
|
||||
if cpp_namespace.cvar.Foo != 42:
|
||||
raise "Bad variable value!"
|
||||
|
||||
t = cpp_namespace.Test()
|
||||
if t.method() != "Test::method":
|
||||
raise "Bad method return value!"
|
||||
|
||||
if cpp_namespace.do_method(t) != "Test::method":
|
||||
raise "Bad return value!"
|
||||
|
||||
if cpp_namespace.do_method2(t) != "Test::method":
|
||||
raise "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 "Bad return value!"
|
||||
|
||||
if cpp_namespace.do_method3(t2,40) != "Test2::method":
|
||||
raise "Bad return value!"
|
||||
|
||||
if cpp_namespace.do_method3(t3,40) != "Test3::method":
|
||||
raise "Bad return value!"
|
||||
|
||||
if cpp_namespace.do_method3(t4,40) != "Test4::method":
|
||||
raise "Bad return value!"
|
||||
|
||||
if cpp_namespace.do_method3(t5,40) != "Test5::method":
|
||||
raise "Bad return value!"
|
||||
|
||||
|
||||
96
SWIG/Examples/test-suite/python/default_constructor_runme.py
Normal file
96
SWIG/Examples/test-suite/python/default_constructor_runme.py
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
import _default_constructor
|
||||
|
||||
dc = _default_constructor
|
||||
|
||||
a = dc.new_A
|
||||
del_a = dc.delete_A
|
||||
|
||||
aa = dc.new_AA
|
||||
del_aa = dc.delete_AA
|
||||
|
||||
b = dc.new_B
|
||||
del_b = dc.delete_B
|
||||
|
||||
try:
|
||||
bb = dc.new_BB;
|
||||
print "Whoa. new_BB created."
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_bb = dc.delete_BB
|
||||
|
||||
try:
|
||||
c = dc.new_C
|
||||
print "Whoa. new_C created."
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_c = dc.delete_C
|
||||
|
||||
cc = dc.new_CC
|
||||
del_cc = dc.delete_CC
|
||||
|
||||
try:
|
||||
d = dc.new_D;
|
||||
print "Whoa. new_D created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_d = dc.delete_D
|
||||
|
||||
try:
|
||||
dd = dc.new_DD
|
||||
print "Whoa. new_DD created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
dd = dc.delete_DD
|
||||
|
||||
try:
|
||||
ad = dc.new_AD
|
||||
print "Whoa. new_AD created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_ad = dc.delete_AD
|
||||
|
||||
e = dc.new_E
|
||||
del_e = dc.delete_E
|
||||
|
||||
ee = dc.new_EE
|
||||
del_ee = dc.delete_EE
|
||||
|
||||
try:
|
||||
eb = dc.new_EB
|
||||
print "Whoa. new_EB created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
del_eb = dc.delete_EB
|
||||
|
||||
f = dc.new_F
|
||||
|
||||
try:
|
||||
del_f = dc.delete_F
|
||||
print "Whoa. delete_F created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
ff = dc.new_FFF
|
||||
try:
|
||||
del_ff = dc.delete_FFF
|
||||
print "Whoa. delete_FFF created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
g = dc.new_G
|
||||
|
||||
try:
|
||||
del_g = dc.delete_G
|
||||
print "Whoa. delete_G created"
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
gg = dc.new_GG
|
||||
del_gg = dc.delete_GG
|
||||
|
||||
12
SWIG/Examples/test-suite/python/dynamic_cast_runme.py
Normal file
12
SWIG/Examples/test-suite/python/dynamic_cast_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
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!!"
|
||||
|
||||
7
SWIG/Examples/test-suite/python/enum_runme.py
Normal file
7
SWIG/Examples/test-suite/python/enum_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
|
||||
import _enum
|
||||
|
||||
_enum.bar2(1)
|
||||
_enum.bar3(1)
|
||||
_enum.bar1(1)
|
||||
|
||||
|
|
@ -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
|
||||
8
SWIG/Examples/test-suite/python/extend_template_runme.py
Normal file
8
SWIG/Examples/test-suite/python/extend_template_runme.py
Normal 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
|
||||
13
SWIG/Examples/test-suite/python/grouping_runme.py
Normal file
13
SWIG/Examples/test-suite/python/grouping_runme.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
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
|
||||
7
SWIG/Examples/test-suite/python/import_nomodule_runme.py
Normal file
7
SWIG/Examples/test-suite/python/import_nomodule_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from import_nomodule import *
|
||||
|
||||
f = create_Foo()
|
||||
test1(f,42)
|
||||
|
||||
b = Bar()
|
||||
test1(b,37)
|
||||
9
SWIG/Examples/test-suite/python/imports_runme.py
Normal file
9
SWIG/Examples/test-suite/python/imports_runme.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# This is the import runtime testcase.
|
||||
|
||||
import _imports_a
|
||||
import _imports_b
|
||||
import sys
|
||||
|
||||
x = _imports_b.new_B()
|
||||
_imports_a.A_hello(x)
|
||||
|
||||
17
SWIG/Examples/test-suite/python/inherit_missing_runme.py
Normal file
17
SWIG/Examples/test-suite/python/inherit_missing_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
17
SWIG/Examples/test-suite/python/lib_std_vector_runme.py
Normal file
17
SWIG/Examples/test-suite/python/lib_std_vector_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from lib_std_vector import *
|
||||
|
||||
iv = IntVector(4)
|
||||
for i in range(0,4):
|
||||
iv[i] = i
|
||||
|
||||
x = average(iv)
|
||||
y = average([1,2,3,4])
|
||||
|
||||
a = half([10,10.5,11,11.5])
|
||||
|
||||
dv = DoubleVector(10)
|
||||
for i in range(0,10):
|
||||
dv[i] = i/2.0
|
||||
|
||||
halve_in_place(dv)
|
||||
|
||||
71
SWIG/Examples/test-suite/python/minherit_runme.py
Normal file
71
SWIG/Examples/test-suite/python/minherit_runme.py
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
|
||||
import minherit
|
||||
|
||||
a = minherit.Foo()
|
||||
b = minherit.Bar()
|
||||
c = minherit.FooBar()
|
||||
d = minherit.Spam()
|
||||
|
||||
if a.xget() != 1:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if b.yget() != 2:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if c.xget() != 1 or c.yget() != 2 or c.zget() != 3:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if d.xget() != 1 or d.yget() != 2 or d.zget() != 3 or d.wget() != 4:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
|
||||
if minherit.xget(a) != 1:
|
||||
raise RuntimeError, "Bad attribute value %d" % (minherit.xget(a))
|
||||
|
||||
if minherit.yget(b) != 2:
|
||||
raise RuntimeError, "Bad attribute value %d" % (minherit.yget(b))
|
||||
|
||||
if minherit.xget(c) != 1 or minherit.yget(c) != 2 or minherit.zget(c) != 3:
|
||||
raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(c), minherit.yget(c), minherit.zget(c))
|
||||
|
||||
if minherit.xget(d) != 1 or minherit.yget(d) != 2 or minherit.zget(d) != 3 or minherit.wget(d) != 4:
|
||||
raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(d), minherit.yget(d), minherit.zget(d), minherit.wget(d))
|
||||
|
||||
# Cleanse all of the pointers and see what happens
|
||||
|
||||
aa = minherit.toFooPtr(a)
|
||||
bb = minherit.toBarPtr(b)
|
||||
cc = minherit.toFooBarPtr(c)
|
||||
dd = minherit.toSpamPtr(d)
|
||||
|
||||
if aa.xget() != 1:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if bb.yget() != 2:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if cc.xget() != 1 or cc.yget() != 2 or cc.zget() != 3:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if dd.xget() != 1 or dd.yget() != 2 or dd.zget() != 3 or dd.wget() != 4:
|
||||
raise RuntimeError, "Bad attribute value"
|
||||
|
||||
if minherit.xget(aa) != 1:
|
||||
raise RuntimeError, "Bad attribute value %d" % (minherit.xget(aa))
|
||||
|
||||
if minherit.yget(bb) != 2:
|
||||
raise RuntimeError, "Bad attribute value %d" % (minherit.yget(bb))
|
||||
|
||||
if minherit.xget(cc) != 1 or minherit.yget(cc) != 2 or minherit.zget(cc) != 3:
|
||||
raise RuntimeError, "Bad attribute value %d %d %d" % (minherit.xget(cc), minherit.yget(cc), minherit.zget(cc))
|
||||
|
||||
if minherit.xget(dd) != 1 or minherit.yget(dd) != 2 or minherit.zget(dd) != 3 or minherit.wget(dd) != 4:
|
||||
raise RuntimeError, "Bad attribute value %d %d %d %d" % (minherit.xget(dd), minherit.yget(dd), minherit.zget(dd), minherit.wget(dd))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
82
SWIG/Examples/test-suite/python/namespace_typemap_runme.py
Normal file
82
SWIG/Examples/test-suite/python/namespace_typemap_runme.py
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
from namespace_typemap import *
|
||||
|
||||
if stest1("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest2("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest3("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest4("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest5("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest6("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest7("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest8("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest9("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest10("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest11("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if stest12("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
c = complex(2,3)
|
||||
r = c.real
|
||||
|
||||
if ctest1(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest2(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest3(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest4(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest5(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest6(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest7(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest8(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest9(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest10(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest11(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
if ctest12(c) != r:
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
ttest1(-14)
|
||||
raise RuntimeError
|
||||
except ValueError:
|
||||
pass
|
||||
3
SWIG/Examples/test-suite/python/overload_copy_runme.py
Normal file
3
SWIG/Examples/test-suite/python/overload_copy_runme.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
from overload_copy import *
|
||||
f = Foo()
|
||||
g = Foo(f)
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue