aboutsummaryrefslogtreecommitdiff
path: root/Examples/test-suite/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'Examples/test-suite/ruby')
-rw-r--r--Examples/test-suite/ruby/Makefile.in15
-rw-r--r--Examples/test-suite/ruby/argcargvtest_runme.rb65
-rw-r--r--Examples/test-suite/ruby/catches_strings_runme.rb31
-rw-r--r--Examples/test-suite/ruby/char_binary_runme.rb35
-rw-r--r--Examples/test-suite/ruby/constant_directive_runme.rb16
-rw-r--r--Examples/test-suite/ruby/contract_runme.rb69
-rw-r--r--Examples/test-suite/ruby/cpp11_alias_nested_template_scoping_runme.rb23
-rw-r--r--Examples/test-suite/ruby/cpp11_director_using_constructor_runme.rb129
-rw-r--r--Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb36
-rw-r--r--Examples/test-suite/ruby/cpp11_rvalue_reference_move_runme.rb106
-rw-r--r--Examples/test-suite/ruby/cpp11_std_unique_ptr_runme.rb151
-rw-r--r--Examples/test-suite/ruby/cpp11_using_constructor_runme.rb129
-rw-r--r--Examples/test-suite/ruby/cpp17_director_string_view_runme.rb42
-rw-r--r--Examples/test-suite/ruby/cpp17_nested_namespaces_runme.rb24
-rw-r--r--Examples/test-suite/ruby/cpp17_string_view_runme.rb119
-rw-r--r--Examples/test-suite/ruby/cpp_enum_runme.rb19
-rw-r--r--Examples/test-suite/ruby/cpp_static_runme.rb26
-rw-r--r--Examples/test-suite/ruby/director_string_runme.rb19
-rw-r--r--Examples/test-suite/ruby/director_unwrap_result_runme.rb120
-rw-r--r--Examples/test-suite/ruby/enums_runme.rb11
-rw-r--r--Examples/test-suite/ruby/friends_runme.rb3
-rw-r--r--Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb48
-rw-r--r--Examples/test-suite/ruby/global_immutable_vars_runme.rb52
-rw-r--r--Examples/test-suite/ruby/ignore_parameter_runme.rb1
-rw-r--r--Examples/test-suite/ruby/import_fragments_runme.rb23
-rw-r--r--Examples/test-suite/ruby/li_constraints_runme.rb63
-rw-r--r--Examples/test-suite/ruby/li_std_auto_ptr_runme.rb151
-rw-r--r--Examples/test-suite/ruby/li_std_containers_int_runme.rb203
-rw-r--r--Examples/test-suite/ruby/li_std_functors_runme.rb7
-rw-r--r--Examples/test-suite/ruby/li_std_map_runme.rb10
-rw-r--r--Examples/test-suite/ruby/li_std_set_runme.rb8
-rw-r--r--Examples/test-suite/ruby/li_std_string_runme.rb17
-rw-r--r--Examples/test-suite/ruby/li_std_vector_runme.rb17
-rw-r--r--Examples/test-suite/ruby/li_std_wstring_runme.rb7
-rw-r--r--Examples/test-suite/ruby/multiple_inheritance_abstract_runme.rb243
-rw-r--r--Examples/test-suite/ruby/multiple_inheritance_nspace_runme.rb243
-rw-r--r--Examples/test-suite/ruby/namespace_chase_runme.rb14
-rw-r--r--Examples/test-suite/ruby/namespace_class_runme.rb40
-rw-r--r--Examples/test-suite/ruby/namespace_forward_declaration_runme.rb16
-rw-r--r--Examples/test-suite/ruby/namespace_virtual_method_runme.rb8
-rw-r--r--Examples/test-suite/ruby/nested_class_runme.rb54
-rw-r--r--Examples/test-suite/ruby/nested_directors_runme.rb29
-rw-r--r--Examples/test-suite/ruby/nested_in_template_runme.rb11
-rw-r--r--Examples/test-suite/ruby/nested_scope_flat_runme.rb25
-rw-r--r--Examples/test-suite/ruby/nested_template_base_runme.rb16
-rw-r--r--Examples/test-suite/ruby/nested_workaround_runme.rb21
-rw-r--r--Examples/test-suite/ruby/newobject2_runme.rb2
-rw-r--r--Examples/test-suite/ruby/numeric_bounds_checking_runme.rb42
-rw-r--r--Examples/test-suite/ruby/overload_null_runme.rb14
-rw-r--r--Examples/test-suite/ruby/preproc_runme.rb40
-rw-r--r--Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb48
-rw-r--r--Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb52
-rw-r--r--Examples/test-suite/ruby/ruby_naming_bugs_runme.rb16
-rw-r--r--Examples/test-suite/ruby/template_nested_flat_runme.rb23
-rw-r--r--Examples/test-suite/ruby/template_static_runme.rb12
-rw-r--r--Examples/test-suite/ruby/typedef_inherit_runme.rb6
56 files changed, 2746 insertions, 24 deletions
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index d75cdb058..20ed68c65 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -6,13 +6,21 @@ LANGUAGE = ruby
RUBY = @RUBY@
SCRIPTSUFFIX = _runme.rb
+HAVE_CXX11 = @HAVE_CXX11@
+HAVE_CXX14 = @HAVE_CXX14@
+HAVE_CXX17 = @HAVE_CXX17@
+HAVE_CXX20 = @HAVE_CXX20@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+FAILING_CPP_TESTS = \
+ cpp17_map_no_default_ctor \
+
CPP_TEST_CASES = \
li_cstring \
li_factory \
+ li_std_containers_int \
li_std_functors \
li_std_list \
li_std_multimap \
@@ -23,6 +31,7 @@ CPP_TEST_CASES = \
li_std_wstring_inherit \
primitive_types \
ruby_alias_method \
+ ruby_global_immutable_vars_cpp \
ruby_keywords \
ruby_minherit_shared_ptr \
ruby_naming \
@@ -36,6 +45,7 @@ CPP_TEST_CASES = \
CPP11_TEST_CASES = \
cpp11_hash_tables \
cpp11_shared_ptr_const \
+ cpp11_shared_ptr_crtp_upcast \
cpp11_shared_ptr_nullptr_in_containers \
cpp11_shared_ptr_overload \
cpp11_shared_ptr_upcast \
@@ -48,6 +58,7 @@ C_TEST_CASES += \
li_cstring \
ruby_alias_global_function \
ruby_alias_module_function \
+ ruby_global_immutable_vars \
ruby_manual_proxy \
include $(srcdir)/../common.mk
@@ -57,6 +68,8 @@ SWIGOPT += -w801 -noautorename -features autodoc=4
# Custom tests - tests with additional commandline options
ruby_alias_global_function.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars.ctest: SWIGOPT += -globalmodule
+ruby_global_immutable_vars_cpp.cpptest: SWIGOPT += -globalmodule
ruby_naming.cpptest: SWIGOPT += -autorename
# Rules for the different types of tests
@@ -80,6 +93,8 @@ ruby_naming.cpptest: SWIGOPT += -autorename
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(RUBYFLAGS) -I$(srcdir):. $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
+ elif [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*.so ] ; then \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(RUBY) $(RUBYFLAGS) -I$(srcdir):. -r$(SCRIPTDIR)/$(SCRIPTPREFIX)$*.so -e '' ; \
fi
# Clean
diff --git a/Examples/test-suite/ruby/argcargvtest_runme.rb b/Examples/test-suite/ruby/argcargvtest_runme.rb
new file mode 100644
index 000000000..da6536593
--- /dev/null
+++ b/Examples/test-suite/ruby/argcargvtest_runme.rb
@@ -0,0 +1,65 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+require 'argcargvtest'
+
+include Argcargvtest
+
+
+$largs = ["hi", "hola", "hello"]
+if mainc($largs) != 3
+ raise RuntimeError, "bad main typemap"
+end
+
+$targs = ["hi", "hola"]
+if mainv($targs, 0) != "hi"
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($targs, 1) != "hola"
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($targs, 2) != "<<NULL>>"
+ raise RuntimeError, "bad main typemap"
+end
+
+$error = 0
+$ret = 0
+begin
+ mainv("hello", 1)
+ $error = 1
+rescue => e
+ $ret = 1
+end
+
+if $error == 1 or $ret != 1
+ raise RuntimeError, "bad main typemap"
+end
+
+initializeApp($largs)
+
+# Check that an empty array works.
+$empty_args = []
+if mainc($empty_args) != 0
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($empty_args, 0) != "<<NULL>>"
+ raise RuntimeError, "bad main typemap"
+end
+
+# Check that empty strings are handled.
+$empty_string = ["hello", "", "world"]
+if mainc($empty_string) != 3
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($empty_string, 0) != "hello"
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($empty_string, 1) != ""
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($empty_string, 2) != "world"
+ raise RuntimeError, "bad main typemap"
+end
+if mainv($empty_string, 3) != "<<NULL>>"
+ raise RuntimeError, "bad main typemap"
+end
diff --git a/Examples/test-suite/ruby/catches_strings_runme.rb b/Examples/test-suite/ruby/catches_strings_runme.rb
new file mode 100644
index 000000000..fb7466765
--- /dev/null
+++ b/Examples/test-suite/ruby/catches_strings_runme.rb
@@ -0,0 +1,31 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'catches_strings'
+
+exception_thrown = false
+begin
+ Catches_strings::StringsThrower.charstring()
+rescue RuntimeError => e
+ if (!e.to_s.include? "charstring message")
+ raise RuntimeError, "incorrect exception message: #{e.to_s}"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown an exception"
+end
+
+exception_thrown = false
+begin
+ Catches_strings::StringsThrower.stdstring()
+rescue RuntimeError => e
+ if (!e.to_s.include? "stdstring message")
+ raise RuntimeError, "incorrect exception message: #{e.to_s}"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown an exception"
+end
diff --git a/Examples/test-suite/ruby/char_binary_runme.rb b/Examples/test-suite/ruby/char_binary_runme.rb
new file mode 100644
index 000000000..c40738fbb
--- /dev/null
+++ b/Examples/test-suite/ruby/char_binary_runme.rb
@@ -0,0 +1,35 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+
+require 'swig_assert'
+require 'char_binary'
+
+include Char_binary
+
+t = Test.new
+str = 'hile'
+swig_assert(t.strlen(str) == 4, binding, 'bad multi-arg typemap')
+swig_assert(t.ustrlen(str) == 4, binding, 'bad multi-arg typemap')
+swig_assert(t.strlen("hil\000") == 4, binding, 'bad multi-arg typemap')
+swig_assert(t.ustrlen("hil\000") == 4, binding, 'bad multi-arg typemap')
+
+# creating a raw char*
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+swig_assert(t.strlen(pc) == 4, binding, 'bad multi-arg typemap')
+swig_assert(t.ustrlen(pc) == 4, binding, 'bad multi-arg typemap')
+
+Char_binary.var_pchar = pc
+swig_assert(Char_binary.var_pchar == 'hola', binding, 'bad pointer case')
+
+Char_binary.var_namet = pc
+swig_assert(Char_binary.var_namet == 'hola', binding, 'bad pointer case')
+
+delete_pchar(pc)
diff --git a/Examples/test-suite/ruby/constant_directive_runme.rb b/Examples/test-suite/ruby/constant_directive_runme.rb
new file mode 100644
index 000000000..ae6cf4fb3
--- /dev/null
+++ b/Examples/test-suite/ruby/constant_directive_runme.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'constant_directive'
+
+swig_assert("Constant_directive::TYPE1_CONSTANT1.is_a?(Constant_directive::Type1)", binding)
+swig_assert("Constant_directive::getType1Instance().is_a?(Constant_directive::Type1)", binding)
+
+swig_assert_equal('Constant_directive::TYPE1_CONSTANT1.val', '1', binding)
+swig_assert_equal('Constant_directive::TYPE1_CONSTANT2.val', '2', binding)
+swig_assert_equal('Constant_directive::TYPE1_CONSTANT3.val', '3', binding)
+swig_assert_equal('Constant_directive::TYPE1CONST_CONSTANT1.val', '1', binding)
+swig_assert_equal('Constant_directive::TYPE1CPTR_CONSTANT1.val', '1', binding)
diff --git a/Examples/test-suite/ruby/contract_runme.rb b/Examples/test-suite/ruby/contract_runme.rb
new file mode 100644
index 000000000..df7fd3d8f
--- /dev/null
+++ b/Examples/test-suite/ruby/contract_runme.rb
@@ -0,0 +1,69 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'contract'
+
+def swig_assert_runtime_error(msg, type, &block)
+ begin
+ yield(block)
+ raise SwigRubyError.new("#{msg} failed")
+ rescue RuntimeError => e
+ reason = e.to_s
+ if reason =~ /\bcontract violation\b/i && reason =~ /\b#{type}\b/i
+ # OK
+ else
+ raise e
+ end
+ end
+end
+
+Contract::test_preassert(1, 2)
+swig_assert_runtime_error("Preassertions", "require") { Contract::test_preassert(-1, 3) }
+
+Contract::test_postassert(3)
+swig_assert_runtime_error("Postassertions", "ensure") { Contract::test_postassert(-3) }
+
+Contract::test_prepost(2, 3)
+Contract::test_prepost(5, -4)
+swig_assert_runtime_error("Preassertions", "require") { Contract::test_prepost(-3, 4) }
+swig_assert_runtime_error("Postassertions", "ensure") { Contract::test_prepost(4, -10) }
+
+f = Contract::Foo.new
+f.test_preassert(4, 5)
+swig_assert_runtime_error("Method preassertion", "require") { f.test_preassert(-2, 3) }
+
+f.test_postassert(4)
+swig_assert_runtime_error("Method postassertion", "ensure") { f.test_postassert(-4) }
+
+f.test_prepost(3, 4)
+f.test_prepost(4, -3)
+swig_assert_runtime_error("Method preassertion", "require") { f.test_prepost(-4, 2) }
+swig_assert_runtime_error("Method postassertion", "ensure") { f.test_prepost(4, -10) }
+
+Contract::Foo.stest_prepost(4, 0)
+swig_assert_runtime_error("Static method preassertion", "require") { Contract::Foo.stest_prepost(-4, 2) }
+swig_assert_runtime_error("Static method postassertion", "ensure") { Contract::Foo.stest_prepost(4, -10) }
+
+b = Contract::Bar.new
+swig_assert_runtime_error("Inherited preassertion", "require") { b.test_prepost(2, -4) }
+
+d = Contract::D.new
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.foo(-1, 1, 1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.foo(1, -1, 1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.foo(1, 1, -1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.foo(1, 1, 1, -1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.foo(1, 1, 1, 1, -1) }
+
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.bar(-1, 1, 1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.bar(1, -1, 1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.bar(1, 1, -1, 1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.bar(1, 1, 1, -1, 1) }
+swig_assert_runtime_error("Inherited preassertion (D)", "require") { d.bar(1, 1, 1, 1, -1) }
+
+# namespace
+Contract::MyClass.new(1)
+swig_assert_runtime_error("Constructor preassertion", "require") { Contract::MyClass.new(0) }
+
diff --git a/Examples/test-suite/ruby/cpp11_alias_nested_template_scoping_runme.rb b/Examples/test-suite/ruby/cpp11_alias_nested_template_scoping_runme.rb
new file mode 100644
index 000000000..c6e2b8559
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_alias_nested_template_scoping_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'cpp11_alias_nested_template_scoping'
+
+ys = Cpp11_alias_nested_template_scoping::Yshort.new
+val = ys.create1
+val = ys.create2
+val = ys.create3
+val = ys.create4
+val = ys.create5
+val = ys.create6
+val = ys.create7
+
+val = ys.create13
+
+val = ys.create15
+val = ys.create16
+val = ys.create17
+
diff --git a/Examples/test-suite/ruby/cpp11_director_using_constructor_runme.rb b/Examples/test-suite/ruby/cpp11_director_using_constructor_runme.rb
new file mode 100644
index 000000000..272fc05e8
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_director_using_constructor_runme.rb
@@ -0,0 +1,129 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'cpp11_director_using_constructor'
+
+include Cpp11_director_using_constructor
+
+# Public base constructors
+a = PublicDerived1.new(0, "hi").meth()
+a = PublicDerived2.new().meth()
+a = PublicDerived2.new(0, "hi").meth()
+a = PublicDerived3.new().meth()
+a = PublicDerived3.new(0, "hi").meth()
+a = PublicDerived4.new().meth()
+a = PublicDerived5.new().meth()
+
+# Protected base constructors
+# Cannot test most of these as the constructors are protected
+ProtectedDerived5.new()
+
+# Mix of public and overloaded constructors
+MixedDerived1a.new(0, "hi").meth()
+MixedDerived1a.new().meth()
+MixedDerived1b.new(0, "hi").meth()
+MixedDerived1b.new().meth()
+
+MixedDerived2a.new(0, "hi").meth()
+MixedDerived2a.new().meth()
+MixedDerived2b.new(0, "hi").meth()
+MixedDerived2b.new().meth()
+
+MixedDerived2c.new(0, "hi").meth()
+MixedDerived2c.new().meth()
+MixedDerived2c.new(0).meth()
+
+MixedDerived2d.new(0, "hi").meth()
+MixedDerived2d.new().meth()
+MixedDerived2d.new(0).meth()
+
+MixedDerived3a.new(0, "hi").meth()
+MixedDerived3a.new().meth()
+MixedDerived3b.new(0, "hi").meth()
+MixedDerived3b.new().meth()
+
+MixedDerived3c.new(0, "hi").meth()
+MixedDerived3c.new().meth()
+MixedDerived3c.new(0).meth()
+
+MixedDerived3d.new(0, "hi").meth()
+MixedDerived3d.new().meth()
+MixedDerived3d.new(0).meth()
+
+MixedDerived4a.new(0, "hi").meth()
+MixedDerived4a.new().meth()
+MixedDerived4b.new(0, "hi").meth()
+MixedDerived4b.new().meth()
+
+MixedDerived4c.new().meth()
+MixedDerived4c.new(0).meth()
+
+MixedDerived4d.new().meth()
+MixedDerived4d.new(0).meth()
+
+MixedDerived4e.new().meth()
+
+MixedDerived4f.new().meth()
+
+# Mix of protected base constructors and overloading
+ProotDerived1a.new().meth()
+
+ProotDerived1b.new(0, "hi").meth()
+ProotDerived1b.new().meth()
+
+ProotDerived1c.new(0, "hi").meth()
+ProotDerived1c.new().meth()
+
+ProotDerived1d.new(0).meth()
+ProotDerived1d.new().meth()
+
+ProotDerived1e.new(0).meth()
+ProotDerived1e.new().meth()
+
+ProotDerived2a.new(0, "hi").meth()
+
+ProotDerived2b.new(0, "hi").meth()
+
+ProotDerived2c.new(0, "hi").meth()
+ProotDerived2c.new().meth()
+
+ProotDerived2d.new(0, "hi").meth()
+ProotDerived2d.new().meth()
+
+ProotDerived2e.new(0, "hi").meth()
+ProotDerived2e.new().meth()
+
+ProotDerived2f.new(0, "hi").meth()
+ProotDerived2f.new().meth()
+ProotDerived2f.new(0).meth()
+
+# Missing base
+# HiddenDerived1()
+
+# Templates and public base constructors (derive from non-template)
+TemplatePublicDerived1Int.new(0, "hi").meth()
+TemplatePublicDerived2Int.new().meth()
+TemplatePublicDerived2Int.new(0, "hi").meth()
+TemplatePublicDerived3Int.new().meth()
+TemplatePublicDerived3Int.new(0, "hi").meth()
+TemplatePublicDerived4Int.new().meth()
+TemplatePublicDerived5Int.new().meth()
+
+# Templates and public base constructors (derive from template)
+TemplPublicDerived1Int.new(0, "hi").meth()
+TemplPublicDerived2Int.new().meth()
+TemplPublicDerived2Int.new(0, "hi").meth()
+TemplPublicDerived3Int.new().meth()
+TemplPublicDerived3Int.new(0, "hi").meth()
+TemplPublicDerived4Int.new().meth()
+TemplPublicDerived5Int.new().meth()
+TemplPublicDerived6Int.new(0, "hi").meth()
+TemplPublicDerived6Int.new().meth()
diff --git a/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb b/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb
new file mode 100644
index 000000000..d2c9fe3df
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_move_typemaps_runme.rb
@@ -0,0 +1,36 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'cpp11_move_typemaps'
+
+Cpp11_move_typemaps::Counter.reset_counts()
+mo = Cpp11_move_typemaps::MoveOnly.new(111)
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 0, 0, 0)
+Cpp11_move_typemaps::MoveOnly.take(mo)
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2)
+mo = nil
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2)
+
+Cpp11_move_typemaps::Counter.reset_counts()
+mo = Cpp11_move_typemaps::MovableCopyable.new(111)
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 0, 0, 0)
+Cpp11_move_typemaps::MovableCopyable.take(mo)
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2)
+mo = nil
+Cpp11_move_typemaps::Counter.check_counts(1, 0, 0, 1, 0, 2)
+
+mo = Cpp11_move_typemaps::MoveOnly.new(222)
+Cpp11_move_typemaps::MoveOnly.take(mo)
+exception_thrown = false
+begin
+ Cpp11_move_typemaps::MoveOnly.take(mo)
+rescue RuntimeError => e
+ if (!e.to_s.include? "cannot release ownership as memory is not owned")
+ raise RuntimeError, "incorrect exception message: #{e.to_s}"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error"
+end
diff --git a/Examples/test-suite/ruby/cpp11_rvalue_reference_move_runme.rb b/Examples/test-suite/ruby/cpp11_rvalue_reference_move_runme.rb
new file mode 100644
index 000000000..0a423d6c4
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_rvalue_reference_move_runme.rb
@@ -0,0 +1,106 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'cpp11_rvalue_reference_move'
+
+# Function containing rvalue reference parameter
+Cpp11_rvalue_reference_move::Counter.reset_counts()
+mo = Cpp11_rvalue_reference_move::MovableCopyable.new(222)
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 0, 0, 0)
+Cpp11_rvalue_reference_move::MovableCopyable.movein(mo)
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 1, 0, 2)
+exception_thrown = false
+begin
+ Cpp11_rvalue_reference_move::MovableCopyable.is_nullptr(mo)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+mo = nil
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 1, 0, 2)
+
+# Move constructor test
+Cpp11_rvalue_reference_move::Counter.reset_counts()
+mo = Cpp11_rvalue_reference_move::MovableCopyable.new(222)
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 0, 0, 0)
+mo_moved = Cpp11_rvalue_reference_move::MovableCopyable.new(mo)
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 1, 0, 1)
+exception_thrown = false
+begin
+ Cpp11_rvalue_reference_move::MovableCopyable.is_nullptr(mo)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+mo = nil
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 1, 0, 1)
+# mo_moved = nil
+# Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 1, 0, 2)
+# Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
+Cpp11_rvalue_reference_move::MovableCopyable.movein(mo_moved)
+Cpp11_rvalue_reference_move::Counter.check_counts(1, 0, 0, 2, 0, 3)
+
+# Move assignment operator test
+Cpp11_rvalue_reference_move::Counter.reset_counts()
+mo111 = Cpp11_rvalue_reference_move::MovableCopyable.new(111)
+mo222 = Cpp11_rvalue_reference_move::MovableCopyable.new(222)
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 0, 0)
+mo111.MoveAssign(mo222)
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 1, 1)
+exception_thrown = false
+begin
+ Cpp11_rvalue_reference_move::MovableCopyable.is_nullptr(mo222)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+mo222 = nil
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 1, 1)
+# mo111 = nil
+# Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 1, 2)
+# Above not deleting the C++ object(node v12) - can't reliably control GC - use the movein function instead to delete
+Cpp11_rvalue_reference_move::MovableCopyable.movein(mo111)
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 1, 1, 3)
+
+# null check
+Cpp11_rvalue_reference_move::Counter.reset_counts()
+exception_thrown = false
+begin
+ Cpp11_rvalue_reference_move::MovableCopyable.movein(nil)
+rescue ArgumentError => e
+ if (!e.to_s.include? "invalid null reference")
+ raise RuntimeError, "incorrect exception message: #{e.to_s}"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown null error"
+end
+Cpp11_rvalue_reference_move::Counter.check_counts(0, 0, 0, 0, 0, 0)
+
+# output
+Cpp11_rvalue_reference_move::Counter.reset_counts()
+mc = Cpp11_rvalue_reference_move::MovableCopyable.moveout(1234)
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 1, 1)
+Cpp11_rvalue_reference_move::MovableCopyable.check_numbers_match(mc, 1234)
+
+exception_thrown = false
+begin
+ Cpp11_rvalue_reference_move::MovableCopyable.movein(mc)
+rescue RuntimeError => e
+ if (!e.to_s.include? "cannot release ownership as memory is not owned")
+ raise RuntimeError, "incorrect exception message: #{e.to_s}"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error"
+end
+Cpp11_rvalue_reference_move::Counter.check_counts(2, 0, 0, 0, 1, 1)
diff --git a/Examples/test-suite/ruby/cpp11_std_unique_ptr_runme.rb b/Examples/test-suite/ruby/cpp11_std_unique_ptr_runme.rb
new file mode 100644
index 000000000..59e9691be
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_std_unique_ptr_runme.rb
@@ -0,0 +1,151 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'cpp11_std_unique_ptr'
+
+def gc_check(expected_count)
+# GC.start(full_mark: true, immediate_sweep: true)
+ GC.start
+# GC is not reliably run, skip check
+# swig_assert_equal_simple(expected_count, Cpp11_std_unique_ptr::Klass::getTotal_count())
+end
+
+def checkCount(expected_count)
+ actual_count = Cpp11_std_unique_ptr::Klass.getTotal_count()
+ if (actual_count != expected_count)
+ raise RuntimeError, "Counts incorrect, expected:" + expected_count + " actual:" + actual_count
+ end
+end
+
+# Test raw pointer handling involving virtual inheritance
+kini = Cpp11_std_unique_ptr::KlassInheritance.new("KlassInheritanceInput")
+checkCount(1)
+s = Cpp11_std_unique_ptr.useKlassRawPtr(kini)
+if (s != "KlassInheritanceInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+# kini = nil
+Cpp11_std_unique_ptr.takeKlassUniquePtr(kini) # Ensure object is deleted (can't rely on GC)
+checkCount(0)
+
+
+# unique_ptr as input
+kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
+checkCount(1)
+s = Cpp11_std_unique_ptr.takeKlassUniquePtr(kin)
+checkCount(0)
+if (s != "KlassInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Cpp11_std_unique_ptr.is_nullptr(kin)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+kin = nil
+checkCount(0)
+
+kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
+checkCount(1)
+s = Cpp11_std_unique_ptr.takeKlassUniquePtr(kin)
+checkCount(0)
+if (s != "KlassInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Cpp11_std_unique_ptr.is_nullptr(kin)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+exception_thrown = false
+begin
+ Cpp11_std_unique_ptr.takeKlassUniquePtr(kin)
+rescue RuntimeError => e
+ # puts e.message
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "double usage of takeKlassUniquePtr should have been an error"
+end
+kin = nil
+checkCount(0)
+
+kin = Cpp11_std_unique_ptr::Klass.new("KlassInput")
+exception_thrown = false
+notowned = Cpp11_std_unique_ptr::get_not_owned_ptr(kin)
+begin
+ Cpp11_std_unique_ptr::takeKlassUniquePtr(notowned)
+rescue RuntimeError => e
+ if (!e.to_s.include? "cannot release ownership as memory is not owned")
+ raise RuntimeError, "incorrect exception message"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error"
+end
+checkCount(1)
+Cpp11_std_unique_ptr.takeKlassUniquePtr(kin) # Ensure object is deleted (can't rely on GC)
+checkCount(0)
+
+kini = Cpp11_std_unique_ptr::KlassInheritance.new("KlassInheritanceInput")
+checkCount(1)
+s = Cpp11_std_unique_ptr.takeKlassUniquePtr(kini)
+checkCount(0)
+if (s != "KlassInheritanceInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Cpp11_std_unique_ptr.is_nullptr(kini)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+kini = nil
+checkCount(0)
+
+Cpp11_std_unique_ptr::takeKlassUniquePtr(nil)
+Cpp11_std_unique_ptr::takeKlassUniquePtr(Cpp11_std_unique_ptr::make_null())
+checkCount(0)
+
+# overloaded parameters
+if (Cpp11_std_unique_ptr::overloadTest() != 0)
+ raise RuntimeError, "overloadTest failed"
+end
+if (Cpp11_std_unique_ptr::overloadTest(nil) != 1)
+ raise RuntimeError, "overloadTest failed"
+end
+if (Cpp11_std_unique_ptr::overloadTest(Cpp11_std_unique_ptr::Klass.new("over")) != 1)
+ raise RuntimeError, "overloadTest failed"
+end
+checkCount(0);
+
+
+# unique_ptr as output
+k1 = Cpp11_std_unique_ptr::makeKlassUniquePtr("first")
+k2 = Cpp11_std_unique_ptr::makeKlassUniquePtr("second")
+swig_assert_equal_simple(2, Cpp11_std_unique_ptr::Klass::getTotal_count())
+
+gc_check(2)
+k1 = nil
+gc_check(1)
+
+swig_assert_equal_simple(k2.getLabel(), "second")
+gc_check(1)
+
+k2 = nil
+gc_check(0)
+
+swig_assert_equal_simple(Cpp11_std_unique_ptr::makeNullUniquePtr(), nil)
diff --git a/Examples/test-suite/ruby/cpp11_using_constructor_runme.rb b/Examples/test-suite/ruby/cpp11_using_constructor_runme.rb
new file mode 100644
index 000000000..b38a0ec35
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp11_using_constructor_runme.rb
@@ -0,0 +1,129 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'cpp11_using_constructor'
+
+include Cpp11_using_constructor
+
+# Public base constructors
+a = PublicDerived1.new(0, "hi").meth()
+a = PublicDerived2.new().meth()
+a = PublicDerived2.new(0, "hi").meth()
+a = PublicDerived3.new().meth()
+a = PublicDerived3.new(0, "hi").meth()
+a = PublicDerived4.new().meth()
+a = PublicDerived5.new().meth()
+
+# Protected base constructors
+# Cannot test most of these as the constructors are protected
+ProtectedDerived5.new()
+
+# Mix of public and overloaded constructors
+MixedDerived1a.new(0, "hi").meth()
+MixedDerived1a.new().meth()
+MixedDerived1b.new(0, "hi").meth()
+MixedDerived1b.new().meth()
+
+MixedDerived2a.new(0, "hi").meth()
+MixedDerived2a.new().meth()
+MixedDerived2b.new(0, "hi").meth()
+MixedDerived2b.new().meth()
+
+MixedDerived2c.new(0, "hi").meth()
+MixedDerived2c.new().meth()
+MixedDerived2c.new(0).meth()
+
+MixedDerived2d.new(0, "hi").meth()
+MixedDerived2d.new().meth()
+MixedDerived2d.new(0).meth()
+
+MixedDerived3a.new(0, "hi").meth()
+MixedDerived3a.new().meth()
+MixedDerived3b.new(0, "hi").meth()
+MixedDerived3b.new().meth()
+
+MixedDerived3c.new(0, "hi").meth()
+MixedDerived3c.new().meth()
+MixedDerived3c.new(0).meth()
+
+MixedDerived3d.new(0, "hi").meth()
+MixedDerived3d.new().meth()
+MixedDerived3d.new(0).meth()
+
+MixedDerived4a.new(0, "hi").meth()
+MixedDerived4a.new().meth()
+MixedDerived4b.new(0, "hi").meth()
+MixedDerived4b.new().meth()
+
+MixedDerived4c.new().meth()
+MixedDerived4c.new(0).meth()
+
+MixedDerived4d.new().meth()
+MixedDerived4d.new(0).meth()
+
+MixedDerived4e.new().meth()
+
+MixedDerived4f.new().meth()
+
+# Mix of protected base constructors and overloading
+ProotDerived1a.new().meth()
+
+ProotDerived1b.new(0, "hi").meth()
+ProotDerived1b.new().meth()
+
+ProotDerived1c.new(0, "hi").meth()
+ProotDerived1c.new().meth()
+
+ProotDerived1d.new(0).meth()
+ProotDerived1d.new().meth()
+
+ProotDerived1e.new(0).meth()
+ProotDerived1e.new().meth()
+
+ProotDerived2a.new(0, "hi").meth()
+
+ProotDerived2b.new(0, "hi").meth()
+
+ProotDerived2c.new(0, "hi").meth()
+ProotDerived2c.new().meth()
+
+ProotDerived2d.new(0, "hi").meth()
+ProotDerived2d.new().meth()
+
+ProotDerived2e.new(0, "hi").meth()
+ProotDerived2e.new().meth()
+
+ProotDerived2f.new(0, "hi").meth()
+ProotDerived2f.new().meth()
+ProotDerived2f.new(0).meth()
+
+# Missing base
+# HiddenDerived1()
+
+# Templates and public base constructors (derive from non-template)
+TemplatePublicDerived1Int.new(0, "hi").meth()
+TemplatePublicDerived2Int.new().meth()
+TemplatePublicDerived2Int.new(0, "hi").meth()
+TemplatePublicDerived3Int.new().meth()
+TemplatePublicDerived3Int.new(0, "hi").meth()
+TemplatePublicDerived4Int.new().meth()
+TemplatePublicDerived5Int.new().meth()
+
+# Templates and public base constructors (derive from template)
+TemplPublicDerived1Int.new(0, "hi").meth()
+TemplPublicDerived2Int.new().meth()
+TemplPublicDerived2Int.new(0, "hi").meth()
+TemplPublicDerived3Int.new().meth()
+TemplPublicDerived3Int.new(0, "hi").meth()
+TemplPublicDerived4Int.new().meth()
+TemplPublicDerived5Int.new().meth()
+TemplPublicDerived6Int.new(0, "hi").meth()
+TemplPublicDerived6Int.new().meth()
diff --git a/Examples/test-suite/ruby/cpp17_director_string_view_runme.rb b/Examples/test-suite/ruby/cpp17_director_string_view_runme.rb
new file mode 100644
index 000000000..911d9f70d
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp17_director_string_view_runme.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'cpp17_director_string_view'
+
+class B < Cpp17_director_string_view::A
+ attr_accessor :smem
+
+ def initialize(some_string)
+ super(some_string)
+ end
+
+ def get_first()
+ # Since std::string_view contains a pointer into a string, the string
+ # cannot be a temporary in order to avoid undefined behaviour.
+ @cached_string = super() + " world!"
+ return @cached_string
+ end
+
+ def process_text(string)
+ super(string)
+ @smem = "hello"
+ end
+
+end
+
+
+b = B.new("hello")
+raise RuntimeError if b.get(0) != "hello"
+raise RuntimeError if b.get_first() != "hello world!"
+raise RuntimeError if b.call_get_first() != "hello world!"
+
+b.call_process_func()
+raise RuntimeError if b.smem != "hello"
diff --git a/Examples/test-suite/ruby/cpp17_nested_namespaces_runme.rb b/Examples/test-suite/ruby/cpp17_nested_namespaces_runme.rb
new file mode 100644
index 000000000..e9e841179
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp17_nested_namespaces_runme.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'cpp17_nested_namespaces'
+
+Cpp17_nested_namespaces::A1Struct.new.A1Method
+Cpp17_nested_namespaces::B1Struct.new.B1Method
+Cpp17_nested_namespaces::C1Struct.new.C1Method
+
+Cpp17_nested_namespaces.createA1Struct().A1Method
+Cpp17_nested_namespaces.createB1Struct().B1Method
+Cpp17_nested_namespaces.createC1Struct().C1Method
+
+Cpp17_nested_namespaces::B2Struct.new.B2Method
+Cpp17_nested_namespaces::C2Struct.new.C2Method
+Cpp17_nested_namespaces.createB2Struct().B2Method
+Cpp17_nested_namespaces.createC2Struct().C2Method
+
+Cpp17_nested_namespaces::B3Struct.new.B3Method
+Cpp17_nested_namespaces::C3Struct.new.C3Method
+Cpp17_nested_namespaces.createB3Struct().B3Method
+Cpp17_nested_namespaces.createC3Struct().C3Method
diff --git a/Examples/test-suite/ruby/cpp17_string_view_runme.rb b/Examples/test-suite/ruby/cpp17_string_view_runme.rb
new file mode 100644
index 000000000..3c071e550
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp17_string_view_runme.rb
@@ -0,0 +1,119 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+require 'cpp17_string_view'
+
+include Cpp17_string_view
+
+# Checking expected use of %typemap(in) std::string_view {}
+test_value("Fee")
+
+# Checking expected result of %typemap(out) std::string_view {}
+raise RuntimeError unless test_value("Fi") == "Fi"
+
+# Verify type-checking for %typemap(in) std::string_view {}
+exceptionRaised = false
+begin
+ test_value(0)
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+# Checking expected use of %typemap(in) const std::string_view & {}
+test_const_reference("Fo")
+
+# Checking expected result of %typemap(out) const std::string_view& {}
+raise RuntimeError unless test_const_reference("Fum") == "Fum"
+
+# Verify type-checking for %typemap(in) const std::string_view & {}
+exceptionRaised = false
+begin
+ test_const_reference(0)
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+#
+# Input and output typemaps for pointers and non-const references to
+# std::string_view are *not* supported; the following tests confirm
+# that none of these cases are slipping through.
+#
+
+exceptionRaised = false
+begin
+ test_pointer("foo")
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+result = test_pointer_out()
+raise RuntimeError if result.is_a? String
+
+exceptionRaised = false
+begin
+ test_const_pointer("bar")
+rescue TypeError
+ exceptionRaised = true
+ensure
+ raise RuntimeError unless exceptionRaised
+end
+
+result = test_const_pointer_out()
+raise RuntimeError if result.is_a? String
+
+result = test_reference_out()
+raise RuntimeError if result.is_a? String
+
+
+# Member Strings
+myStructure = Structure.new
+if (myStructure.ConstMemberString != "const member string")
+ raise RuntimeError
+end
+
+
+if (Structure.ConstStaticMemberString != "const static member string")
+ raise RuntimeError
+end
+
+
+if (stdstringview_empty() != "")
+ puts "raise RuntimeError"
+end
+
+if (c_empty() != "")
+ raise RuntimeError
+end
+
+
+if (c_null() != nil)
+ raise RuntimeError
+end
+
+
+if (get_null(c_null()) != nil)
+ raise RuntimeError
+end
+
+
+if (get_null(c_empty()) != "non-null")
+ raise RuntimeError
+end
+
+if (get_null(stdstringview_empty()) != "non-null")
+ raise RuntimeError
+end
diff --git a/Examples/test-suite/ruby/cpp_enum_runme.rb b/Examples/test-suite/ruby/cpp_enum_runme.rb
new file mode 100644
index 000000000..0a395e0e0
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp_enum_runme.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'cpp_enum'
+
+f = Cpp_enum::Foo.new
+swig_assert_equal('f.hola', 'Cpp_enum::Foo::Hello', binding)
+
+f.hola = Cpp_enum::Foo::Hi
+swig_assert_equal('f.hola', 'Cpp_enum::Foo::Hi', binding)
+
+f.hola = Cpp_enum::Foo::Hello
+swig_assert_equal('f.hola', 'Cpp_enum::Foo::Hello', binding)
+
+Cpp_enum::hi = Cpp_enum::Hello
+swig_assert_equal('Cpp_enum::hi', 'Cpp_enum::Hello', binding)
diff --git a/Examples/test-suite/ruby/cpp_static_runme.rb b/Examples/test-suite/ruby/cpp_static_runme.rb
new file mode 100644
index 000000000..85bdb7028
--- /dev/null
+++ b/Examples/test-suite/ruby/cpp_static_runme.rb
@@ -0,0 +1,26 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'cpp_static'
+
+Cpp_static::StaticFunctionTest.static_func()
+Cpp_static::StaticFunctionTest.static_func_2(1)
+Cpp_static::StaticFunctionTest.static_func_3(1, 2)
+
+swig_assert_equal("Cpp_static::StaticMemberTest.static_int", "99", binding)
+Cpp_static::StaticMemberTest.static_int = 10
+swig_assert_equal("Cpp_static::StaticMemberTest.static_int", "10", binding)
+
+swig_assert_equal("Cpp_static::StaticBase.statty", "11", binding)
+swig_assert_equal("Cpp_static::StaticBase.grab_statty_base", "11", binding)
+swig_assert_equal("Cpp_static::StaticDerived.statty", "111", binding)
+swig_assert_equal("Cpp_static::StaticDerived.grab_statty_derived", "111", binding)
+Cpp_static::StaticBase.statty = 22
+Cpp_static::StaticDerived.statty = 222
+swig_assert_equal("Cpp_static::StaticBase.statty", "22", binding)
+swig_assert_equal("Cpp_static::StaticBase.grab_statty_base", "22", binding)
+swig_assert_equal("Cpp_static::StaticDerived.statty", "222", binding)
+swig_assert_equal("Cpp_static::StaticDerived.grab_statty_derived", "222", binding)
diff --git a/Examples/test-suite/ruby/director_string_runme.rb b/Examples/test-suite/ruby/director_string_runme.rb
index a18feac3d..f3f65f4c1 100644
--- a/Examples/test-suite/ruby/director_string_runme.rb
+++ b/Examples/test-suite/ruby/director_string_runme.rb
@@ -12,13 +12,28 @@ require 'swig_assert'
require 'director_string'
class B < Director_string::A
+ attr_accessor :smem
def initialize(some_string)
super(some_string)
end
+
+ def get_first()
+ return super() + " world!"
+ end
+
+ def process_text(string)
+ super(string)
+ @smem = "hello"
+ end
+
end
b = B.new("hello")
-b.get_first
-b.get(0)
+raise RuntimeError if b.get(0) != "hello"
+raise RuntimeError if b.get_first() != "hello world!"
+raise RuntimeError if b.call_get_first() != "hello world!"
+
+b.call_process_func()
+raise RuntimeError if b.smem != "hello"
diff --git a/Examples/test-suite/ruby/director_unwrap_result_runme.rb b/Examples/test-suite/ruby/director_unwrap_result_runme.rb
new file mode 100644
index 000000000..26206ae5c
--- /dev/null
+++ b/Examples/test-suite/ruby/director_unwrap_result_runme.rb
@@ -0,0 +1,120 @@
+#!/usr/bin/env ruby
+#
+# This test checks the proper unwrapping of director objects before returning
+# a pointer to the (wrapped) instance.
+# Unwrapping must not happen for return-by-value and returning higher
+# reference levels (pointer to pointer, reference to pointer, etc.), but this
+# is already checked by the C++ compiler.
+#
+
+require 'swig_assert'
+
+require 'director_unwrap_result'
+
+############################
+# test with a regular (non-template) class
+
+class MyElement < Director_unwrap_result::Element
+end
+
+class MyStorage < Director_unwrap_result::Storage
+ def initialize(e)
+ super()
+ @elem = e
+ end
+ def getIt
+ @elem.getPtrPtr
+ end
+end
+
+e = MyElement.new
+s = MyStorage.new(e)
+
+swig_assert_equal('s.getElement.class', 'Director_unwrap_result::Element', binding)
+swig_assert('s.getElement != e', binding)
+
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getElementPtr.class', 'MyElement', binding)
+swig_assert_equal('s.getElementPtr', 'e', binding)
+
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getElementRef.class', 'MyElement', binding)
+swig_assert_equal('s.getElementRef', 'e', binding)
+
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getElementPtrTypedef.class', 'MyElement', binding)
+swig_assert_equal('s.getElementPtrTypedef', 'e', binding)
+
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getElementRefTypedef.class', 'MyElement', binding)
+swig_assert_equal('s.getElementRefTypedef', 'e', binding)
+
+# this is not unwrapped:
+swig_assert_equal('s.getElementPtrPtr.class', 'SWIG::TYPE_p_p_Element', binding)
+swig_assert_equal('s.getElementPtrPtr.class', 'SWIG::TYPE_p_p_Element', binding)
+
+# this is not unwrapped:
+swig_assert_equal('s.getElementPtrRef.class', 'SWIG::TYPE_p_p_Element', binding)
+swig_assert_equal('s.getElementPtrRef.class', 'SWIG::TYPE_p_p_Element', binding)
+
+# this is not unwrapped:
+swig_assert_equal('s.getElementPtrRefTypedef.class', 'SWIG::TYPE_p_p_Element', binding)
+swig_assert_equal('s.getElementPtrRefTypedef.class', 'SWIG::TYPE_p_p_Element', binding)
+
+############################
+# test with a template class
+
+class MyElementStorage < Director_unwrap_result::ElementStorage
+ def initialize(e)
+ super()
+ @elem = e
+ end
+ def getIt
+ @elem
+ end
+end
+
+class MyElementPtrStorage < Director_unwrap_result::ElementPtrStorage
+ def initialize(e)
+ super()
+ @elem = e
+ end
+ def getIt
+ @elem.getPtrPtr
+ end
+end
+
+class MyElementPtrPtrStorage < Director_unwrap_result::ElementPtrPtrStorage
+ def initialize(e)
+ super()
+ @elem = e
+ end
+ def getIt
+ @elem.getPtrPtrPtr
+ end
+end
+
+e = MyElement.new
+
+s = MyElementStorage.new(e)
+swig_assert_equal('s.getVal.class', 'Director_unwrap_result::Element', binding)
+swig_assert('s.getVal != e', binding)
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getPtr.class', 'MyElement', binding)
+swig_assert_equal('s.getPtr', 'e', binding)
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getRef.class', 'MyElement', binding)
+swig_assert_equal('s.getRef', 'e', binding)
+
+s = MyElementPtrStorage.new(e)
+# this shows that the director class was unwrapped:
+swig_assert_equal('s.getVal.class', 'MyElement', binding)
+swig_assert_equal('s.getVal', 'e', binding)
+swig_assert_equal('s.getPtr.class', 'SWIG::TYPE_p_p_Element', binding)
+swig_assert_equal('s.getRef.class', 'SWIG::TYPE_p_p_Element', binding)
+
+s = MyElementPtrPtrStorage.new(e)
+swig_assert_equal('s.getVal.class', 'SWIG::TYPE_p_p_Element', binding)
+swig_assert_equal('s.getPtr.class', 'SWIG::TYPE_p_p_p_Element', binding)
+swig_assert_equal('s.getRef.class', 'SWIG::TYPE_p_p_p_Element', binding)
+
diff --git a/Examples/test-suite/ruby/enums_runme.rb b/Examples/test-suite/ruby/enums_runme.rb
index cafac25fa..274d59568 100644
--- a/Examples/test-suite/ruby/enums_runme.rb
+++ b/Examples/test-suite/ruby/enums_runme.rb
@@ -25,10 +25,7 @@ Enums::BAR1 == 0
Enums::BAR2 == 1
EOF
-#
-# @bug:
-#
-# swig_assert_each_line( <<EOF )
-# Enums::IFoo::Phoo == 50
-# Enums::IFoo::Char == 'a'[0]
-# EOF
+swig_assert_each_line( <<EOF )
+Enums::Phoo == 50
+Enums::Char == 'a'[0]
+EOF
diff --git a/Examples/test-suite/ruby/friends_runme.rb b/Examples/test-suite/ruby/friends_runme.rb
index c5c1caa01..232bb68ee 100644
--- a/Examples/test-suite/ruby/friends_runme.rb
+++ b/Examples/test-suite/ruby/friends_runme.rb
@@ -17,3 +17,6 @@ a = Friends::A.new(2)
raise RuntimeError if Friends::get_val1(a) != 2
raise RuntimeError if Friends::get_val2(a) != 4
raise RuntimeError if Friends::get_val3(a) != 6
+
+raise RuntimeError if Friends.chum_blah() != 1234
+raise RuntimeError if Friends.mate_blah() != 4321
diff --git a/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
new file mode 100644
index 000000000..7897f7da5
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+#
+# C++ version of global_immutable_vars_runme.rb
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var == 40
+Global_immutable_vars_cpp::global_immutable_var == 41
+Global_immutable_vars_cpp::specific_mutable_var == 42
+Global_immutable_vars_cpp::global_mutable_var == 43
+Global_immutable_vars_cpp::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars_cpp::default_mutable_var = 80
+Global_immutable_vars_cpp::default_mutable_var == 80
+Global_immutable_vars_cpp::specific_mutable_var = 82
+Global_immutable_vars_cpp::specific_mutable_var == 82
+Global_immutable_vars_cpp::global_mutable_var = 83
+Global_immutable_vars_cpp::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars_cpp::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars_cpp::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars_cpp::specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(Global_immutable_vars_cpp::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/global_immutable_vars_runme.rb b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
new file mode 100644
index 000000000..ffbea270f
--- /dev/null
+++ b/Examples/test-suite/ruby/global_immutable_vars_runme.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+#
+# Here the proper generation of mutable and immutable variables is tested
+# in the target language.
+# Immutable variables do not have "<var>=" methods generated by SWIG,
+# therefore trying to assign these variables shall throw a NoMethodError
+# exception.
+#
+
+require 'swig_assert'
+
+require 'global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var == 40
+Global_immutable_vars::global_immutable_var == 41
+Global_immutable_vars::specific_mutable_var == 42
+Global_immutable_vars::global_mutable_var == 43
+Global_immutable_vars::specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+Global_immutable_vars::default_mutable_var = 80
+Global_immutable_vars::default_mutable_var == 80
+Global_immutable_vars::specific_mutable_var = 82
+Global_immutable_vars::specific_mutable_var == 82
+Global_immutable_vars::global_mutable_var = 83
+Global_immutable_vars::global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ Global_immutable_vars::global_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ Global_immutable_vars::specific_immutable_var = 81
+rescue NoMethodError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "Global_immutable_vars::specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(Global_immutable_vars::check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/ignore_parameter_runme.rb b/Examples/test-suite/ruby/ignore_parameter_runme.rb
index c5466a2a6..1d1e0bac0 100644
--- a/Examples/test-suite/ruby/ignore_parameter_runme.rb
+++ b/Examples/test-suite/ruby/ignore_parameter_runme.rb
@@ -25,6 +25,7 @@ raise RuntimeError unless sc.daimler(0, 1.0) == "hello"
raise RuntimeError unless sc.astonmartin("foo", 1.0) == 101
raise RuntimeError unless sc.bugatti("foo", 0) == 8.8
raise RuntimeError unless sc.lamborghini() == 101
+raise RuntimeError unless sc.audi() == 8.8
# Constructor tests
MiniCooper.new(0, 1.0)
diff --git a/Examples/test-suite/ruby/import_fragments_runme.rb b/Examples/test-suite/ruby/import_fragments_runme.rb
new file mode 100644
index 000000000..a529980c0
--- /dev/null
+++ b/Examples/test-suite/ruby/import_fragments_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# Put description here
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+
+exception_file = nil
+
+begin
+ require 'import_fragments'
+rescue LoadError => e
+ # due to missing import_fragments_a
+ exception_file = e.respond_to?(:path) ? e.path : e.to_s.sub(/.* -- /, '')
+end
+
+swig_assert(exception_file == "import_fragments_a",
+ msg: "Loading should have failed due to missing 'import_fragments_a'")
+
diff --git a/Examples/test-suite/ruby/li_constraints_runme.rb b/Examples/test-suite/ruby/li_constraints_runme.rb
new file mode 100644
index 000000000..a4dcd685a
--- /dev/null
+++ b/Examples/test-suite/ruby/li_constraints_runme.rb
@@ -0,0 +1,63 @@
+#!/usr/bin/env ruby
+
+require 'li_constraints'
+include Li_constraints
+
+def check_double(except, fn, f, val)
+ actual = true
+ proper = false
+ begin
+ fn.call(val)
+ rescue => e
+ actual = false
+ proper = e.class == ArgumentError && e.message == "Expected a #{f} value."
+ end
+ if actual
+ if !except
+ raise RuntimeError, "function '#{f}' with #{val} should perform an exception"
+ end
+ else
+ if except
+ raise RuntimeError, "function '#{f}' with #{val} should not perform an exception"
+ elsif !proper
+ raise RuntimeError, "function '#{f}' with #{val} should perform a proper exception"
+ end
+ end
+end
+
+nonnegative = -> (v) { test_nonnegative(v) }
+check_double(true, nonnegative, "non-negative", 10)
+check_double(true, nonnegative, "non-negative", 0)
+check_double(false, nonnegative, "non-negative", -10)
+
+nonpositive = -> (v) { test_nonpositive(v) }
+check_double(false, nonpositive, "non-positive", 10)
+check_double(true, nonpositive, "non-positive", 0)
+check_double(true, nonpositive, "non-positive", -10)
+
+positive = -> (v) { test_positive(v) }
+check_double(true, positive, "positive", 10)
+check_double(false, positive, "positive", 0)
+check_double(false, positive, "positive", -10)
+
+negative = -> (v) { test_negative(v) }
+check_double(false, negative, "negative", 10)
+check_double(false, negative, "negative", 0)
+check_double(true, negative, "negative", -10)
+
+nonzero = -> (v) { test_nonzero(v) }
+check_double(true, nonzero, "nonzero", 10)
+check_double(false, nonzero, "nonzero", 0)
+check_double(true, nonzero, "nonzero", -10)
+
+have_exception = false
+begin
+ test_nonnull(nil)
+rescue => e
+ have_exception = e.class == ArgumentError && e.message == "Received a NULL pointer."
+end
+if not have_exception
+ raise RuntimeError, "test_nonnull should perform exception with 'null' value"
+end
+nonnull = get_nonnull()
+test_nonnull(nonnull)
diff --git a/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb
new file mode 100644
index 000000000..48276a888
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_auto_ptr_runme.rb
@@ -0,0 +1,151 @@
+#!/usr/bin/env ruby
+
+require 'swig_assert'
+
+require 'li_std_auto_ptr'
+
+def gc_check(expected_count)
+# GC.start(full_mark: true, immediate_sweep: true)
+ GC.start
+# GC is not reliably run, skip check
+# swig_assert_equal_simple(expected_count, Li_std_auto_ptr::Klass::getTotal_count())
+end
+
+def checkCount(expected_count)
+ actual_count = Li_std_auto_ptr::Klass.getTotal_count()
+ if (actual_count != expected_count)
+ raise RuntimeError, "Counts incorrect, expected:" + expected_count + " actual:" + actual_count
+ end
+end
+
+# Test raw pointer handling involving virtual inheritance
+kini = Li_std_auto_ptr::KlassInheritance.new("KlassInheritanceInput")
+checkCount(1)
+s = Li_std_auto_ptr.useKlassRawPtr(kini)
+if (s != "KlassInheritanceInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+# kini = nil
+Li_std_auto_ptr.takeKlassAutoPtr(kini) # Ensure object is deleted (can't rely on GC)
+checkCount(0)
+
+
+# auto_ptr as input
+kin = Li_std_auto_ptr::Klass.new("KlassInput")
+checkCount(1)
+s = Li_std_auto_ptr.takeKlassAutoPtr(kin)
+checkCount(0)
+if (s != "KlassInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Li_std_auto_ptr.is_nullptr(kin)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+kin = nil
+checkCount(0)
+
+kin = Li_std_auto_ptr::Klass.new("KlassInput")
+checkCount(1)
+s = Li_std_auto_ptr.takeKlassAutoPtr(kin)
+checkCount(0)
+if (s != "KlassInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Li_std_auto_ptr.is_nullptr(kin)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+exception_thrown = false
+begin
+ Li_std_auto_ptr.takeKlassAutoPtr(kin)
+rescue RuntimeError => e
+ # puts e.message
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "double usage of takeKlassAutoPtr should have been an error"
+end
+kin = nil
+checkCount(0)
+
+kin = Li_std_auto_ptr::Klass.new("KlassInput")
+exception_thrown = false
+notowned = Li_std_auto_ptr::get_not_owned_ptr(kin)
+begin
+ Li_std_auto_ptr::takeKlassAutoPtr(notowned)
+rescue RuntimeError
+ if (!e.to_s.include? "cannot release ownership as memory is not owned")
+ raise RuntimeError, "incorrect exception message"
+ end
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "Should have thrown 'Cannot release ownership as memory is not owned' error"
+end
+checkCount(1)
+Li_std_auto_ptr.takeKlassAutoPtr(kin) # Ensure object is deleted (can't rely on GC)
+checkCount(0)
+
+kini = Li_std_auto_ptr::KlassInheritance.new("KlassInheritanceInput")
+checkCount(1)
+s = Li_std_auto_ptr.takeKlassAutoPtr(kini)
+checkCount(0)
+if (s != "KlassInheritanceInput")
+ raise RuntimeError, "Incorrect string: " + s
+end
+exception_thrown = false
+begin
+ Li_std_auto_ptr.is_nullptr(kini)
+rescue ObjectPreviouslyDeleted
+ exception_thrown = true
+end
+if (!exception_thrown)
+ raise RuntimeError, "is_nullptr failed to throw"
+end
+kini = nil
+checkCount(0)
+
+Li_std_auto_ptr::takeKlassAutoPtr(nil)
+Li_std_auto_ptr::takeKlassAutoPtr(Li_std_auto_ptr::make_null())
+checkCount(0)
+
+# overloaded parameters
+if (Li_std_auto_ptr::overloadTest() != 0)
+ raise RuntimeError, "overloadTest failed"
+end
+if (Li_std_auto_ptr::overloadTest(nil) != 1)
+ raise RuntimeError, "overloadTest failed"
+end
+if (Li_std_auto_ptr::overloadTest(Li_std_auto_ptr::Klass.new("over")) != 1)
+ raise RuntimeError, "overloadTest failed"
+end
+checkCount(0);
+
+
+# auto_ptr as output
+k1 = Li_std_auto_ptr::makeKlassAutoPtr("first")
+k2 = Li_std_auto_ptr::makeKlassAutoPtr("second")
+swig_assert_equal_simple(2, Li_std_auto_ptr::Klass::getTotal_count())
+
+gc_check(2)
+k1 = nil
+gc_check(1)
+
+swig_assert_equal_simple(k2.getLabel(), "second")
+gc_check(1)
+
+k2 = nil
+gc_check(0)
+
+swig_assert_equal_simple(Li_std_auto_ptr::makeNullAutoPtr(), nil)
diff --git a/Examples/test-suite/ruby/li_std_containers_int_runme.rb b/Examples/test-suite/ruby/li_std_containers_int_runme.rb
new file mode 100644
index 000000000..73594173c
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_containers_int_runme.rb
@@ -0,0 +1,203 @@
+#!/usr/bin/env ruby
+
+# Check std::vector and std::list behaves the same as Ruby iterable
+# types (list)
+
+require 'swig_assert'
+require 'li_std_containers_int'
+
+def failed(a, b, msg)
+ # to_a() convert to array
+ # convert to array, so we can call join().
+ # join() join array element to string with a seperator.
+ raise RuntimeError, msg+" ["+a.to_a().join(", ")+"] ["+b.to_a().join(", ")+"]"
+end
+
+def compare_sequences(a, b)
+ # A start, out of range, may produce nil value
+ # As long as vector behave as list, we do not care :-)
+ if a == nil and b == nil then
+ return
+ end
+ if a.size != b.size then
+ failed(a, b, "different sizes")
+ end
+ a.each_index do |i|
+ if a[i] != b[i] then
+ failed(a, b, "elements are different")
+ end
+ end
+end
+
+def compare_containers(pythonlist, swigvector, swiglist)
+ compare_sequences(pythonlist, swigvector)
+ compare_sequences(pythonlist, swiglist)
+end
+
+# Check std::vector and std::list assignment behaves same as Ruby list
+# assignment including exceptions
+def container_insert_step(i, l, newval)
+ ps = (1..6).to_a
+ iv = Li_std_containers_int::Vector_int.new(ps)
+ il = Li_std_containers_int::List_int.new(ps)
+
+ # Ruby slice
+ begin
+ if l == nil then
+ ps[i] = newval
+ else
+ ps[i,l] = newval
+ end
+ ps_error = nil
+ rescue => e
+ ps_error = e
+ end
+
+ begin
+ if l == nil then
+ iv[i] = newval
+ else
+ iv[i,l] = newval
+ end
+ iv_error = nil
+ rescue => e
+ iv_error = e
+ end
+
+ begin
+ if l == nil then
+ il[i] = newval
+ else
+ il[i,l] = newval
+ end
+ il_error = nil
+ rescue => e
+ il_error = e
+ end
+
+ if iv_error != nil and il_error == nil then
+ raise RuntimeError, "ValueError std::vector<> fails while std::list<> pass: " + iv_error.to_s
+ end
+ if iv_error == nil and il_error != nil then
+ raise RuntimeError, "ValueError std::vector<> pass while std::list<> fail: " + il_error.to_s
+ end
+ if ps_error != nil and iv_error == nil then
+ raise RuntimeError, "ValueError C++ wrapper should fail like ruby: " + ps_error.to_s
+ end
+ if ps_error != nil and iv_error != nil and il_error != nil then
+ compare_containers(ps, iv, il)
+ end
+end
+
+# Check std::vector and std::list delete behaves same as Ruby list
+# delete including exceptions
+def container_delete(i, j)
+ ps = (1..6).to_a
+ iv = Li_std_containers_int::Vector_int.new(ps)
+ il = Li_std_containers_int::List_int.new(ps)
+
+ # Ruby slice
+ begin
+ if j == nil then
+ ps[i] = nil
+ else
+ ps[i,(j - i)] = nil
+ end
+ ps_error = nil
+ rescue => e
+ ps_error = e
+ end
+
+ # std::vector<int>
+ begin
+ if j == nil then
+ iv[i] = nil
+ else
+ iv[i,(j - i)] = nil
+ end
+ iv_error = nil
+ rescue => e
+ iv_error = e
+ end
+
+ # std::list<int>
+ begin
+ if j == nil then
+ il[i] = nil
+ else
+ il[i,(j - i)] = nil
+ end
+ il_error = nil
+ rescue => e
+ il_error = e
+ end
+
+ if iv_error != nil and il_error == nil then
+ raise RuntimeError, "ValueError std::vector<> fails while std::list<> pass: " + iv_error.to_s
+ end
+ if iv_error == nil and il_error != nil then
+ raise RuntimeError, "ValueError std::vector<> pass while std::list<> fail: " + il_error.to_s
+ end
+ if ps_error != nil and iv_error == nil then
+ raise RuntimeError, "ValueError C++ wrapper should fail like ruby: " + ps_error.to_s
+ end
+ if ps_error != nil and iv_error != nil and il_error != nil then
+ compare_containers(ps, iv, il)
+ end
+end
+
+ps = [0, 1, 2, 3, 4, 5]
+iv = Li_std_containers_int::Vector_int.new(ps)
+il = Li_std_containers_int::List_int.new(ps)
+
+# Ruby use array[start, length]
+# slices
+compare_containers(ps[0,0], iv[0,0], il[0,0])
+compare_containers(ps[1,0], iv[1,0], il[1,0])
+compare_containers(ps[1,2], iv[1,2], il[1,2])
+compare_containers(ps[2,2], iv[2,2], il[2,2])
+compare_containers(ps[0,3], iv[0,3], il[0,3])
+compare_containers(ps[3,3], iv[3,3], il[3,3])
+compare_containers(ps[3,7], iv[3,7], il[3,7]) # beyond end of range
+
+# before beginning of range (negative indexing)
+compare_containers(ps[-1,6], iv[-1,6], il[-1,6])
+compare_containers(ps[-2,6], iv[-2,6], il[-2,6])
+compare_containers(ps[-5,6], iv[-5,6], il[-5,6])
+compare_containers(ps[-6,6], iv[-6,6], il[-6,6])
+
+# before beginning of range (negative indexing, negative index is >
+# container size)
+compare_containers(ps[-7,7], iv[-7,7], il[-7,7])
+compare_containers(ps[-100,7], iv[-100,7], il[-100,7])
+
+compare_containers(ps[3,9], iv[3,9], il[3,9])
+compare_containers(ps[0,3], iv[0,3], il[0,3])
+compare_containers(ps, iv, il)
+compare_containers(ps[-3,9], iv[-3,9], il[-3,9])
+compare_containers(ps[-6,9], iv[-6,9], il[-6,9])
+
+# insert sequences (growing, shrinking and staying same size)
+(-6..6).step do |start|
+ # single element set/replace
+ container_insert_step(start, nil, 111)
+ (0..6).step do |len|
+ container_insert_step(start, len, [111, 222, 333, 444, 555, 666, 777])
+ container_insert_step(start, len, [111, 222, 333, 444, 555, 666])
+ container_insert_step(start, len, [111, 222, 333, 444, 555])
+ container_insert_step(start, len, [111, 222, 333, 444])
+ container_insert_step(start, len, [111, 222, 333])
+ container_insert_step(start, len, [111, 222])
+ container_insert_step(start, len, [111])
+ container_insert_step(start, len, [])
+ end
+end
+
+# delete sequences (growing, shrinking and staying same size)
+for start in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]
+ # single element delete
+ container_delete(start, nil)
+ for vend in [-102, -100, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 100, 102]
+ container_delete(start, vend)
+ end
+end
diff --git a/Examples/test-suite/ruby/li_std_functors_runme.rb b/Examples/test-suite/ruby/li_std_functors_runme.rb
index 5623d49f0..a2a7c6f3d 100644
--- a/Examples/test-suite/ruby/li_std_functors_runme.rb
+++ b/Examples/test-suite/ruby/li_std_functors_runme.rb
@@ -63,7 +63,9 @@ def test
yield method(:_map), Li_std_functors::Map
end
-# these should fail and not segfault
+# these should fail and not segfault but currently do segfault with Ruby 2.6
+# in GitHub Actions environment
+if RUBY_VERSION != '2.6.6'
begin
Li_std_functors::Set.new('sd')
rescue
@@ -72,5 +74,4 @@ end
test do |proc, container|
proc.call(container)
end
-
-
+end
diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb
index 0ec8cac84..9661e4cd4 100644
--- a/Examples/test-suite/ruby/li_std_map_runme.rb
+++ b/Examples/test-suite/ruby/li_std_map_runme.rb
@@ -43,6 +43,16 @@ m.each_key { |k| pm[k] = m[k] }
m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) }
EOF
+
+Li_std_map::populate(Li_std_map.MyMap)
+Li_std_map.MyMap["eeeeee"] = 6
+swig_assert( "Li_std_map.MyMap['a'] == 1", binding )
+swig_assert( "Li_std_map.MyMap['aa'] == 2", binding )
+swig_assert( "Li_std_map.MyMap['zzz'] == 3", binding )
+swig_assert( "Li_std_map.MyMap['xxxx'] == 4", binding )
+swig_assert( "Li_std_map.MyMap['aaaaa'] == 5", binding )
+swig_assert( "Li_std_map.MyMap['eeeeee'] == 6", binding )
+
mii = Li_std_map::IntIntMap.new
mii[1] = 1
diff --git a/Examples/test-suite/ruby/li_std_set_runme.rb b/Examples/test-suite/ruby/li_std_set_runme.rb
index efc163bee..455a1706e 100644
--- a/Examples/test-suite/ruby/li_std_set_runme.rb
+++ b/Examples/test-suite/ruby/li_std_set_runme.rb
@@ -56,11 +56,15 @@ m.value == 'c'
s = LanguageSet.new
s.insert([1,2])
s.insert(1)
-s.insert("hello")
+# There is a reference count issue that needs fixing, see https://github.com/swig/swig/issues/2115
+# Workaround is to create hello variable containing a string and use it instead of just "hello"
+hello = "hello"
+s.insert(hello)
#s.to_a == [1,[1,2],'hello'] # sort order: s.sort {|a,b| a.hash <=> b.hash}
# Test above is flawed as LanguageSet sorts by each element's hash, so the order will change from one invocation to the next. Sort a conversion to array instead.
+GC.start
sa = s.to_a.sort { |x, y| x.to_s <=> y.to_s }
-sa == [1,[1,2],'hello']
+sa == [1,[1,2],hello]
EOF
diff --git a/Examples/test-suite/ruby/li_std_string_runme.rb b/Examples/test-suite/ruby/li_std_string_runme.rb
index dc85b5dab..36824a4d7 100644
--- a/Examples/test-suite/ruby/li_std_string_runme.rb
+++ b/Examples/test-suite/ruby/li_std_string_runme.rb
@@ -122,23 +122,34 @@ s = test_reference_inout("hello")
if (s != "hellohello")
raise RuntimeError
end
+if (test_reference_output() != "output")
+ raise RuntimeError
+end
if (stdstring_empty() != "")
raise RuntimeError
end
-if (c_empty() != "")
+if (c_empty() != "")
+ raise RuntimeError
+end
+
+
+if (c_null() != nil)
raise RuntimeError
end
-if (c_null() != nil)
+if (get_null(c_null()) != nil)
raise RuntimeError
end
-if (get_null(c_null()) != nil)
+if (get_null(c_empty()) != "non-null")
raise RuntimeError
end
+if (get_null(stdstring_empty()) != "non-null")
+ raise RuntimeError
+end
diff --git a/Examples/test-suite/ruby/li_std_vector_runme.rb b/Examples/test-suite/ruby/li_std_vector_runme.rb
index 68feb8f1a..dfcf285c3 100644
--- a/Examples/test-suite/ruby/li_std_vector_runme.rb
+++ b/Examples/test-suite/ruby/li_std_vector_runme.rb
@@ -260,3 +260,20 @@ begin
lv = LanguageVector.new('crapola')
rescue
end
+
+# Variables
+vh = VariableHolder.new
+vector_append(vh.instance_variable, 10)
+swig_assert_equal("vh.instance_variable[0]", "10", binding)
+vh.instance_variable.clear
+swig_assert_equal("vh.instance_variable.empty?", "true", binding)
+
+vector_append(VariableHolder.static_variable, 20)
+swig_assert_equal("VariableHolder.static_variable[0]", "20", binding)
+VariableHolder.static_variable.clear
+swig_assert_equal("VariableHolder.static_variable.empty?", "true", binding)
+
+vector_append(Li_std_vector::global_variable, 30)
+swig_assert_equal("Li_std_vector::global_variable[0]", "30", binding)
+Li_std_vector::global_variable.clear
+swig_assert_equal("Li_std_vector::global_variable.empty?", "true", binding)
diff --git a/Examples/test-suite/ruby/li_std_wstring_runme.rb b/Examples/test-suite/ruby/li_std_wstring_runme.rb
index 4922d8d90..170f80ebf 100644
--- a/Examples/test-suite/ruby/li_std_wstring_runme.rb
+++ b/Examples/test-suite/ruby/li_std_wstring_runme.rb
@@ -50,3 +50,10 @@ x = "abc\0def"
swig_assert_equal("Li_std_wstring.test_value(x)", "x", binding)
swig_assert_equal("Li_std_wstring.test_ccvalue(x)", '"abc"', binding)
swig_assert_equal("Li_std_wstring.test_wchar_overload(x)", '"abc"', binding)
+
+ts = Li_std_wstring::Wchar_test_struct.new
+ts.wchar_t_member = h
+swig_assert_equal("ts.wchar_t_member", "h", binding)
+ts.wchar_t_ptr_member = s
+swig_assert_equal("ts.wchar_t_ptr_member", "s", binding)
+
diff --git a/Examples/test-suite/ruby/multiple_inheritance_abstract_runme.rb b/Examples/test-suite/ruby/multiple_inheritance_abstract_runme.rb
new file mode 100644
index 000000000..01e9e6e4e
--- /dev/null
+++ b/Examples/test-suite/ruby/multiple_inheritance_abstract_runme.rb
@@ -0,0 +1,243 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'multiple_inheritance_abstract'
+
+# Test base class as a parameter in Ruby
+
+def jcbase1b(cb1)
+ cb1.cbase1y
+end
+
+def jabase1(ab1)
+ ab1.abase1
+end
+
+def jcbase2(cb2)
+ cb2.cbase2
+end
+
+# test Derived1
+d1 = Multiple_inheritance_abstract::Derived1.new
+swig_assert_equal('d1.cbase1y', '3', binding, 'Derived1::cbase1y() failed')
+swig_assert_equal('d1.cbase2', '4', binding, 'Derived1::cbase2() failed')
+
+# test Derived2
+d2 = Multiple_inheritance_abstract::Derived2.new
+swig_assert_equal('d2.cbase1y', '6', binding, 'Derived2::cbase1y() failed')
+swig_assert_equal('d2.abase1', '5', binding, 'Derived2::cbase1y() failed')
+
+# test Derived3
+d3 = Multiple_inheritance_abstract::Derived3.new
+swig_assert_equal('d3.cbase1y', '7', binding, 'Derived3::cbase1y() failed')
+swig_assert_equal('d3.cbase2', '8', binding, 'Derived3::cbase2() failed')
+swig_assert_equal('d3.abase1', '9', binding, 'Derived3::abase1() failed')
+
+# test Bottom1
+b1 = Multiple_inheritance_abstract::Bottom1.new
+swig_assert_equal('b1.cbase1y', '103', binding, 'Bottom1::cbase1y() failed')
+swig_assert_equal('b1.cbase2', '104', binding, 'Bottom1::cbase2() failed')
+
+# test Bottom2
+b2 = Multiple_inheritance_abstract::Bottom2.new
+swig_assert_equal('b2.cbase1y', '206', binding, 'Bottom2::cbase1y() failed')
+swig_assert_equal('b2.abase1', '205', binding, 'Bottom2::abase1() failed')
+
+# test Bottom3
+b3 = Multiple_inheritance_abstract::Bottom3.new
+swig_assert_equal('b3.cbase1y', '307', binding, 'Bottom3::cbase1y() failed')
+swig_assert_equal('b3.cbase2', '308', binding, 'Bottom3::cbase2() failed')
+swig_assert_equal('b3.abase1', '309', binding, 'Bottom3::abase1() failed')
+
+# test interfaces from C++ classes
+cb1 = Multiple_inheritance_abstract::CBase1.new
+cb2 = Multiple_inheritance_abstract::CBase2.new
+swig_assert_equal('cb1.cbase1y', '1', binding, 'CBase1::cbase1y() failed')
+swig_assert_equal('cb2.cbase2', '2', binding, 'CBase2::cbase2() failed')
+
+# test nspace class as return value
+ab1 = d3.cloneit
+swig_assert_equal('ab1.abase1', '9', binding, 'Derived3::abase1() through ABase1 failed')
+
+# test concrete base class as return value
+cb6 = d2.cloneit
+cb7 = d1.cloneit
+swig_assert_equal('cb6.cbase1y', '6', binding, 'Derived2::cbase1y() through CBase1 failed')
+swig_assert_equal('cb7.cbase2', '4', binding, 'Derived1:cbase2() through ABase1 failed')
+
+# test multi inheritance
+cb3 = Multiple_inheritance_abstract::Derived1.new
+cb4 = Multiple_inheritance_abstract::Derived3.new
+cb5 = Multiple_inheritance_abstract::Derived3.new
+ab6 = Multiple_inheritance_abstract::Derived2.new
+swig_assert_equal('cb3.cbase1y', '3', binding, 'Derived1::cbase1y() through CBase1 failed')
+swig_assert_equal('cb4.cbase1y', '7', binding, 'Derived3::cbase1y() through CBase1 failed')
+swig_assert_equal('cb5.cbase2', '8', binding, 'Derived3::cbase2() through CBase2 failed')
+swig_assert_equal('ab6.abase1', '5', binding, 'Derived2::abase1() through ABase1 failed')
+
+# test base classes as parameter in Ruby
+swig_assert_equal('jcbase1b(d1)', '3', binding, 'jcbase1b() through Derived1 as parameter failed')
+swig_assert_equal('jcbase1b(d2)', '6', binding, 'jcbase1b() through Derived2 as parameter failed')
+swig_assert_equal('jcbase1b(d3)', '7', binding, 'jcbase1b() through Derived3 as parameter failed')
+swig_assert_equal('jcbase2(d1)', '4', binding, 'jcbase2() through Derived1 as parameter failed')
+swig_assert_equal('jcbase2(d3)', '8', binding, 'jcbase2() through Derived3 as parameter failed')
+swig_assert_equal('jabase1(d2)', '5', binding, 'jabase1() through Derived2 as parameter failed')
+swig_assert_equal('jabase1(d3)', '9', binding, 'jabase1() through Derived3 as parameter failed')
+
+# value parameters
+# test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(d1)', '1', binding, 'InputValCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(d2)', '1', binding, 'InputValCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(d3)', '1', binding, 'InputValCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase2(d3)', '2', binding, 'InputValCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase2(d1)', '2', binding, 'InputValCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(cb1)', '1', binding, 'InputValCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase2(cb2)', '2', binding, 'InputValCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(b1)', '1', binding, 'InputValCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(b2)', '1', binding, 'InputValCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase1(b3)', '1', binding, 'InputValCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase2(b3)', '2', binding, 'InputValCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValCBase2(b1)', '2', binding, 'InputValCBase2(), Bottom1 as a parameter failed')
+
+# pointer parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrABase1(d2)', '5', binding, 'InputPtrABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrABase1(d3)', '9', binding, 'InputPtrABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrABase1(b2)', '205', binding, 'InputPtrABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrABase1(b3)', '309', binding, 'InputPtrABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(d1)', '3', binding, 'InputPtrCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(d2)', '6', binding, 'InputPtrCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(d3)', '7', binding, 'InputPtrCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase2(d3)', '8', binding, 'InputPtrCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase2(d1)', '4', binding, 'InputPtrCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(cb1)', '1', binding, 'InputPtrCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase2(cb2)', '2', binding, 'InputPtrCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(b1)', '103', binding, 'InputPtrCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(b2)', '206', binding, 'InputPtrCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase1(b3)', '307', binding, 'InputPtrCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase2(b3)', '308', binding, 'InputPtrCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrCBase2(b1)', '104', binding, 'InputPtrCBase2(), Bottom1 as a parameter failed')
+
+# reference parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_abstract::InputRefABase1(d2)', '5', binding, 'InputRefABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefABase1(d3)', '9', binding, 'InputRefABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefABase1(b2)', '205', binding, 'InputRefABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefABase1(b3)', '309', binding, 'InputRefABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(d1)', '3', binding, 'InputRefCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(d2)', '6', binding, 'InputRefCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(d3)', '7', binding, 'InputRefCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase2(d3)', '8', binding, 'InputRefCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase2(d1)', '4', binding, 'InputRefCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(cb1)', '1', binding, 'InputRefCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase2(cb2)', '2', binding, 'InputRefCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(b1)', '103', binding, 'InputRefCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(b2)', '206', binding, 'InputRefCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase1(b3)', '307', binding, 'InputRefCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase2(b3)', '308', binding, 'InputRefCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefCBase2(b1)', '104', binding, 'InputRefCBase2(), Bottom1 as a parameter failed')
+
+# const reference pointer parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefABase1(d2)', '5', binding, 'InputCPtrRefABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefABase1(d3)', '9', binding, 'InputCPtrRefABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefABase1(b2)', '205', binding, 'InputCPtrRefABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefABase1(b3)', '309', binding, 'InputCPtrRefABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(d1)', '3', binding, 'InputCPtrRefCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(d2)', '6', binding, 'InputCPtrRefCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(d3)', '7', binding, 'InputCPtrRefCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase2(d3)', '8', binding, 'InputCPtrRefCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase2(d1)', '4', binding, 'InputCPtrRefCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(cb1)', '1', binding, 'InputCPtrRefCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase2(cb2)', '2', binding, 'InputCPtrRefCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(b1)', '103', binding, 'InputCPtrRefCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(b2)', '206', binding, 'InputCPtrRefCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase1(b3)', '307', binding, 'InputCPtrRefCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase2(b3)', '308', binding, 'InputCPtrRefCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefCBase2(b1)', '104', binding, 'InputCPtrRefCBase2(), Bottom1 as a parameter failed')
+
+# derived classes as parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived1(d1)', '3+4', binding, 'InputValDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived2(d2)', '6+5', binding, 'InputValDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived3(d3)', '7+8+9', binding, 'InputValDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived1(d1)', '3+4', binding, 'InputRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived2(d2)', '6+5', binding, 'InputRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived3(d3)', '7+8+9', binding, 'InputRefDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived1(d1)', '3+4', binding, 'InputPtrDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived2(d2)', '6+5', binding, 'InputPtrDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived3(d3)', '7+8+9', binding, 'InputPtrDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived1(d1)', '3+4', binding, 'InputCPtrRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived2(d2)', '6+5', binding, 'InputCPtrRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived3(d3)', '7+8+9', binding, 'InputCPtrRefDerived3() failed')
+
+# bottom classes as Derived parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived1(b1)', '3+4', binding, 'InputValDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived2(b2)', '6+5', binding, 'InputValDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValDerived3(b3)', '7+8+9', binding, 'InputValDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived1(b1)', '103+104', binding, 'InputRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived2(b2)', '206+205', binding, 'InputRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefDerived3(b3)', '307+308+309', binding, 'InputRefDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived1(b1)', '103+104', binding, 'InputPtrDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived2(b2)', '206+205', binding, 'InputPtrDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrDerived3(b3)', '307+308+309', binding, 'InputPtrDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived1(b1)', '103+104', binding, 'InputCPtrRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived2(b2)', '206+205', binding, 'InputCPtrRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefDerived3(b3)', '307+308+309', binding, 'InputCPtrRefDerived3() failed')
+
+# bottom classes as Bottom parameters
+swig_assert_equal('Multiple_inheritance_abstract::InputValBottom1(b1)', '103+104', binding, 'InputValBottom1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValBottom2(b2)', '206+205', binding, 'InputValBottom2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputValBottom3(b3)', '307+308+309', binding, 'InputValBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputRefBottom1(b1)', '103+104', binding, 'InputRefBottom1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefBottom2(b2)', '206+205', binding, 'InputRefBottom2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputRefBottom3(b3)', '307+308+309', binding, 'InputRefBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrBottom1(b1)', '103+104', binding, 'InputPtrBottom1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrBottom2(b2)', '206+205', binding, 'InputPtrBottom2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputPtrBottom3(b3)', '307+308+309', binding, 'InputPtrBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefBottom1(b1)', '103+104', binding, 'InputCPtrRefBottom1() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefBottom2(b2)', '206+205', binding, 'InputCPtrRefBottom2() failed')
+swig_assert_equal('Multiple_inheritance_abstract::InputCPtrRefBottom3(b3)', '307+308+309', binding, 'InputCPtrRefBottom3() failed')
+
+# return pointers
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived1_CBase1().cbase1y', '3', binding, 'MakePtrDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived1_CBase2().cbase2', '4', binding, 'MakePtrDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived2_CBase1().cbase1y', '6', binding, 'MakePtrDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived2_ABase1().abase1', '5', binding, 'MakePtrDerived2_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived3_ABase1().abase1', '9', binding, 'MakePtrDerived3_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived3_CBase1().cbase1y', '7', binding, 'MakePtrDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakePtrDerived3_CBase2().cbase2', '8', binding, 'MakePtrDerived3_CBase2 failed')
+
+# return references
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived1_CBase1().cbase1y', '3', binding, 'MakeRefDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived1_CBase2().cbase2', '4', binding, 'MakeRefDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived2_CBase1().cbase1y', '6', binding, 'MakeRefDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived2_ABase1().abase1', '5', binding, 'MakeRefDerived2_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived3_ABase1().abase1', '9', binding, 'MakeRefDerived3_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived3_CBase1().cbase1y', '7', binding, 'MakeRefDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeRefDerived3_CBase2().cbase2', '8', binding, 'MakeRefDerived3_CBase2 failed')
+
+# return by value (sliced objects)
+swig_assert_equal('Multiple_inheritance_abstract::MakeValDerived1_CBase1().cbase1y', '1', binding, 'MakeValDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeValDerived1_CBase2().cbase2', '2', binding, 'MakeValDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeValDerived2_CBase1().cbase1y', '1', binding, 'MakeValDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeValDerived3_CBase1().cbase1y', '1', binding, 'MakeValDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_abstract::MakeValDerived3_CBase2().cbase2', '2', binding, 'MakeValDerived3_CBase2 failed')
+
diff --git a/Examples/test-suite/ruby/multiple_inheritance_nspace_runme.rb b/Examples/test-suite/ruby/multiple_inheritance_nspace_runme.rb
new file mode 100644
index 000000000..fb28a0f83
--- /dev/null
+++ b/Examples/test-suite/ruby/multiple_inheritance_nspace_runme.rb
@@ -0,0 +1,243 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'multiple_inheritance_nspace'
+
+# Test base class as a parameter in Ruby
+
+def jcbase1b(cb1)
+ cb1.cbase1y
+end
+
+def jabase1(ab1)
+ ab1.abase1
+end
+
+def jcbase2(cb2)
+ cb2.cbase2
+end
+
+# test Derived1
+d1 = Multiple_inheritance_nspace::Derived1.new
+swig_assert_equal('d1.cbase1y', '3', binding, 'Derived1::cbase1y() failed')
+swig_assert_equal('d1.cbase2', '4', binding, 'Derived1::cbase2() failed')
+
+# test Derived2
+d2 = Multiple_inheritance_nspace::Derived2.new
+swig_assert_equal('d2.cbase1y', '6', binding, 'Derived2::cbase1y() failed')
+swig_assert_equal('d2.abase1', '5', binding, 'Derived2::cbase1y() failed')
+
+# test Derived3
+d3 = Multiple_inheritance_nspace::Derived3.new
+swig_assert_equal('d3.cbase1y', '7', binding, 'Derived3::cbase1y() failed')
+swig_assert_equal('d3.cbase2', '8', binding, 'Derived3::cbase2() failed')
+swig_assert_equal('d3.abase1', '9', binding, 'Derived3::abase1() failed')
+
+# test Bottom1
+b1 = Multiple_inheritance_nspace::Bottom1.new
+swig_assert_equal('b1.cbase1y', '103', binding, 'Bottom1::cbase1y() failed')
+swig_assert_equal('b1.cbase2', '104', binding, 'Bottom1::cbase2() failed')
+
+# test Bottom2
+b2 = Multiple_inheritance_nspace::Bottom2.new
+swig_assert_equal('b2.cbase1y', '206', binding, 'Bottom2::cbase1y() failed')
+swig_assert_equal('b2.abase1', '205', binding, 'Bottom2::abase1() failed')
+
+# test Bottom3
+b3 = Multiple_inheritance_nspace::Bottom3.new
+swig_assert_equal('b3.cbase1y', '307', binding, 'Bottom3::cbase1y() failed')
+swig_assert_equal('b3.cbase2', '308', binding, 'Bottom3::cbase2() failed')
+swig_assert_equal('b3.abase1', '309', binding, 'Bottom3::abase1() failed')
+
+# test interfaces from C++ classes
+cb1 = Multiple_inheritance_nspace::CBase1.new
+cb2 = Multiple_inheritance_nspace::CBase2.new
+swig_assert_equal('cb1.cbase1y', '1', binding, 'CBase1::cbase1y() failed')
+swig_assert_equal('cb2.cbase2', '2', binding, 'CBase2::cbase2() failed')
+
+# test nspace class as return value
+ab1 = d3.cloneit
+swig_assert_equal('ab1.abase1', '9', binding, 'Derived3::abase1() through ABase1 failed')
+
+# test concrete base class as return value
+cb6 = d2.cloneit
+cb7 = d1.cloneit
+swig_assert_equal('cb6.cbase1y', '6', binding, 'Derived2::cbase1y() through CBase1 failed')
+swig_assert_equal('cb7.cbase2', '4', binding, 'Derived1:cbase2() through ABase1 failed')
+
+# test multi inheritance
+cb3 = Multiple_inheritance_nspace::Derived1.new
+cb4 = Multiple_inheritance_nspace::Derived3.new
+cb5 = Multiple_inheritance_nspace::Derived3.new
+ab6 = Multiple_inheritance_nspace::Derived2.new
+swig_assert_equal('cb3.cbase1y', '3', binding, 'Derived1::cbase1y() through CBase1 failed')
+swig_assert_equal('cb4.cbase1y', '7', binding, 'Derived3::cbase1y() through CBase1 failed')
+swig_assert_equal('cb5.cbase2', '8', binding, 'Derived3::cbase2() through CBase2 failed')
+swig_assert_equal('ab6.abase1', '5', binding, 'Derived2::abase1() through ABase1 failed')
+
+# test base classes as parameter in Ruby
+swig_assert_equal('jcbase1b(d1)', '3', binding, 'jcbase1b() through Derived1 as parameter failed')
+swig_assert_equal('jcbase1b(d2)', '6', binding, 'jcbase1b() through Derived2 as parameter failed')
+swig_assert_equal('jcbase1b(d3)', '7', binding, 'jcbase1b() through Derived3 as parameter failed')
+swig_assert_equal('jcbase2(d1)', '4', binding, 'jcbase2() through Derived1 as parameter failed')
+swig_assert_equal('jcbase2(d3)', '8', binding, 'jcbase2() through Derived3 as parameter failed')
+swig_assert_equal('jabase1(d2)', '5', binding, 'jabase1() through Derived2 as parameter failed')
+swig_assert_equal('jabase1(d3)', '9', binding, 'jabase1() through Derived3 as parameter failed')
+
+# value parameters
+# test CBase1 CBase2 as parameters (note slicing for Derived and Bottom classes)
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(d1)', '1', binding, 'InputValCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(d2)', '1', binding, 'InputValCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(d3)', '1', binding, 'InputValCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase2(d3)', '2', binding, 'InputValCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase2(d1)', '2', binding, 'InputValCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(cb1)', '1', binding, 'InputValCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase2(cb2)', '2', binding, 'InputValCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(b1)', '1', binding, 'InputValCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(b2)', '1', binding, 'InputValCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase1(b3)', '1', binding, 'InputValCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase2(b3)', '2', binding, 'InputValCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValCBase2(b1)', '2', binding, 'InputValCBase2(), Bottom1 as a parameter failed')
+
+# pointer parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrABase1(d2)', '5', binding, 'InputPtrABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrABase1(d3)', '9', binding, 'InputPtrABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrABase1(b2)', '205', binding, 'InputPtrABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrABase1(b3)', '309', binding, 'InputPtrABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(d1)', '3', binding, 'InputPtrCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(d2)', '6', binding, 'InputPtrCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(d3)', '7', binding, 'InputPtrCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase2(d3)', '8', binding, 'InputPtrCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase2(d1)', '4', binding, 'InputPtrCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(cb1)', '1', binding, 'InputPtrCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase2(cb2)', '2', binding, 'InputPtrCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(b1)', '103', binding, 'InputPtrCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(b2)', '206', binding, 'InputPtrCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase1(b3)', '307', binding, 'InputPtrCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase2(b3)', '308', binding, 'InputPtrCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrCBase2(b1)', '104', binding, 'InputPtrCBase2(), Bottom1 as a parameter failed')
+
+# reference parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_nspace::InputRefABase1(d2)', '5', binding, 'InputRefABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefABase1(d3)', '9', binding, 'InputRefABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefABase1(b2)', '205', binding, 'InputRefABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefABase1(b3)', '309', binding, 'InputRefABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(d1)', '3', binding, 'InputRefCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(d2)', '6', binding, 'InputRefCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(d3)', '7', binding, 'InputRefCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase2(d3)', '8', binding, 'InputRefCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase2(d1)', '4', binding, 'InputRefCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(cb1)', '1', binding, 'InputRefCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase2(cb2)', '2', binding, 'InputRefCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(b1)', '103', binding, 'InputRefCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(b2)', '206', binding, 'InputRefCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase1(b3)', '307', binding, 'InputRefCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase2(b3)', '308', binding, 'InputRefCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefCBase2(b1)', '104', binding, 'InputRefCBase2(), Bottom1 as a parameter failed')
+
+# const reference pointer parameters
+# test ABase1 as a parameter
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefABase1(d2)', '5', binding, 'InputCPtrRefABase1() through Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefABase1(d3)', '9', binding, 'InputCPtrRefABase1() through Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefABase1(b2)', '205', binding, 'InputCPtrRefABase1() through Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefABase1(b3)', '309', binding, 'InputCPtrRefABase1() through Bottom3 as a parameter failed')
+
+# test CBase1 CBase2 as parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(d1)', '3', binding, 'InputCPtrRefCBase1(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(d2)', '6', binding, 'InputCPtrRefCBase1(), Derived2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(d3)', '7', binding, 'InputCPtrRefCBase1(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase2(d3)', '8', binding, 'InputCPtrRefCBase2(), Derived3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase2(d1)', '4', binding, 'InputCPtrRefCBase2(), Derived1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(cb1)', '1', binding, 'InputCPtrRefCBase1(), CBase1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase2(cb2)', '2', binding, 'InputCPtrRefCBase2(), CBase2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(b1)', '103', binding, 'InputCPtrRefCBase1(), Bottom1 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(b2)', '206', binding, 'InputCPtrRefCBase1(), Bottom2 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase1(b3)', '307', binding, 'InputCPtrRefCBase1(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase2(b3)', '308', binding, 'InputCPtrRefCBase2(), Bottom3 as a parameter failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefCBase2(b1)', '104', binding, 'InputCPtrRefCBase2(), Bottom1 as a parameter failed')
+
+# derived classes as parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived1(d1)', '3+4', binding, 'InputValDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived2(d2)', '6+5', binding, 'InputValDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived3(d3)', '7+8+9', binding, 'InputValDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived1(d1)', '3+4', binding, 'InputRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived2(d2)', '6+5', binding, 'InputRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived3(d3)', '7+8+9', binding, 'InputRefDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived1(d1)', '3+4', binding, 'InputPtrDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived2(d2)', '6+5', binding, 'InputPtrDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived3(d3)', '7+8+9', binding, 'InputPtrDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived1(d1)', '3+4', binding, 'InputCPtrRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived2(d2)', '6+5', binding, 'InputCPtrRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived3(d3)', '7+8+9', binding, 'InputCPtrRefDerived3() failed')
+
+# bottom classes as Derived parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived1(b1)', '3+4', binding, 'InputValDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived2(b2)', '6+5', binding, 'InputValDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValDerived3(b3)', '7+8+9', binding, 'InputValDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived1(b1)', '103+104', binding, 'InputRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived2(b2)', '206+205', binding, 'InputRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefDerived3(b3)', '307+308+309', binding, 'InputRefDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived1(b1)', '103+104', binding, 'InputPtrDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived2(b2)', '206+205', binding, 'InputPtrDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrDerived3(b3)', '307+308+309', binding, 'InputPtrDerived3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived1(b1)', '103+104', binding, 'InputCPtrRefDerived1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived2(b2)', '206+205', binding, 'InputCPtrRefDerived2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefDerived3(b3)', '307+308+309', binding, 'InputCPtrRefDerived3() failed')
+
+# bottom classes as Bottom parameters
+swig_assert_equal('Multiple_inheritance_nspace::InputValBottom1(b1)', '103+104', binding, 'InputValBottom1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValBottom2(b2)', '206+205', binding, 'InputValBottom2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputValBottom3(b3)', '307+308+309', binding, 'InputValBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputRefBottom1(b1)', '103+104', binding, 'InputRefBottom1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefBottom2(b2)', '206+205', binding, 'InputRefBottom2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputRefBottom3(b3)', '307+308+309', binding, 'InputRefBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrBottom1(b1)', '103+104', binding, 'InputPtrBottom1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrBottom2(b2)', '206+205', binding, 'InputPtrBottom2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputPtrBottom3(b3)', '307+308+309', binding, 'InputPtrBottom3() failed')
+
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefBottom1(b1)', '103+104', binding, 'InputCPtrRefBottom1() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefBottom2(b2)', '206+205', binding, 'InputCPtrRefBottom2() failed')
+swig_assert_equal('Multiple_inheritance_nspace::InputCPtrRefBottom3(b3)', '307+308+309', binding, 'InputCPtrRefBottom3() failed')
+
+# return pointers
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived1_CBase1().cbase1y', '3', binding, 'MakePtrDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived1_CBase2().cbase2', '4', binding, 'MakePtrDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived2_CBase1().cbase1y', '6', binding, 'MakePtrDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived2_ABase1().abase1', '5', binding, 'MakePtrDerived2_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived3_ABase1().abase1', '9', binding, 'MakePtrDerived3_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived3_CBase1().cbase1y', '7', binding, 'MakePtrDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakePtrDerived3_CBase2().cbase2', '8', binding, 'MakePtrDerived3_CBase2 failed')
+
+# return references
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived1_CBase1().cbase1y', '3', binding, 'MakeRefDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived1_CBase2().cbase2', '4', binding, 'MakeRefDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived2_CBase1().cbase1y', '6', binding, 'MakeRefDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived2_ABase1().abase1', '5', binding, 'MakeRefDerived2_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived3_ABase1().abase1', '9', binding, 'MakeRefDerived3_ABase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived3_CBase1().cbase1y', '7', binding, 'MakeRefDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeRefDerived3_CBase2().cbase2', '8', binding, 'MakeRefDerived3_CBase2 failed')
+
+# return by value (sliced objects)
+swig_assert_equal('Multiple_inheritance_nspace::MakeValDerived1_CBase1().cbase1y', '1', binding, 'MakeValDerived1_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeValDerived1_CBase2().cbase2', '2', binding, 'MakeValDerived1_CBase2 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeValDerived2_CBase1().cbase1y', '1', binding, 'MakeValDerived2_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeValDerived3_CBase1().cbase1y', '1', binding, 'MakeValDerived3_CBase1 failed')
+swig_assert_equal('Multiple_inheritance_nspace::MakeValDerived3_CBase2().cbase2', '2', binding, 'MakeValDerived3_CBase2 failed')
+
diff --git a/Examples/test-suite/ruby/namespace_chase_runme.rb b/Examples/test-suite/ruby/namespace_chase_runme.rb
new file mode 100644
index 000000000..c5f227dfd
--- /dev/null
+++ b/Examples/test-suite/ruby/namespace_chase_runme.rb
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'namespace_chase'
+
+s1a = Namespace_chase::Struct1A.new
+s1b = Namespace_chase::Struct1B.new
+s1c = Namespace_chase::Struct1C.new
+
+Namespace_chase.sss3a(s1a, s1b, s1c)
+Namespace_chase.sss3b(s1a, s1b, s1c)
diff --git a/Examples/test-suite/ruby/namespace_class_runme.rb b/Examples/test-suite/ruby/namespace_class_runme.rb
new file mode 100644
index 000000000..fd9345814
--- /dev/null
+++ b/Examples/test-suite/ruby/namespace_class_runme.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'namespace_class'
+
+begin
+ p = Namespace_class::Private1.new
+ raise SwigRubyError.new("Private1 is private")
+rescue NameError => e
+ # OK
+end
+
+begin
+ p = Namespace_class::Private2.new
+ raise SwigRubyError.new("Private2 is private")
+rescue NameError => e
+ # OK
+end
+
+Namespace_class::EulerT3D.toFrame(1, 1, 1)
+
+b = Namespace_class::BooT_i.new
+b = Namespace_class::BooT_H.new
+
+
+f = Namespace_class::FooT_i.new
+f.quack(1)
+
+f = Namespace_class::FooT_d.new
+f.moo(1)
+
+f = Namespace_class::FooT_H.new
+f.foo(Namespace_class::Hi)
+
+f_type = f.class.to_s
+swig_assert_equal('f_type', '"Namespace_class::FooT_H"', binding)
+
diff --git a/Examples/test-suite/ruby/namespace_forward_declaration_runme.rb b/Examples/test-suite/ruby/namespace_forward_declaration_runme.rb
new file mode 100644
index 000000000..0e6b50eb8
--- /dev/null
+++ b/Examples/test-suite/ruby/namespace_forward_declaration_runme.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'namespace_forward_declaration'
+
+xxx = Namespace_forward_declaration::XXX.new
+Namespace_forward_declaration.testXXX1(xxx)
+Namespace_forward_declaration.testXXX2(xxx)
+Namespace_forward_declaration.testXXX3(xxx)
+yyy = Namespace_forward_declaration::YYY.new
+Namespace_forward_declaration.testYYY1(yyy)
+Namespace_forward_declaration.testYYY2(yyy)
+Namespace_forward_declaration.testYYY3(yyy)
diff --git a/Examples/test-suite/ruby/namespace_virtual_method_runme.rb b/Examples/test-suite/ruby/namespace_virtual_method_runme.rb
new file mode 100644
index 000000000..54e4a7a21
--- /dev/null
+++ b/Examples/test-suite/ruby/namespace_virtual_method_runme.rb
@@ -0,0 +1,8 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'namespace_virtual_method'
+
+x = Namespace_virtual_method::Spam.new
diff --git a/Examples/test-suite/ruby/nested_class_runme.rb b/Examples/test-suite/ruby/nested_class_runme.rb
new file mode 100644
index 000000000..2cf3bf96a
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_class_runme.rb
@@ -0,0 +1,54 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'nested_class'
+
+outer = Nested_class::Outer.new
+is1 = outer.makeInnerStruct1
+ic1 = outer.makeInnerClass1
+iu1 = outer.makeInnerUnion1
+
+is2 = outer.makeInnerStruct2
+ic2 = outer.makeInnerClass2
+iu2 = outer.makeInnerUnion2
+
+ic4 = outer.makeInnerClass4Typedef
+is4 = outer.makeInnerStruct4Typedef
+iu4 = outer.makeInnerUnion4Typedef
+
+ic5 = outer.makeInnerClass5
+is5 = outer.makeInnerStruct5
+iu5 = outer.makeInnerUnion5
+
+ic5 = outer.makeInnerClass5Typedef
+is5 = outer.makeInnerStruct5Typedef
+iu5 = outer.makeInnerUnion5Typedef
+
+im1 = outer.MultipleInstance1
+im2 = outer.MultipleInstance2
+im3 = outer.MultipleInstance3
+im4 = outer.MultipleInstance4
+
+im1 = outer.MultipleDerivedInstance1
+im2 = outer.MultipleDerivedInstance2
+im3 = outer.MultipleDerivedInstance3
+im4 = outer.MultipleDerivedInstance4
+
+im1 = outer.MultipleDerivedInstance1
+im2 = outer.MultipleDerivedInstance2
+im3 = outer.MultipleDerivedInstance3
+im4 = outer.MultipleDerivedInstance4
+
+mat1 = outer.makeInnerMultipleAnonTypedef1
+mat2 = outer.makeInnerMultipleAnonTypedef2
+mat3 = outer.makeInnerMultipleAnonTypedef3
+
+mnt = outer.makeInnerMultipleNamedTypedef
+mnt1 = outer.makeInnerMultipleNamedTypedef1
+mnt2 = outer.makeInnerMultipleNamedTypedef2
+mnt3 = outer.makeInnerMultipleNamedTypedef3
+
+isn = outer.makeInnerSameName
diff --git a/Examples/test-suite/ruby/nested_directors_runme.rb b/Examples/test-suite/ruby/nested_directors_runme.rb
new file mode 100644
index 000000000..b2020b3d4
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_directors_runme.rb
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its C# counterpart.
+#
+
+require 'swig_assert'
+require 'nested_directors'
+
+# nested classes not yet supported
+#class CNested < Nested_directors::Base::Nest
+# def GetValue
+# true
+# end
+#end
+
+class CSub < Nested_directors::Sub
+ def GetValue
+ super
+ end
+ def Test
+ GetValue()
+ end
+end
+
+#n = CNested.new
+#swig_assert('n.GetValue()', binding)
+
+s = CSub.new
+swig_assert('s.Test()', binding)
diff --git a/Examples/test-suite/ruby/nested_in_template_runme.rb b/Examples/test-suite/ruby/nested_in_template_runme.rb
new file mode 100644
index 000000000..4d3b721a1
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_in_template_runme.rb
@@ -0,0 +1,11 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'nested_in_template'
+
+
+cd = Nested_in_template::ConcreteDerived.new(88)
+swig_assert_equal('cd.m_value', '88', binding, 'ConcreteDerived not created correctly')
diff --git a/Examples/test-suite/ruby/nested_scope_flat_runme.rb b/Examples/test-suite/ruby/nested_scope_flat_runme.rb
new file mode 100644
index 000000000..bd7ee7c91
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_scope_flat_runme.rb
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+#
+# Check the availability of expected classes and their member variables.
+#
+
+require 'swig_assert'
+require 'nested_scope_flat'
+
+Nested_scope_flat::Global_.new
+Nested_scope_flat::Outer1.new
+nested2 = Nested_scope_flat::Nested2.new
+nested2.data = 42
+swig_assert_equal("nested2.data", "42", binding)
+Nested_scope_flat::Klass.new
+
+Nested_scope_flat::Abstract_int
+cannot_instantiate = false
+begin
+ Nested_scope_flat::Abstract_int.new
+rescue TypeError
+ cannot_instantiate = true
+end
+swig_assert_simple(cannot_instantiate)
+
+Nested_scope_flat::Real.new.Method()
diff --git a/Examples/test-suite/ruby/nested_template_base_runme.rb b/Examples/test-suite/ruby/nested_template_base_runme.rb
new file mode 100644
index 000000000..a4f293365
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_template_base_runme.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+require 'nested_template_base'
+
+ois = Nested_template_base::InnerS.new(123)
+oic = Nested_template_base::InnerC.new
+
+# Check base method is available
+swig_assert_equal('oic.outer(ois).val', '123', binding, 'Wrong value calling outer')
+
+# Check non-derived class using base class
+swig_assert_equal('oic.innerc().outer(ois).val', '123', binding, 'Wrong value calling innerc')
diff --git a/Examples/test-suite/ruby/nested_workaround_runme.rb b/Examples/test-suite/ruby/nested_workaround_runme.rb
new file mode 100644
index 000000000..645bdd321
--- /dev/null
+++ b/Examples/test-suite/ruby/nested_workaround_runme.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'nested_workaround'
+
+begin
+ inner = Nested_workaround::Inner.new(5)
+ outer = Nested_workaround::Outer.new
+ newInner = outer.doubleInnerValue(inner)
+ swig_assert_equal("newInner.getValue", "10", binding)
+end
+
+begin
+ outer = Nested_workaround::Outer.new
+ inner = outer.createInner(3)
+ newInner = outer.doubleInnerValue(inner)
+ swig_assert_equal("outer.getInnerValue(newInner)", "6", binding)
+end
diff --git a/Examples/test-suite/ruby/newobject2_runme.rb b/Examples/test-suite/ruby/newobject2_runme.rb
index 04129f4aa..b7ebea097 100644
--- a/Examples/test-suite/ruby/newobject2_runme.rb
+++ b/Examples/test-suite/ruby/newobject2_runme.rb
@@ -18,10 +18,12 @@ require 'newobject2'
include Newobject2
GC.track_class = Foo
+GC.disable
GC.stats if $VERBOSE
100.times { foo1 = makeFoo }
GC.stats if $VERBOSE
swig_assert( 'fooCount == 100', nil, "but is #{fooCount}" )
+GC.enable
GC.start
swig_assert( 'fooCount <= 1', nil, "but is #{fooCount}" )
diff --git a/Examples/test-suite/ruby/numeric_bounds_checking_runme.rb b/Examples/test-suite/ruby/numeric_bounds_checking_runme.rb
new file mode 100644
index 000000000..1db51be38
--- /dev/null
+++ b/Examples/test-suite/ruby/numeric_bounds_checking_runme.rb
@@ -0,0 +1,42 @@
+#!/usr/bin/env ruby
+#
+# Tests the bounds checking for integral parameters passed to wrapped functions.
+#
+
+require 'swig_assert'
+require 'numeric_bounds_checking'
+
+limits = Numeric_bounds_checking::Limits.new
+checker = Numeric_bounds_checking::Checker.new
+
+all_ok = true
+
+types = %w(schar uchar
+ shrt ushrt
+ int uint
+ long ulong)
+types += %w(llong ullong) if limits.respond_to?(:llong_min)
+
+types.each do |t|
+ min = limits.send("#{t}_min")
+ max = limits.send("#{t}_max")
+
+ meth = "pass_#{t}"
+
+ # check within bounds
+ swig_assert_equal("checker.#{meth}(#{min})", "#{min}", binding)
+ swig_assert_equal("checker.#{meth}(#{max})", "#{max}", binding)
+
+ # check outside bounds
+ [ min - 1, max + 1 ].each do |val|
+ ok = false
+ begin
+ ret = checker.send("#{meth}", val)
+ rescue RangeError, TypeError
+ ok = true
+ end
+ $stderr.puts "\n#{meth}(#{val}): Expected exception but got #{ret} for #{val} (type '#{t}') " unless ok
+ all_ok = all_ok && ok
+ end
+ raise SwigRubyError.new("\nAt least one bounds check failed ") unless all_ok
+end
diff --git a/Examples/test-suite/ruby/overload_null_runme.rb b/Examples/test-suite/ruby/overload_null_runme.rb
index eabea5e40..e84851a88 100644
--- a/Examples/test-suite/ruby/overload_null_runme.rb
+++ b/Examples/test-suite/ruby/overload_null_runme.rb
@@ -40,13 +40,13 @@ swig_assert(14 == o.byval1cpr(nil))
swig_assert(15 == o.byval2cpr(nil))
swig_assert(16 == o.byval2cpr(x))
-# forward class declaration
-swig_assert(17 == o.byval1forwardptr(x))
-swig_assert(18 == o.byval1forwardptr(nil))
+# fwd class declaration
+swig_assert(17 == o.byval1fwdptr(x))
+swig_assert(18 == o.byval1fwdptr(nil))
-swig_assert(19 == o.byval2forwardptr(nil))
-swig_assert(20 == o.byval2forwardptr(x))
+swig_assert(19 == o.byval2fwdptr(nil))
+swig_assert(20 == o.byval2fwdptr(x))
-swig_assert(21 == o.byval1forwardref(x))
+swig_assert(21 == o.byval1fwdref(x))
-swig_assert(22 == o.byval2forwardref(x))
+swig_assert(22 == o.byval2fwdref(x))
diff --git a/Examples/test-suite/ruby/preproc_runme.rb b/Examples/test-suite/ruby/preproc_runme.rb
new file mode 100644
index 000000000..4b4a9157d
--- /dev/null
+++ b/Examples/test-suite/ruby/preproc_runme.rb
@@ -0,0 +1,40 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'swig_assert'
+
+# This extension to the Warning class is intended for suppressing expected
+# Ruby warning messages about invalid or redefined Ruby constants - basically
+# the equivalent of %warnfilter(SWIGWARN_RUBY_WRONG_NAME) but for the moment
+# the wrapper library is loaded by the Ruby interpreter.
+# Note: This only works for Ruby 2.4 and later
+if Object.const_defined?(:Warning) && Warning.respond_to?(:warn)
+ module CustomWarningFilter
+ def warn(*args)
+ msg = args[0]
+ if msg =~ /[Aa]lready initialized constant Preproc::A[56]/ ||
+ msg =~ /invalid name .?__GMP_HAVE_/
+ # ignore
+ else
+ super
+ end
+ end
+ end
+ Warning.extend CustomWarningFilter
+end
+
+require 'preproc'
+
+swig_assert_equal('Preproc::endif', '1', binding)
+swig_assert_equal('Preproc::define', '1', binding)
+swig_assert_equal('Preproc::ddefined', '1', binding)
+
+swig_assert_equal('2 * Preproc::One', 'Preproc::Two', binding)
+
+swig_assert_equal('Preproc::methodX(99)', '199', binding)
+
+t1 = Preproc::TcxMessageTest
+t2 = Preproc::TcxMessageBug
+
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
new file mode 100644
index 000000000..5523b59f4
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_cpp_runme.rb
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+#
+# C++ version of ruby_global_immutable_vars_runme.rb.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars_cpp'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
new file mode 100644
index 000000000..45a8506ba
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_global_immutable_vars_runme.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+#
+# This test program is similar to global_immutable_vars_runme.rb
+# with the difference that the global variables to check are also
+# Ruby global variables (SWIG Ruby option "-globalmodule").
+#
+# Immutable global variables shall throw a NameError exception.
+#
+
+require 'swig_assert'
+
+require 'ruby_global_immutable_vars'
+
+# first check if all variables can be read
+swig_assert_each_line( <<EOF )
+$default_mutable_var == 40
+$global_immutable_var == 41
+$specific_mutable_var == 42
+$global_mutable_var == 43
+$specific_immutable_var == 44
+EOF
+
+# check that all mutable variables can be modified
+swig_assert_each_line( <<EOF )
+$default_mutable_var = 80
+$default_mutable_var == 80
+$specific_mutable_var = 82
+$specific_mutable_var == 82
+$global_mutable_var = 83
+$global_mutable_var == 83
+EOF
+
+# now check that immutable variables cannot be modified
+had_exception = false
+begin
+ $global_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$global_immutable_var is writable (expected to be immutable)")
+
+had_exception = false
+begin
+ $specific_immutable_var = 81
+rescue NameError => e
+ had_exception = true
+end
+swig_assert(had_exception, nil,
+ "$specific_immutable_var is writable (expected to be immutable)")
+
+swig_assert(check_values(80, 41, 82, 83, 44) == 1, nil, "Check values failed")
diff --git a/Examples/test-suite/ruby/ruby_naming_bugs_runme.rb b/Examples/test-suite/ruby/ruby_naming_bugs_runme.rb
new file mode 100644
index 000000000..49311352d
--- /dev/null
+++ b/Examples/test-suite/ruby/ruby_naming_bugs_runme.rb
@@ -0,0 +1,16 @@
+#!/usr/bin/env ruby
+#
+# Regression tests for Ruby naming bugs
+#
+
+require 'swig_assert'
+
+require 'ruby_naming_bugs'
+
+# Prior to SWIG 4.1.0 the "Cool_" here was overzealously removed
+# while trying to remove a class name prefix, so this method would be
+# named "somethingFast" in Ruby instead.
+c = Ruby_naming_bugs::Cool.new()
+if c.somethingCool_Fast != 42
+ raise RuntimeError, "Incorrect value for somethingCool_Fast"
+end
diff --git a/Examples/test-suite/ruby/template_nested_flat_runme.rb b/Examples/test-suite/ruby/template_nested_flat_runme.rb
new file mode 100644
index 000000000..5d0907f80
--- /dev/null
+++ b/Examples/test-suite/ruby/template_nested_flat_runme.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Java counterpart.
+#
+
+require 'swig_assert'
+require 'template_nested_flat'
+
+Template_nested_flat::T_NormalTemplateNormalClass.new.tmethod(Template_nested_flat::NormalClass.new)
+Template_nested_flat::OuterClass.new.T_OuterTMethodNormalClass(Template_nested_flat::NormalClass.new)
+
+tf = Template_nested_flat::TemplateFuncs.new
+swig_assert_equal("tf.T_TemplateFuncs1Int(-10)", "-10", binding)
+swig_assert_equal("tf.T_TemplateFuncs2Double(-12.3)", "-12.3", binding)
+
+tn = Template_nested_flat::T_NestedOuterTemplateDouble.new
+swig_assert_equal("tn.hohum(-12.3)", "-12.3", binding)
+
+inner1 = Template_nested_flat::OuterClass.new.useInner1(Template_nested_flat::T_OuterClassInner1Int.new)
+inner2 = Template_nested_flat::T_OuterClassInner2NormalClass.new
+inner2.embeddedVar = 2
+inner22 = Template_nested_flat::OuterClass.new.useInner2Again(inner2)
+inner3 = Template_nested_flat::T_OuterClassInner1Double.new
diff --git a/Examples/test-suite/ruby/template_static_runme.rb b/Examples/test-suite/ruby/template_static_runme.rb
new file mode 100644
index 000000000..83c40e177
--- /dev/null
+++ b/Examples/test-suite/ruby/template_static_runme.rb
@@ -0,0 +1,12 @@
+#!/usr/bin/env ruby
+#
+# This test implementation is directly derived from its Python counterpart.
+#
+
+require 'template_static'
+
+Template_static::Foo_i.test
+Template_static::Foo_d.test
+Template_static::Foo::test
+Template_static::Foo::bar_double(1)
+
diff --git a/Examples/test-suite/ruby/typedef_inherit_runme.rb b/Examples/test-suite/ruby/typedef_inherit_runme.rb
index 029b80c70..10f155b3b 100644
--- a/Examples/test-suite/ruby/typedef_inherit_runme.rb
+++ b/Examples/test-suite/ruby/typedef_inherit_runme.rb
@@ -36,3 +36,9 @@ x = Typedef_inherit.do_blah2(d)
if x != "Grok::blah"
puts "Whoa! Bad return #{x}"
end
+
+x = d.far
+if x != "Spam::far"
+ puts "Whoa! Bad return #{x}"
+end
+