From eef4efb2eb44d40598866b0e5e29a2b85dbdf580 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sun, 12 Dec 2004 21:40:18 +0000 Subject: [PATCH] add test case using 'super' git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6864 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Examples/test-suite/common.mk | 1 + .../test-suite/director_constructor.i | 37 +++++++++++++++++++ .../ruby/director_constructor_runme.rb | 26 +++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 SWIG/Examples/test-suite/director_constructor.i create mode 100644 SWIG/Examples/test-suite/ruby/director_constructor_runme.rb diff --git a/SWIG/Examples/test-suite/common.mk b/SWIG/Examples/test-suite/common.mk index 7c7495191..2e5a969a1 100644 --- a/SWIG/Examples/test-suite/common.mk +++ b/SWIG/Examples/test-suite/common.mk @@ -109,6 +109,7 @@ CPP_TEST_CASES += \ destructor_reprotected \ director_abstract \ director_basic \ + director_constructor \ director_detect \ director_default \ director_enum \ diff --git a/SWIG/Examples/test-suite/director_constructor.i b/SWIG/Examples/test-suite/director_constructor.i new file mode 100644 index 000000000..b3505f9f5 --- /dev/null +++ b/SWIG/Examples/test-suite/director_constructor.i @@ -0,0 +1,37 @@ +%module(directors="1") director_constructor + +%feature("director") Foo; + +%inline %{ +class Foo +{ +public: + int a; + + Foo(int i) + { + a=i; + } + + virtual ~Foo() { } + + int do_test() { + return test(); + } + + virtual int getit() + { + return a; + } + + virtual void doubleit() + { + a = a * 2; + } + + virtual int test() = 0; +}; +%} + + + diff --git a/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb b/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb new file mode 100644 index 000000000..3100cf9b9 --- /dev/null +++ b/SWIG/Examples/test-suite/ruby/director_constructor_runme.rb @@ -0,0 +1,26 @@ +require 'director_constructor' + +include Director_constructor + +class Test < Foo + def initialize(i) + super(i) + end + + def doubleit() + self.a = (self.a * 2) + end + + def test + 3 + end +end + +a = Test.new(5) #dies here + +raise RuntimeError if a.getit != 5 +raise RuntimeError if a.do_test != 3 + +a.doubleit +raise RuntimeError if a.getit != 10 +