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
3
SWIG/Examples/test-suite/ruby/.cvsignore
Normal file
3
SWIG/Examples/test-suite/ruby/.cvsignore
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
*wrap*
|
||||
*.so
|
||||
*.dll
|
||||
41
SWIG/Examples/test-suite/ruby/Makefile
Normal file
41
SWIG/Examples/test-suite/ruby/Makefile
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#######################################################################
|
||||
# $Header$
|
||||
# Makefile for ruby test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = ruby
|
||||
SCRIPTSUFFIX = _runme.rb
|
||||
|
||||
include ../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
|
||||
# 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.rb appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $*\_runme.rb ]; then ( \
|
||||
ruby $*\_runme.rb;) \
|
||||
fi;
|
||||
|
||||
# Clean
|
||||
%.clean:
|
||||
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile ruby_clean
|
||||
4
SWIG/Examples/test-suite/ruby/README
Normal file
4
SWIG/Examples/test-suite/ruby/README
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
See ../README for common README file.
|
||||
|
||||
Any testcases which have _runme.rb appended after the testcase name will be detected and run.
|
||||
|
||||
10
SWIG/Examples/test-suite/ruby/class_ignore_runme.rb
Executable file
10
SWIG/Examples/test-suite/ruby/class_ignore_runme.rb
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
require 'class_ignore'
|
||||
|
||||
a = Class_ignore::Bar.new
|
||||
|
||||
# Even though we didn't wrap the Foo class, this call
|
||||
# to do_blah() should succeed.
|
||||
|
||||
if Class_ignore.do_blah(a) != "Bar::blah"
|
||||
raise RuntimeError
|
||||
end
|
||||
44
SWIG/Examples/test-suite/ruby/constover_runme.rb
Executable file
44
SWIG/Examples/test-suite/ruby/constover_runme.rb
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
require 'constover'
|
||||
|
||||
error = 0
|
||||
|
||||
p = Constover.test("test")
|
||||
if p != "test"
|
||||
puts "test failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
p = Constover.test_pconst("test")
|
||||
if p != "test_pconst"
|
||||
puts "test_pconst failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
f = Constover::Foo.new
|
||||
p = f.test("test")
|
||||
if p != "test"
|
||||
print "member-test failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
p = f.test_pconst("test")
|
||||
if p != "test_pconst"
|
||||
print "member-test_pconst failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
p = f.test_constm("test")
|
||||
if p != "test_constmethod"
|
||||
print "member-test_constm failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
p = f.test_pconstm("test")
|
||||
if p != "test_pconstmethod"
|
||||
print "member-test_pconstm failed!"
|
||||
error = 1
|
||||
end
|
||||
|
||||
exit(error)
|
||||
|
||||
|
||||
51
SWIG/Examples/test-suite/ruby/cpp_namespace_runme.rb
Executable file
51
SWIG/Examples/test-suite/ruby/cpp_namespace_runme.rb
Executable file
|
|
@ -0,0 +1,51 @@
|
|||
# Note: This example assumes that namespaces are flattened
|
||||
require 'cpp_namespace'
|
||||
|
||||
n = Cpp_namespace.fact(4)
|
||||
if n != 24
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.Foo != 42
|
||||
raise "Bad variable value!"
|
||||
end
|
||||
|
||||
t = Cpp_namespace::Test.new
|
||||
if t.method() != "Test::method"
|
||||
raise "Bad method return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method(t) != "Test::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method2(t) != "Test::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
Cpp_namespace.weird("hello", 4)
|
||||
|
||||
t2 = Cpp_namespace::Test2.new
|
||||
t3 = Cpp_namespace::Test3.new
|
||||
t4 = Cpp_namespace::Test4.new
|
||||
t5 = Cpp_namespace::Test5.new
|
||||
|
||||
if Cpp_namespace.foo3(42) != 42
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method3(t2, 40) != "Test2::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method3(t3, 40) != "Test3::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method3(t4, 40) != "Test4::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
|
||||
if Cpp_namespace.do_method3(t5, 40) != "Test5::method"
|
||||
raise "Bad return value!"
|
||||
end
|
||||
94
SWIG/Examples/test-suite/ruby/default_constructor_runme.rb
Executable file
94
SWIG/Examples/test-suite/ruby/default_constructor_runme.rb
Executable file
|
|
@ -0,0 +1,94 @@
|
|||
require 'default_constructor'
|
||||
|
||||
include Default_constructor
|
||||
|
||||
# Ruby 1.6 raises NameError if you try to call Class.new where no constructor
|
||||
# is defined; Ruby 1.7 changed this to NoMethodError
|
||||
|
||||
NoConstructorError = Kernel.const_defined?("NoMethodError") ? NoMethodError : NameError
|
||||
|
||||
# This should be no problem
|
||||
a = A.new
|
||||
|
||||
# Nor should this
|
||||
aa = AA.new
|
||||
|
||||
# The default constructor for B is private, so this should raise an exception
|
||||
begin
|
||||
b = B.new
|
||||
rescue ArgumentError
|
||||
# pass
|
||||
end
|
||||
|
||||
# The two-argument constructor for B should work
|
||||
b = B.new(3, 4)
|
||||
|
||||
# BB shouldn't inherit B's default constructor, so this should raise an exception
|
||||
begin
|
||||
bb = BB.new
|
||||
puts "Whoa. new BB created."
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# C's constructor is protected, so this should raise an exception
|
||||
begin
|
||||
c = C.new
|
||||
print "Whoa. new C created."
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# CC gets a default constructor, so no problem here
|
||||
cc = CC.new
|
||||
|
||||
# D's constructor is private, so this should fail
|
||||
begin
|
||||
d = D.new
|
||||
puts "Whoa. new D created"
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# DD shouldn't get a default constructor, so this should fail
|
||||
begin
|
||||
dd = DD.new
|
||||
puts "Whoa. new DD created"
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# AD shouldn't get a default constructor, so this should fail
|
||||
begin
|
||||
ad = AD.new
|
||||
puts "Whoa. new AD created"
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# Both of the arguments to E's constructor have default values,
|
||||
# so this should be fine.
|
||||
e = E.new
|
||||
|
||||
# EE should get a default constructor
|
||||
ee = EE.new
|
||||
|
||||
# EB should not get a default constructor (because B doesn't have one)
|
||||
begin
|
||||
eb = EB.new
|
||||
puts "Whoa. new EB created"
|
||||
rescue NoConstructorError
|
||||
# pass
|
||||
end
|
||||
|
||||
# This should work fine
|
||||
f = F.new
|
||||
|
||||
# This should work fine
|
||||
ff = FFF.new
|
||||
|
||||
# This should work fine
|
||||
g = G.new
|
||||
|
||||
# This should work fine
|
||||
gg = GG.new
|
||||
13
SWIG/Examples/test-suite/ruby/dynamic_cast_runme.rb
Executable file
13
SWIG/Examples/test-suite/ruby/dynamic_cast_runme.rb
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
require 'dynamic_cast'
|
||||
|
||||
f = Dynamic_cast::Foo.new
|
||||
b = Dynamic_cast::Bar.new
|
||||
|
||||
x = f.blah
|
||||
y = b.blah
|
||||
|
||||
a = Dynamic_cast.do_test(y)
|
||||
if a != "Bar::test"
|
||||
puts "Failed!!"
|
||||
end
|
||||
|
||||
6
SWIG/Examples/test-suite/ruby/enum_runme.rb
Executable file
6
SWIG/Examples/test-suite/ruby/enum_runme.rb
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
require 'enum'
|
||||
|
||||
Enum.bar2(1)
|
||||
Enum.bar3(1)
|
||||
Enum.bar1(1)
|
||||
|
||||
12
SWIG/Examples/test-suite/ruby/extend_template_ns_runme.rb
Normal file
12
SWIG/Examples/test-suite/ruby/extend_template_ns_runme.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require 'extend_template_ns'
|
||||
|
||||
include Extend_template_ns
|
||||
|
||||
f = Foo_One.new
|
||||
if f.test1(37) != 37
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
if f.test2(42) != 42
|
||||
raise RuntimeError
|
||||
end
|
||||
10
SWIG/Examples/test-suite/ruby/extend_template_runme.rb
Normal file
10
SWIG/Examples/test-suite/ruby/extend_template_runme.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'extend_template'
|
||||
|
||||
f = Extend_template::Foo_0.new
|
||||
if f.test1(37) != 37
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
if f.test2(42) != 42
|
||||
raise RuntimeError
|
||||
end
|
||||
15
SWIG/Examples/test-suite/ruby/grouping_runme.rb
Normal file
15
SWIG/Examples/test-suite/ruby/grouping_runme.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'grouping'
|
||||
|
||||
x = Grouping.test1(42)
|
||||
if x != 42
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
Grouping.test2(42)
|
||||
|
||||
x = Grouping.do_unary(37, Grouping::NEGATE)
|
||||
if x != -37
|
||||
raise RuntimeError
|
||||
end
|
||||
|
||||
Grouping.test3 = 42
|
||||
9
SWIG/Examples/test-suite/ruby/imports_runme.rb
Executable file
9
SWIG/Examples/test-suite/ruby/imports_runme.rb
Executable file
|
|
@ -0,0 +1,9 @@
|
|||
# This is the import runtime testcase.
|
||||
|
||||
require 'imports_a'
|
||||
require 'imports_b'
|
||||
|
||||
x = Imports_b::B.new
|
||||
|
||||
x.hello
|
||||
|
||||
20
SWIG/Examples/test-suite/ruby/inherit_missing_runme.rb
Normal file
20
SWIG/Examples/test-suite/ruby/inherit_missing_runme.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require 'inherit_missing'
|
||||
|
||||
a = Inherit_missing.new_Foo()
|
||||
b = Inherit_missing::Bar.new
|
||||
c = Inherit_missing::Spam.new
|
||||
|
||||
x = Inherit_missing.do_blah(a)
|
||||
if x != "Foo::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
x = Inherit_missing.do_blah(b)
|
||||
if x != "Bar::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
x = Inherit_missing.do_blah(c)
|
||||
if x != "Spam::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
17
SWIG/Examples/test-suite/ruby/lib_std_vector_runme.rb
Executable file
17
SWIG/Examples/test-suite/ruby/lib_std_vector_runme.rb
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
require 'lib_std_vector'
|
||||
|
||||
include Lib_std_vector
|
||||
|
||||
iv = IntVector.new(4)
|
||||
0.upto(3) { |i| iv[i] = i }
|
||||
|
||||
x = average(iv)
|
||||
y = average([1, 2, 3, 4])
|
||||
|
||||
a = half([10, 10.5, 11, 11.5])
|
||||
|
||||
dv = DoubleVector.new(10)
|
||||
0.upto(9) { |i| dv[i] = i/2.0 }
|
||||
|
||||
halve_in_place(dv)
|
||||
|
||||
33
SWIG/Examples/test-suite/ruby/namespace_typemap_runme.rb
Executable file
33
SWIG/Examples/test-suite/ruby/namespace_typemap_runme.rb
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
require 'namespace_typemap'
|
||||
|
||||
include Namespace_typemap
|
||||
|
||||
raise RuntimeError 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"
|
||||
|
||||
begin
|
||||
ttest1(-14)
|
||||
raise RuntimeError
|
||||
rescue RangeError
|
||||
end
|
||||
15
SWIG/Examples/test-suite/ruby/newobject1_runme.rb
Normal file
15
SWIG/Examples/test-suite/ruby/newobject1_runme.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'newobject1'
|
||||
|
||||
include Newobject1
|
||||
|
||||
foo1 = Foo.makeFoo
|
||||
raise RuntimeError if Foo.fooCount != 1
|
||||
|
||||
foo2 = foo1.makeMore
|
||||
raise RuntimeError if Foo.fooCount != 2
|
||||
|
||||
foo1 = nil ; GC.start
|
||||
raise RuntimeError if Foo.fooCount != 1
|
||||
|
||||
foo2 = nil ; GC.start
|
||||
raise RuntimeError if Foo.fooCount != 0
|
||||
15
SWIG/Examples/test-suite/ruby/newobject2_runme.rb
Normal file
15
SWIG/Examples/test-suite/ruby/newobject2_runme.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'newobject2'
|
||||
|
||||
include Newobject2
|
||||
|
||||
foo1 = makeFoo
|
||||
raise RuntimeError if fooCount != 1
|
||||
|
||||
foo2 = makeFoo
|
||||
raise RuntimeError if fooCount != 2
|
||||
|
||||
foo1 = nil ; GC.start
|
||||
raise RuntimeError if fooCount != 1
|
||||
|
||||
foo2 = nil ; GC.start
|
||||
raise RuntimeError if fooCount != 0
|
||||
6
SWIG/Examples/test-suite/ruby/overload_copy_runme.rb
Executable file
6
SWIG/Examples/test-suite/ruby/overload_copy_runme.rb
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
require 'overload_copy'
|
||||
|
||||
include Overload_copy
|
||||
|
||||
f = Foo.new
|
||||
g = Foo.new(f)
|
||||
8
SWIG/Examples/test-suite/ruby/overload_extend_runme.rb
Executable file
8
SWIG/Examples/test-suite/ruby/overload_extend_runme.rb
Executable file
|
|
@ -0,0 +1,8 @@
|
|||
require 'overload_extend'
|
||||
|
||||
f = Overload_extend::Foo.new
|
||||
|
||||
raise RuntimeError if f.test(3) != 1
|
||||
raise RuntimeError if f.test("hello") != 2
|
||||
raise RuntimeError if f.test(3.5,2.5) != 3
|
||||
|
||||
7
SWIG/Examples/test-suite/ruby/overload_extendc_runme.rb
Executable file
7
SWIG/Examples/test-suite/ruby/overload_extendc_runme.rb
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
require 'overload_extend'
|
||||
|
||||
f = Overload_extend::Foo.new
|
||||
|
||||
raise RuntimeError if f.test(3) != 1
|
||||
raise RuntimeError if f.test("hello") != 2
|
||||
raise RuntimeError if f.test(3.5,2.5) != 3
|
||||
119
SWIG/Examples/test-suite/ruby/overload_simple_runme.rb
Executable file
119
SWIG/Examples/test-suite/ruby/overload_simple_runme.rb
Executable file
|
|
@ -0,0 +1,119 @@
|
|||
require 'overload_simple'
|
||||
|
||||
include Overload_simple
|
||||
|
||||
if foo(3) != "foo:int"
|
||||
raise RuntimeError, "foo(int)"
|
||||
end
|
||||
|
||||
if foo(3.0) != "foo:double"
|
||||
raise RuntimeError, "foo(double)"
|
||||
end
|
||||
|
||||
if foo("hello") != "foo:char *"
|
||||
raise RuntimeError, "foo(char *)"
|
||||
end
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new
|
||||
|
||||
if foo(f) != "foo:Foo *"
|
||||
raise RuntimeError, "foo(Foo *)"
|
||||
end
|
||||
|
||||
if foo(b) != "foo:Bar *"
|
||||
raise RuntimeError, "foo(Bar *)"
|
||||
end
|
||||
|
||||
v = malloc_void(32)
|
||||
|
||||
if foo(v) != "foo:void *"
|
||||
raise RuntimeError, "foo(void *)"
|
||||
end
|
||||
|
||||
s = Spam.new
|
||||
|
||||
if s.foo(3) != "foo:int"
|
||||
raise RuntimeError, "Spam::foo(int)"
|
||||
end
|
||||
|
||||
if s.foo(3.0) != "foo:double"
|
||||
raise RuntimeError, "Spam::foo(double)"
|
||||
end
|
||||
|
||||
if s.foo("hello") != "foo:char *"
|
||||
raise RuntimeError, "Spam::foo(char *)"
|
||||
end
|
||||
|
||||
if s.foo(f) != "foo:Foo *"
|
||||
raise RuntimeError, "Spam::foo(Foo *)"
|
||||
end
|
||||
|
||||
if s.foo(b) != "foo:Bar *"
|
||||
raise RuntimeError, "Spam::foo(Bar *)"
|
||||
end
|
||||
|
||||
if s.foo(v) != "foo:void *"
|
||||
raise RuntimeError, "Spam::foo(void *)"
|
||||
end
|
||||
|
||||
if Spam.bar(3) != "bar:int"
|
||||
raise RuntimeError, "Spam::bar(int)"
|
||||
end
|
||||
|
||||
if Spam.bar(3.0) != "bar:double"
|
||||
raise RuntimeError, "Spam::bar(double)"
|
||||
end
|
||||
|
||||
if Spam.bar("hello") != "bar:char *"
|
||||
raise RuntimeError, "Spam::bar(char *)"
|
||||
end
|
||||
|
||||
if Spam.bar(f) != "bar:Foo *"
|
||||
raise RuntimeError, "Spam::bar(Foo *)"
|
||||
end
|
||||
|
||||
if Spam.bar(b) != "bar:Bar *"
|
||||
raise RuntimeError, "Spam::bar(Bar *)"
|
||||
end
|
||||
|
||||
if Spam.bar(v) != "bar:void *"
|
||||
raise RuntimeError, "Spam::bar(void *)"
|
||||
end
|
||||
|
||||
# Test constructors
|
||||
|
||||
s = Spam.new
|
||||
if s.type != "none"
|
||||
raise RuntimeError, "Spam()"
|
||||
end
|
||||
|
||||
s = Spam.new(3)
|
||||
if s.type != "int"
|
||||
raise RuntimeError, "Spam(int)"
|
||||
end
|
||||
|
||||
s = Spam.new(3.4)
|
||||
if s.type != "double"
|
||||
raise RuntimeError, "Spam(double)"
|
||||
end
|
||||
|
||||
s = Spam.new("hello")
|
||||
if s.type != "char *"
|
||||
raise RuntimeError, "Spam(char *)"
|
||||
end
|
||||
|
||||
s = Spam.new(f)
|
||||
if s.type != "Foo *"
|
||||
raise RuntimeError, "Spam(Foo *)"
|
||||
end
|
||||
|
||||
s = Spam.new(b)
|
||||
if s.type != "Bar *"
|
||||
raise RuntimeError, "Spam(Bar *)"
|
||||
end
|
||||
|
||||
s = Spam.new(v)
|
||||
if s.type != "void *"
|
||||
raise RuntimeError, "Spam(void *)"
|
||||
end
|
||||
15
SWIG/Examples/test-suite/ruby/overload_subtype_runme.rb
Normal file
15
SWIG/Examples/test-suite/ruby/overload_subtype_runme.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'overload_subtype'
|
||||
|
||||
include Overload_subtype
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new
|
||||
|
||||
if spam(f) != 1
|
||||
raise RuntimeError, "foo"
|
||||
end
|
||||
|
||||
if spam(b) != 2
|
||||
raise RuntimeError, "bar"
|
||||
end
|
||||
|
||||
6
SWIG/Examples/test-suite/ruby/overload_template_runme.rb
Executable file
6
SWIG/Examples/test-suite/ruby/overload_template_runme.rb
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
require 'overload_template'
|
||||
|
||||
f = Overload_template.foo()
|
||||
|
||||
a = Overload_template.max(3,4)
|
||||
b = Overload_template.max(3.4,5.2)
|
||||
27
SWIG/Examples/test-suite/ruby/primitive_ref_runme.rb
Executable file
27
SWIG/Examples/test-suite/ruby/primitive_ref_runme.rb
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
require 'primitive_ref'
|
||||
|
||||
include Primitive_ref
|
||||
|
||||
raise RuntimeError 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(true) != true
|
||||
|
||||
raise RuntimeError if ref_char('x') != 'x'
|
||||
10
SWIG/Examples/test-suite/ruby/rename_scope_runme.rb
Normal file
10
SWIG/Examples/test-suite/ruby/rename_scope_runme.rb
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
require 'rename_scope'
|
||||
|
||||
include Rename_scope
|
||||
|
||||
a = Natural_UP.new
|
||||
b = Natural_BP.new
|
||||
|
||||
raise RuntimeError if a.rtest() != 1
|
||||
|
||||
raise RuntimeError if b.rtest() != 1
|
||||
13
SWIG/Examples/test-suite/ruby/smart_pointer_const_runme.rb
Normal file
13
SWIG/Examples/test-suite/ruby/smart_pointer_const_runme.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
require 'smart_pointer_const'
|
||||
|
||||
include Smart_pointer_const
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
|
||||
b.x = 3
|
||||
raise RuntimeError if b.getx() != 3
|
||||
|
||||
fp = b.__deref__()
|
||||
fp.x = 4
|
||||
raise RuntimeError if fp.getx() != 4
|
||||
15
SWIG/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
Normal file
15
SWIG/Examples/test-suite/ruby/smart_pointer_multi_runme.rb
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
require 'smart_pointer_multi'
|
||||
|
||||
include Smart_pointer_multi
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
s = Spam.new(b)
|
||||
g = Grok.new(b)
|
||||
|
||||
s.x = 3
|
||||
raise RuntimeError if s.getx() != 3
|
||||
|
||||
g.x = 4
|
||||
raise RuntimeError if g.getx() != 4
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
require 'smart_pointer_multi_typedef'
|
||||
|
||||
include Smart_pointer_multi_typedef
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
s = Spam.new(b)
|
||||
g = Grok.new(b)
|
||||
|
||||
s.x = 3
|
||||
raise RuntimeError if s.getx() != 3
|
||||
|
||||
g.x = 4
|
||||
raise RuntimeError if g.getx() != 4
|
||||
44
SWIG/Examples/test-suite/ruby/smart_pointer_not_runme.rb
Normal file
44
SWIG/Examples/test-suite/ruby/smart_pointer_not_runme.rb
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
require 'smart_pointer_not'
|
||||
|
||||
include Smart_pointer_not
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
s = Spam.new(f)
|
||||
g = Grok.new(f)
|
||||
|
||||
begin
|
||||
x = b.x
|
||||
puts "Error! b.x"
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
begin
|
||||
x = s.x
|
||||
puts "Error! s.x"
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
begin
|
||||
x = g.x
|
||||
puts "Error! g.x"
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
begin
|
||||
x = b.getx()
|
||||
puts "Error! b.getx()"
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
begin
|
||||
x = s.getx()
|
||||
puts "Error! s.getx()"
|
||||
rescue NameError
|
||||
end
|
||||
|
||||
begin
|
||||
x = g.getx()
|
||||
puts "Error! g.getx()"
|
||||
rescue NameError
|
||||
end
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
require 'smart_pointer_overload'
|
||||
|
||||
include Smart_pointer_overload
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
|
||||
|
||||
raise RuntimeError 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
|
||||
|
||||
12
SWIG/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
Normal file
12
SWIG/Examples/test-suite/ruby/smart_pointer_rename_runme.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
require 'smart_pointer_rename'
|
||||
|
||||
include Smart_pointer_rename
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
|
||||
raise RuntimeError if b.test() != 3
|
||||
|
||||
raise RuntimeError if b.ftest1(1) != 1
|
||||
|
||||
raise RuntimeError if b.ftest2(2,3) != 2
|
||||
13
SWIG/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
Normal file
13
SWIG/Examples/test-suite/ruby/smart_pointer_simple_runme.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
require 'smart_pointer_simple'
|
||||
|
||||
include Smart_pointer_simple
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
|
||||
b.x = 3
|
||||
raise RuntimeError if b.getx() != 3
|
||||
|
||||
fp = b.__deref__()
|
||||
fp.x = 4
|
||||
raise RuntimeError if fp.getx() != 4
|
||||
13
SWIG/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
Normal file
13
SWIG/Examples/test-suite/ruby/smart_pointer_typedef_runme.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
require 'smart_pointer_typedef'
|
||||
|
||||
include Smart_pointer_typedef
|
||||
|
||||
f = Foo.new
|
||||
b = Bar.new(f)
|
||||
|
||||
b.x = 3
|
||||
raise RuntimeError if b.getx() != 3
|
||||
|
||||
fp = b.__deref__()
|
||||
fp.x = 4
|
||||
raise RuntimeError if fp.getx() != 4
|
||||
6
SWIG/Examples/test-suite/ruby/sneaky1_runme.rb
Executable file
6
SWIG/Examples/test-suite/ruby/sneaky1_runme.rb
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
require 'sneaky1'
|
||||
|
||||
x = Sneaky1.add(3, 4)
|
||||
y = Sneaky1.sub(3, 4)
|
||||
z = Sneaky1.mul(3, 4)
|
||||
w = Sneaky1.divide(3, 4)
|
||||
40
SWIG/Examples/test-suite/ruby/template_inherit_runme.rb
Executable file
40
SWIG/Examples/test-suite/ruby/template_inherit_runme.rb
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
require 'template_inherit'
|
||||
|
||||
include Template_inherit
|
||||
|
||||
a = FooInt.new
|
||||
b = FooDouble.new
|
||||
c = BarInt.new
|
||||
d = BarDouble.new
|
||||
e = FooUInt.new
|
||||
f = BarUInt.new
|
||||
|
||||
raise ValueError 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"
|
||||
4
SWIG/Examples/test-suite/ruby/template_ns4_runme.rb
Executable file
4
SWIG/Examples/test-suite/ruby/template_ns4_runme.rb
Executable file
|
|
@ -0,0 +1,4 @@
|
|||
require 'template_ns4'
|
||||
|
||||
d = Template_ns4.make_Class_DD()
|
||||
raise RuntimeError if d.test() != "test"
|
||||
15
SWIG/Examples/test-suite/ruby/template_ns_runme.rb
Executable file
15
SWIG/Examples/test-suite/ruby/template_ns_runme.rb
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
require 'template_ns'
|
||||
|
||||
include Template_ns
|
||||
|
||||
p1 = Pairii.new(2, 3)
|
||||
p2 = Pairii.new(p1)
|
||||
|
||||
raise RuntimeError if p2.first != 2
|
||||
raise RuntimeError if p2.second != 3
|
||||
|
||||
p3 = Pairdd.new(3.5, 2.5)
|
||||
p4 = Pairdd.new(p3)
|
||||
|
||||
raise RuntimeError if p4.first != 3.5
|
||||
raise RuntimeError if p4.second != 2.5
|
||||
12
SWIG/Examples/test-suite/ruby/template_rename_runme.rb
Executable file
12
SWIG/Examples/test-suite/ruby/template_rename_runme.rb
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
require 'template_rename'
|
||||
|
||||
i = Template_rename::IFoo.new
|
||||
d = Template_rename::DFoo.new
|
||||
|
||||
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)
|
||||
27
SWIG/Examples/test-suite/ruby/typedef_inherit_runme.rb
Executable file
27
SWIG/Examples/test-suite/ruby/typedef_inherit_runme.rb
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
require 'typedef_inherit'
|
||||
|
||||
a = Typedef_inherit::Foo.new
|
||||
b = Typedef_inherit::Bar.new
|
||||
|
||||
x = Typedef_inherit.do_blah(a)
|
||||
if x != "Foo::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
x = Typedef_inherit.do_blah(b)
|
||||
if x != "Bar::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
c = Typedef_inherit::Spam.new
|
||||
d = Typedef_inherit::Grok.new
|
||||
|
||||
x = Typedef_inherit.do_blah2(c)
|
||||
if x != "Spam::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
|
||||
x = Typedef_inherit.do_blah2(d)
|
||||
if x != "Grok::blah"
|
||||
puts "Whoa! Bad return #{x}"
|
||||
end
|
||||
13
SWIG/Examples/test-suite/ruby/typedef_scope_runme.rb
Executable file
13
SWIG/Examples/test-suite/ruby/typedef_scope_runme.rb
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
require 'typedef_scope'
|
||||
|
||||
b = Typedef_scope::Bar.new
|
||||
|
||||
x = b.test1(42, "hello")
|
||||
if x != 42
|
||||
puts "Failed!!"
|
||||
end
|
||||
|
||||
x = b.test2(42, "hello")
|
||||
if x != "hello"
|
||||
puts "Failed!!"
|
||||
end
|
||||
7
SWIG/Examples/test-suite/ruby/typemap_namespace_runme.rb
Executable file
7
SWIG/Examples/test-suite/ruby/typemap_namespace_runme.rb
Executable file
|
|
@ -0,0 +1,7 @@
|
|||
require 'typemap_namespace'
|
||||
|
||||
include Typemap_namespace
|
||||
|
||||
raise RuntimeError if test1("hello") != "hello"
|
||||
|
||||
raise RuntimeError if test2("hello") != "hello"
|
||||
14
SWIG/Examples/test-suite/ruby/typename_runme.rb
Executable file
14
SWIG/Examples/test-suite/ruby/typename_runme.rb
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
require 'typename'
|
||||
|
||||
f = Typename::Foo.new
|
||||
b = Typename::Bar.new
|
||||
|
||||
x = Typename.twoFoo(f)
|
||||
unless x.is_a? Float
|
||||
puts "Wrong return type!"
|
||||
end
|
||||
|
||||
y = Typename.twoBar(b)
|
||||
unless y.is_a? Integer
|
||||
puts "Wrong return type!"
|
||||
end
|
||||
54
SWIG/Examples/test-suite/ruby/unions_runme.rb
Normal file
54
SWIG/Examples/test-suite/ruby/unions_runme.rb
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
# This is the union runtime testcase. It ensures that values within a
|
||||
# union embedded within a struct can be set and read correctly.
|
||||
|
||||
require 'unions'
|
||||
|
||||
# Create new instances of SmallStruct and BigStruct for later use
|
||||
small = Unions::SmallStruct.new()
|
||||
small.jill = 200
|
||||
|
||||
big = Unions::BigStruct.new()
|
||||
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.new()
|
||||
|
||||
# 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 , "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
Num1 = eut.number
|
||||
if (Num1 != 1)
|
||||
print "Runtime test2 failed. eut.number=" , Num1 , "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
# 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 , "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
Jill2 = eut.uni.big.smallstruct.jill
|
||||
if (Jill2 != 200)
|
||||
print "Runtime test4 failed. eut.uni.big.smallstruct.jill=" , Jill2 , "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
Num2 = eut.number
|
||||
if (Num2 != 2)
|
||||
print "Runtime test5 failed. eut.number=" , Num2 , "\n"
|
||||
exit 1
|
||||
end
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue