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
1508 changed files with 125983 additions and 44037 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)
|
||||
11
SWIG/Examples/test-suite/python/overload_extend_runme.py
Normal file
11
SWIG/Examples/test-suite/python/overload_extend_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import overload_extend
|
||||
|
||||
f = overload_extend.Foo()
|
||||
if f.test(3) != 1:
|
||||
raise RuntimeError
|
||||
if f.test("hello") != 2:
|
||||
raise RuntimeError
|
||||
if f.test(3.5,2.5) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
11
SWIG/Examples/test-suite/python/overload_extendc_runme.py
Normal file
11
SWIG/Examples/test-suite/python/overload_extendc_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import overload_extend
|
||||
|
||||
f = overload_extend.Foo()
|
||||
if f.test(3) != 1:
|
||||
raise RuntimeError
|
||||
if f.test("hello") != 2:
|
||||
raise RuntimeError
|
||||
if f.test(3.5,2.5) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
97
SWIG/Examples/test-suite/python/overload_simple_runme.py
Normal file
97
SWIG/Examples/test-suite/python/overload_simple_runme.py
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
from overload_simple import *
|
||||
|
||||
if foo(3) != "foo:int":
|
||||
raise RuntimeError, "foo(int)"
|
||||
|
||||
if foo(3.0) != "foo:double":
|
||||
raise RuntimeError, "foo(double)"
|
||||
|
||||
if foo("hello") != "foo:char *":
|
||||
raise RuntimeError, "foo(char *)"
|
||||
|
||||
f = Foo()
|
||||
b = Bar()
|
||||
|
||||
if foo(f) != "foo:Foo *":
|
||||
raise RuntimeError, "foo(Foo *)"
|
||||
|
||||
if foo(b) != "foo:Bar *":
|
||||
raise RuntimeError, "foo(Bar *)"
|
||||
|
||||
v = malloc_void(32)
|
||||
|
||||
if foo(v) != "foo:void *":
|
||||
raise RuntimeError, "foo(void *)"
|
||||
|
||||
s = Spam()
|
||||
|
||||
if s.foo(3) != "foo:int":
|
||||
raise RuntimeError, "Spam::foo(int)"
|
||||
|
||||
if s.foo(3.0) != "foo:double":
|
||||
raise RuntimeError, "Spam::foo(double)"
|
||||
|
||||
if s.foo("hello") != "foo:char *":
|
||||
raise RuntimeError, "Spam::foo(char *)"
|
||||
|
||||
if s.foo(f) != "foo:Foo *":
|
||||
raise RuntimeError, "Spam::foo(Foo *)"
|
||||
|
||||
if s.foo(b) != "foo:Bar *":
|
||||
raise RuntimeError, "Spam::foo(Bar *)"
|
||||
|
||||
if s.foo(v) != "foo:void *":
|
||||
raise RuntimeError, "Spam::foo(void *)"
|
||||
|
||||
if Spam_bar(3) != "bar:int":
|
||||
raise RuntimeError, "Spam::bar(int)"
|
||||
|
||||
if Spam_bar(3.0) != "bar:double":
|
||||
raise RuntimeError, "Spam::bar(double)"
|
||||
|
||||
if Spam_bar("hello") != "bar:char *":
|
||||
raise RuntimeError, "Spam::bar(char *)"
|
||||
|
||||
if Spam_bar(f) != "bar:Foo *":
|
||||
raise RuntimeError, "Spam::bar(Foo *)"
|
||||
|
||||
if Spam_bar(b) != "bar:Bar *":
|
||||
raise RuntimeError, "Spam::bar(Bar *)"
|
||||
|
||||
if Spam_bar(v) != "bar:void *":
|
||||
raise RuntimeError, "Spam::bar(void *)"
|
||||
|
||||
# Test constructors
|
||||
|
||||
s = Spam()
|
||||
if s.type != "none":
|
||||
raise RuntimeError, "Spam()"
|
||||
|
||||
s = Spam(3)
|
||||
if s.type != "int":
|
||||
raise RuntimeError, "Spam(int)"
|
||||
|
||||
s = Spam(3.4)
|
||||
if s.type != "double":
|
||||
raise RuntimeError, "Spam(double)"
|
||||
|
||||
s = Spam("hello")
|
||||
if s.type != "char *":
|
||||
raise RuntimeError, "Spam(char *)"
|
||||
|
||||
s = Spam(f)
|
||||
if s.type != "Foo *":
|
||||
raise RuntimeError, "Spam(Foo *)"
|
||||
|
||||
s = Spam(b)
|
||||
if s.type != "Bar *":
|
||||
raise RuntimeError, "Spam(Bar *)"
|
||||
|
||||
s = Spam(v)
|
||||
if s.type != "void *":
|
||||
raise RuntimeError, "Spam(void *)"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
SWIG/Examples/test-suite/python/overload_subtype_runme.py
Normal file
11
SWIG/Examples/test-suite/python/overload_subtype_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from overload_subtype import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar()
|
||||
|
||||
if spam(f) != 1:
|
||||
raise RuntimeError, "foo"
|
||||
|
||||
if spam(b) != 2:
|
||||
raise RuntimeError, "bar"
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from overload_template import *
|
||||
f = foo()
|
||||
|
||||
a = max(3,4)
|
||||
b = max(3.4,5.2)
|
||||
37
SWIG/Examples/test-suite/python/primitive_ref_runme.py
Normal file
37
SWIG/Examples/test-suite/python/primitive_ref_runme.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
from primitive_ref import *
|
||||
|
||||
if ref_int(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_uint(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_short(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_ushort(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_long(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_ulong(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_schar(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_uchar(3) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_float(3.5) != 3.5:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_double(3.5) != 3.5:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_bool(1) != 1:
|
||||
raise RuntimeError
|
||||
|
||||
if ref_char('x') != 'x':
|
||||
raise RuntimeError
|
||||
10
SWIG/Examples/test-suite/python/rename_scope_runme.py
Normal file
10
SWIG/Examples/test-suite/python/rename_scope_runme.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from rename_scope import *
|
||||
|
||||
a = Natural_UP()
|
||||
b = Natural_BP()
|
||||
|
||||
if a.rtest() != 1:
|
||||
raise RuntimeError
|
||||
|
||||
if b.rtest() != 1:
|
||||
raise RuntimeError
|
||||
15
SWIG/Examples/test-suite/python/smart_pointer_multi_runme.py
Normal file
15
SWIG/Examples/test-suite/python/smart_pointer_multi_runme.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
from smart_pointer_multi import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
s = Spam(b)
|
||||
g = Grok(b)
|
||||
|
||||
s.x = 3
|
||||
if s.getx() != 3:
|
||||
raise RuntimeError
|
||||
|
||||
g.x = 4
|
||||
if g.getx() != 4:
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from smart_pointer_multi_typedef import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
s = Spam(b)
|
||||
g = Grok(b)
|
||||
|
||||
s.x = 3
|
||||
if s.getx() != 3:
|
||||
raise RuntimeError
|
||||
|
||||
g.x = 4
|
||||
if g.getx() != 4:
|
||||
raise RuntimeError
|
||||
|
||||
42
SWIG/Examples/test-suite/python/smart_pointer_not_runme.py
Normal file
42
SWIG/Examples/test-suite/python/smart_pointer_not_runme.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
from smart_pointer_not import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
s = Spam(f)
|
||||
g = Grok(f)
|
||||
|
||||
try:
|
||||
x = b.x
|
||||
print "Error! b.x"
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
x = s.x
|
||||
print "Error! s.x"
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
x = g.x
|
||||
print "Error! g.x"
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
x = b.getx()
|
||||
print "Error! b.getx()"
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
x = s.getx()
|
||||
print "Error! s.getx()"
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
x = g.getx()
|
||||
print "Error! g.getx()"
|
||||
except:
|
||||
pass
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
from smart_pointer_overload import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
|
||||
|
||||
if f.test(3) != 1:
|
||||
raise RuntimeError
|
||||
if f.test(3.5) != 2:
|
||||
raise RuntimeError
|
||||
if f.test("hello") != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if b.test(3) != 1:
|
||||
raise RuntimeError
|
||||
if b.test(3.5) != 2:
|
||||
raise RuntimeError
|
||||
if b.test("hello") != 3:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from smart_pointer_rename import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
|
||||
if b.test() != 3:
|
||||
raise RuntimeError
|
||||
|
||||
if b.ftest1(1) != 1:
|
||||
raise RuntimeError
|
||||
|
||||
if b.ftest2(2,3) != 2:
|
||||
raise RuntimeError
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from smart_pointer_simple import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
|
||||
b.x = 3
|
||||
if b.getx() != 3:
|
||||
raise RuntimeError
|
||||
|
||||
fp = b.__deref__()
|
||||
fp.x = 4
|
||||
if fp.getx() != 4:
|
||||
raise RuntimeError
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
from smart_pointer_typedef import *
|
||||
|
||||
f = Foo()
|
||||
b = Bar(f)
|
||||
|
||||
b.x = 3
|
||||
if b.getx() != 3:
|
||||
raise RuntimeError
|
||||
|
||||
fp = b.__deref__()
|
||||
fp.x = 4
|
||||
if fp.getx() != 4:
|
||||
raise RuntimeError
|
||||
5
SWIG/Examples/test-suite/python/sneaky1_runme.py
Normal file
5
SWIG/Examples/test-suite/python/sneaky1_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import sneaky1
|
||||
x = sneaky1.add(3,4)
|
||||
y = sneaky1.sub(3,4)
|
||||
z = sneaky1.mul(3,4)
|
||||
w = sneaky1.divide(3,4)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
from static_const_member_2 import *
|
||||
|
||||
c = Test_int()
|
||||
try:
|
||||
a = c.forward_field
|
||||
a = c.current_profile
|
||||
a = c.RightIndex
|
||||
a = Test_int.backward_field
|
||||
a = Test_int.LeftIndex
|
||||
a = Test_int.cavity_flags
|
||||
except:
|
||||
print "Failed!!"
|
||||
|
||||
|
||||
|
||||
9
SWIG/Examples/test-suite/python/struct_value_runme.py
Normal file
9
SWIG/Examples/test-suite/python/struct_value_runme.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import struct_value
|
||||
|
||||
b = struct_value.Bar()
|
||||
|
||||
b.a.x = 3
|
||||
if b.a.x != 3: raise RuntimeError
|
||||
|
||||
b.b.x = 3
|
||||
if b.b.x != 3: raise RuntimeError
|
||||
|
|
@ -0,0 +1 @@
|
|||
import template_construct
|
||||
53
SWIG/Examples/test-suite/python/template_inherit_runme.py
Normal file
53
SWIG/Examples/test-suite/python/template_inherit_runme.py
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
from template_inherit import *
|
||||
a = FooInt()
|
||||
b = FooDouble()
|
||||
c = BarInt()
|
||||
d = BarDouble()
|
||||
e = FooUInt()
|
||||
f = BarUInt()
|
||||
|
||||
if a.blah() != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if b.blah() != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if e.blah() != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if c.blah() != "Bar":
|
||||
raise ValueError
|
||||
|
||||
if d.blah() != "Bar":
|
||||
raise ValueError
|
||||
|
||||
if f.blah() != "Bar":
|
||||
raise ValueError
|
||||
|
||||
if c.foomethod() != "foomethod":
|
||||
raise ValueError
|
||||
|
||||
if d.foomethod() != "foomethod":
|
||||
raise ValueError
|
||||
|
||||
if f.foomethod() != "foomethod":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_int(a) != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_int(c) != "Bar":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_double(b) != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_double(d) != "Bar":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_uint(e) != "Foo":
|
||||
raise ValueError
|
||||
|
||||
if invoke_blah_uint(f) != "Bar":
|
||||
raise ValueError
|
||||
|
||||
5
SWIG/Examples/test-suite/python/template_ns4_runme.py
Normal file
5
SWIG/Examples/test-suite/python/template_ns4_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from template_ns4 import *
|
||||
|
||||
d = make_Class_DD();
|
||||
if d.test() != "test":
|
||||
raise RuntimeError
|
||||
17
SWIG/Examples/test-suite/python/template_ns_runme.py
Normal file
17
SWIG/Examples/test-suite/python/template_ns_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from template_ns import *
|
||||
p1 = pairii(2,3)
|
||||
p2 = pairii(p1)
|
||||
|
||||
if p2.first != 2:
|
||||
raise RuntimeError
|
||||
if p2.second != 3:
|
||||
raise RuntimeError
|
||||
|
||||
p3 = pairdd(3.5,2.5)
|
||||
p4 = pairdd(p3)
|
||||
|
||||
if p4.first != 3.5:
|
||||
raise RuntimeError
|
||||
|
||||
if p4.second != 2.5:
|
||||
raise RuntimeError
|
||||
12
SWIG/Examples/test-suite/python/template_rename_runme.py
Normal file
12
SWIG/Examples/test-suite/python/template_rename_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import template_rename
|
||||
|
||||
i = template_rename.iFoo()
|
||||
d = template_rename.dFoo()
|
||||
|
||||
a = i.blah_test(4)
|
||||
b = i.spam_test(5)
|
||||
c = i.grok_test(6)
|
||||
|
||||
x = d.blah_test(7)
|
||||
y = d.spam(8)
|
||||
z = d.grok_test(9)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from template_tbase_template import *
|
||||
|
||||
a = make_Class_dd()
|
||||
if a.test() != "test":
|
||||
raise RuntimeError
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
from template_type_namespace import *
|
||||
|
||||
if type(foo()[0]) != type(""):
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
import string
|
||||
from template_typedef_cplx2 import *
|
||||
|
||||
#
|
||||
# double case
|
||||
#
|
||||
|
||||
try:
|
||||
d = make_Identity_double()
|
||||
a = d.this
|
||||
except:
|
||||
print d, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % d)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print d, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
e = make_Multiplies_double_double_double_double(d, d)
|
||||
a = e.this
|
||||
except:
|
||||
print e, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % e)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print e, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
#
|
||||
# complex case
|
||||
#
|
||||
|
||||
try:
|
||||
c = make_Identity_complex()
|
||||
a = c.this
|
||||
except:
|
||||
print c, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % c)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print c, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
f = make_Multiplies_complex_complex_complex_complex(c, c)
|
||||
a = f.this
|
||||
except:
|
||||
print f, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % f)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print f, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
#
|
||||
# Mix case
|
||||
#
|
||||
|
||||
try:
|
||||
g = make_Multiplies_double_double_complex_complex(d, c)
|
||||
a = g.this
|
||||
except:
|
||||
print g, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % g)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
try:
|
||||
h = make_Multiplies_complex_complex_double_double(c, d)
|
||||
a = h.this
|
||||
except:
|
||||
print h, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % g)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
a = g.get_value()
|
||||
except:
|
||||
print g, "has not get_value() method"
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import string
|
||||
from template_typedef_cplx3 import *
|
||||
|
||||
#
|
||||
# this is OK
|
||||
#
|
||||
|
||||
|
||||
s = Sin()
|
||||
s.get_base_value()
|
||||
s.get_value()
|
||||
s.get_arith_value()
|
||||
my_func_r(s)
|
||||
make_Multiplies_double_double_double_double(s,s)
|
||||
|
||||
z = CSin()
|
||||
z.get_base_value()
|
||||
z.get_value()
|
||||
z.get_arith_value()
|
||||
my_func_c(z)
|
||||
make_Multiplies_complex_complex_complex_complex(z,z)
|
||||
|
||||
#
|
||||
# Here we fail
|
||||
#
|
||||
d = make_Identity_double()
|
||||
my_func_r(d)
|
||||
|
||||
c = make_Identity_complex()
|
||||
my_func_c(c)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
import string
|
||||
from template_typedef_cplx4 import *
|
||||
|
||||
#
|
||||
# this is OK
|
||||
#
|
||||
|
||||
|
||||
s = Sin()
|
||||
s.get_base_value()
|
||||
s.get_value()
|
||||
s.get_arith_value()
|
||||
my_func_r(s)
|
||||
make_Multiplies_double_double_double_double(s,s)
|
||||
|
||||
z = CSin()
|
||||
z.get_base_value()
|
||||
z.get_value()
|
||||
z.get_arith_value()
|
||||
my_func_c(z)
|
||||
make_Multiplies_complex_complex_complex_complex(z,z)
|
||||
|
||||
#
|
||||
# Here we fail
|
||||
#
|
||||
d = make_Identity_double()
|
||||
my_func_r(d)
|
||||
|
||||
c = make_Identity_complex()
|
||||
my_func_c(c)
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
import string
|
||||
from template_typedef_cplx import *
|
||||
|
||||
#
|
||||
# double case
|
||||
#
|
||||
|
||||
try:
|
||||
d = make_Identity_double()
|
||||
a = d.this
|
||||
except:
|
||||
print d, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % d)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print d, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
e = make_Multiplies_double_double_double_double(d, d)
|
||||
a = e.this
|
||||
except:
|
||||
print e, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % e)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print e, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
#
|
||||
# complex case
|
||||
#
|
||||
|
||||
try:
|
||||
c = make_Identity_complex()
|
||||
a = c.this
|
||||
except:
|
||||
print c, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % c)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print c, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
f = make_Multiplies_complex_complex_complex_complex(c, c)
|
||||
a = f.this
|
||||
except:
|
||||
print f, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % f)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print f, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
#
|
||||
# Mix case
|
||||
#
|
||||
|
||||
try:
|
||||
g = make_Multiplies_double_double_complex_complex(d, c)
|
||||
a = g.this
|
||||
except:
|
||||
print g, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % g)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
try:
|
||||
h = make_Multiplies_complex_complex_double_double(c, d)
|
||||
a = h.this
|
||||
except:
|
||||
print h, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
s = string.split('%s' % g)[1]
|
||||
if string.find(s, 'ArithUnaryFunction') == -1:
|
||||
print g, "is not an ArithUnaryFunction"
|
||||
raise RuntimeError
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import string
|
||||
from template_typedef_cplx2 import *
|
||||
from template_typedef_import import *
|
||||
|
||||
#
|
||||
# this is OK
|
||||
#
|
||||
|
||||
|
||||
s = Sin()
|
||||
s.get_base_value()
|
||||
s.get_value()
|
||||
s.get_arith_value()
|
||||
my_func_r(s)
|
||||
make_Multiplies_double_double_double_double(s,s)
|
||||
|
||||
z = CSin()
|
||||
z.get_base_value()
|
||||
z.get_value()
|
||||
z.get_arith_value()
|
||||
my_func_c(z)
|
||||
make_Multiplies_complex_complex_complex_complex(z,z)
|
||||
|
||||
#
|
||||
# Here we fail
|
||||
#
|
||||
d = make_Identity_double()
|
||||
my_func_r(d)
|
||||
|
||||
c = make_Identity_complex()
|
||||
my_func_c(c)
|
||||
|
||||
|
||||
|
||||
|
||||
33
SWIG/Examples/test-suite/python/template_typedef_runme.py
Normal file
33
SWIG/Examples/test-suite/python/template_typedef_runme.py
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
from template_typedef import *
|
||||
|
||||
d = make_Identity_float()
|
||||
c = make_Identity_real()
|
||||
|
||||
|
||||
try:
|
||||
a = d.this
|
||||
a = c.this
|
||||
except:
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
e = make_Multiplies_float_float_float_float(d, d)
|
||||
a = e.this
|
||||
except:
|
||||
print e, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
f = make_Multiplies_real_real_real_real(c, c)
|
||||
a = f.this
|
||||
except:
|
||||
print f, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
try:
|
||||
g = make_Multiplies_float_float_real_real(d, c)
|
||||
a = g.this
|
||||
except:
|
||||
print g, "is not an instance"
|
||||
raise RuntimeError
|
||||
|
||||
23
SWIG/Examples/test-suite/python/typedef_inherit_runme.py
Normal file
23
SWIG/Examples/test-suite/python/typedef_inherit_runme.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import typedef_inherit
|
||||
|
||||
a = typedef_inherit.Foo()
|
||||
b = typedef_inherit.Bar()
|
||||
|
||||
x = typedef_inherit.do_blah(a)
|
||||
if x != "Foo::blah":
|
||||
print "Whoa! Bad return", x
|
||||
|
||||
x = typedef_inherit.do_blah(b)
|
||||
if x != "Bar::blah":
|
||||
print "Whoa! Bad return", x
|
||||
|
||||
c = typedef_inherit.Spam()
|
||||
d = typedef_inherit.Grok()
|
||||
|
||||
x = typedef_inherit.do_blah2(c)
|
||||
if x != "Spam::blah":
|
||||
print "Whoa! Bad return", x
|
||||
|
||||
x = typedef_inherit.do_blah2(d)
|
||||
if x != "Grok::blah":
|
||||
print "Whoa! Bad return", x
|
||||
12
SWIG/Examples/test-suite/python/typedef_scope_runme.py
Normal file
12
SWIG/Examples/test-suite/python/typedef_scope_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import typedef_scope
|
||||
|
||||
b = typedef_scope.Bar()
|
||||
x = b.test1(42,"hello")
|
||||
if x != 42:
|
||||
print "Failed!!"
|
||||
|
||||
x = b.test2(42,"hello")
|
||||
if x != "hello":
|
||||
print "Failed!!"
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
from typemap_namespace import *
|
||||
|
||||
if test1("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
if test2("hello") != "hello":
|
||||
raise RuntimeError
|
||||
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
import typemap_ns_using
|
||||
|
||||
if typemap_ns_using.spam(37) != 37:
|
||||
raise RuntimeError
|
||||
12
SWIG/Examples/test-suite/python/typename_runme.py
Normal file
12
SWIG/Examples/test-suite/python/typename_runme.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import typename
|
||||
import types
|
||||
f = typename.Foo()
|
||||
b = typename.Bar()
|
||||
|
||||
x = typename.twoFoo(f)
|
||||
if not isinstance(x,types.FloatType):
|
||||
print "Wrong return type!"
|
||||
y = typename.twoBar(b)
|
||||
if not isinstance(y,types.IntType):
|
||||
print "Wrong return type!"
|
||||
|
||||
51
SWIG/Examples/test-suite/python/unions_runme.py
Normal file
51
SWIG/Examples/test-suite/python/unions_runme.py
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
|
||||
# This is the union runtime testcase. It ensures that values within a
|
||||
# union embedded within a struct can be set and read correctly.
|
||||
|
||||
import unions
|
||||
import sys
|
||||
import string
|
||||
|
||||
# Create new instances of SmallStruct and BigStruct for later use
|
||||
small = unions.SmallStruct()
|
||||
small.jill = 200
|
||||
|
||||
big = unions.BigStruct()
|
||||
big.smallstruct = small
|
||||
big.jack = 300
|
||||
|
||||
# Use SmallStruct then BigStruct to setup EmbeddedUnionTest.
|
||||
# Ensure values in EmbeddedUnionTest are set correctly for each.
|
||||
eut = unions.EmbeddedUnionTest()
|
||||
|
||||
# First check the SmallStruct in EmbeddedUnionTest
|
||||
eut.number = 1
|
||||
eut.uni.small = small
|
||||
Jill1 = eut.uni.small.jill
|
||||
if (Jill1 != 200):
|
||||
print "Runtime test1 failed. eut.uni.small.jill=" , Jill1
|
||||
sys.exit(1)
|
||||
|
||||
Num1 = eut.number
|
||||
if (Num1 != 1):
|
||||
print "Runtime test2 failed. eut.number=" , Num1
|
||||
sys.exit(1)
|
||||
|
||||
# Secondly check the BigStruct in EmbeddedUnionTest
|
||||
eut.number = 2
|
||||
eut.uni.big = big
|
||||
Jack1 = eut.uni.big.jack
|
||||
if (Jack1 != 300):
|
||||
print "Runtime test3 failed. eut.uni.big.jack=" , Jack1
|
||||
sys.exit(1)
|
||||
|
||||
Jill2 = eut.uni.big.smallstruct.jill
|
||||
if (Jill2 != 200):
|
||||
print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2
|
||||
sys.exit(1)
|
||||
|
||||
Num2 = eut.number
|
||||
if (Num2 != 2):
|
||||
print "Runtime test5 failed. eut.number=" , Num2
|
||||
sys.exit(1)
|
||||
|
||||
4
SWIG/Examples/test-suite/python/using1_runme.py
Normal file
4
SWIG/Examples/test-suite/python/using1_runme.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import using1
|
||||
|
||||
if using1.spam(37) != 37:
|
||||
raise RuntimeError
|
||||
4
SWIG/Examples/test-suite/python/using2_runme.py
Normal file
4
SWIG/Examples/test-suite/python/using2_runme.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
import using2
|
||||
|
||||
if using2.spam(37) != 37:
|
||||
raise RuntimeError
|
||||
11
SWIG/Examples/test-suite/python/using_composition_runme.py
Normal file
11
SWIG/Examples/test-suite/python/using_composition_runme.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from using_composition import *
|
||||
|
||||
f = FooBar()
|
||||
if f.blah(3) != 3:
|
||||
raise RuntimeError,"blah(int)"
|
||||
|
||||
if f.blah(3.5) != 3.5:
|
||||
raise RuntimeError,"blah(double)"
|
||||
|
||||
if f.blah("hello") != "hello":
|
||||
raise RuntimeError,"blah(char *)"
|
||||
17
SWIG/Examples/test-suite/python/using_extend_runme.py
Normal file
17
SWIG/Examples/test-suite/python/using_extend_runme.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
from using_extend import *
|
||||
|
||||
f = FooBar()
|
||||
if f.blah(3) != 3:
|
||||
raise RuntimeError,"blah(int)"
|
||||
|
||||
if f.blah(3.5) != 3.5:
|
||||
raise RuntimeError,"blah(double)"
|
||||
|
||||
if f.blah("hello") != "hello":
|
||||
raise RuntimeError,"blah(char *)"
|
||||
|
||||
if f.blah(3,4) != 7:
|
||||
raise RuntimeError,"blah(int,int)"
|
||||
|
||||
if f.blah(3.5,7.5) != (3.5+7.5):
|
||||
raise RuntimeError,"blah(double,double)"
|
||||
8
SWIG/Examples/test-suite/python/using_inherit_runme.py
Normal file
8
SWIG/Examples/test-suite/python/using_inherit_runme.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
from using_inherit import *
|
||||
|
||||
b = Bar()
|
||||
if b.test(3) != 3:
|
||||
raise RuntimeError,"test(int)"
|
||||
|
||||
if b.test(3.5) != 3.5:
|
||||
raise RuntimeError, "test(double)"
|
||||
7
SWIG/Examples/test-suite/python/using_private_runme.py
Normal file
7
SWIG/Examples/test-suite/python/using_private_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from using_private import *
|
||||
|
||||
f = FooBar()
|
||||
f.x = 3
|
||||
|
||||
if f.blah(4) != 4:
|
||||
raise RuntimeError, "blah(int)"
|
||||
7
SWIG/Examples/test-suite/python/using_protected_runme.py
Normal file
7
SWIG/Examples/test-suite/python/using_protected_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
from using_protected import *
|
||||
|
||||
f = FooBar()
|
||||
f.x = 3
|
||||
|
||||
if f.blah(4) != 4:
|
||||
raise RuntimeError, "blah(int)"
|
||||
7
SWIG/Examples/test-suite/python/voidtest_runme.py
Normal file
7
SWIG/Examples/test-suite/python/voidtest_runme.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import voidtest
|
||||
|
||||
voidtest.globalfunc()
|
||||
f = voidtest.Foo()
|
||||
f.memberfunc()
|
||||
|
||||
voidtest.Foo_staticmemberfunc()
|
||||
Loading…
Add table
Add a link
Reference in a new issue