Added test case for Ruby using track objects and directors at the same time.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7524 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Charlie Savage 2005-09-24 22:30:30 +00:00
commit c8a76f8587
2 changed files with 73 additions and 0 deletions

View file

@ -0,0 +1,29 @@
require 'test/unit'
require 'track_objects_directors'
class MyFoo < Track_objects_directors::Foo
def ping
"MyFoo::ping()"
end
end
a = MyFoo.new
raise RuntimeError if a.ping != "MyFoo::ping()"
raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()"
b = Track_objects_directors::Foo.new
raise RuntimeError if b.ping != "Foo::ping()"
raise RuntimeError if b.pong != "Foo::pong();Foo::ping()"
container = Track_objects_directors::Container.new
foo = MyFoo.new
container.set_foo(foo)
myFoo1 = container.get_foo
myFoo2 = container.get_foo
if not myFoo1.equal?(myFoo2)
raise RuntimeError, "MyFoo's should be the same"
end

View file

@ -0,0 +1,44 @@
%module(directors="1") track_objects_directors
%{
#include <string>
%}
%include "std_string.i";
%feature("director") Foo;
%trackobjects;
%inline %{
class Foo {
public:
Foo() {}
virtual ~Foo() {}
virtual std::string ping()
{
return "Foo::ping()";
}
virtual std::string pong()
{
return "Foo::pong();" + ping();
}
};
class Container {
Foo* foo_;
public:
Foo* get_foo()
{
return foo_;
}
void set_foo(Foo *foo)
{
foo_ = foo;
}
};
%}