Director smartptr testing
- Enhance Java and C# test - Add Ruby test
This commit is contained in:
parent
f266a588e0
commit
350eff3687
4 changed files with 107 additions and 25 deletions
|
|
@ -1,13 +1,13 @@
|
|||
using director_smartptrNamespace;
|
||||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
|
||||
private class director_smartptr_MyBarFoo : Foo
|
||||
{
|
||||
public override string ping()
|
||||
{
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
return "director_smartptr_MyBarFoo.ping()";
|
||||
}
|
||||
|
||||
public override string pong()
|
||||
|
|
@ -15,27 +15,39 @@ public class runme
|
|||
return "director_smartptr_MyBarFoo.pong();" + ping();
|
||||
}
|
||||
|
||||
public override string fooBar(FooBar fooBar)
|
||||
public override string upcall(FooBar fooBarPtr)
|
||||
{
|
||||
return fooBar.FooBarDo();
|
||||
return "override;" + fooBarPtr.FooBarDo();
|
||||
}
|
||||
|
||||
public override Foo makeFoo()
|
||||
{
|
||||
return new Foo();
|
||||
}
|
||||
}
|
||||
|
||||
public override FooBar makeFooBar()
|
||||
{
|
||||
return new FooBar();
|
||||
}
|
||||
private static void check(string got, string expected)
|
||||
{
|
||||
if (got != expected)
|
||||
throw new ApplicationException("Failed, got: " + got + " expected: " + expected);
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
director_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
FooBar fooBar = new FooBar();
|
||||
|
||||
myBarFoo.ping();
|
||||
Foo myBarFoo = new director_smartptr_MyBarFoo();
|
||||
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
|
||||
check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
|
||||
check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
|
||||
|
||||
Foo myFoo = myBarFoo.makeFoo();
|
||||
check(myFoo.pong(), "Foo::pong();Foo::ping()");
|
||||
check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
|
||||
check(myFoo.upcall(new FooBar()), "Bar::Foo2::Foo2Bar()");
|
||||
|
||||
Foo myFoo2 = new Foo().makeFoo();
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,12 @@ public:
|
|||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Foo::ping()"; }
|
||||
virtual std::string pong() { return "Foo::pong();" + ping(); }
|
||||
virtual std::string fooBar(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
|
||||
virtual std::string upcall(FooBar* fooBarPtr) { return fooBarPtr->FooBarDo(); }
|
||||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static std::string callPong(Foo &foo) { return foo.pong(); }
|
||||
static std::string callUpcall(Foo &foo, FooBar* fooBarPtr) { return foo.upcall(fooBarPtr); }
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
|
||||
|
|
@ -61,10 +63,12 @@ public:
|
|||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
virtual std::string fooBar(FooBar* fooBarPtr);
|
||||
virtual std::string upcall(FooBar* fooBarPtr);
|
||||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static std::string callPong(Foo &foo);
|
||||
static std::string callUpcall(Foo &foo, FooBar* fooBarPtr);
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,18 +12,35 @@ public class director_smartptr_runme {
|
|||
}
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
director_smartptr_MyBarFoo myBarFoo =
|
||||
new director_smartptr_MyBarFoo();
|
||||
private static void check(String got, String expected) {
|
||||
if (!got.equals(expected))
|
||||
throw new RuntimeException("Failed, got: " + got + " expected: " + expected);
|
||||
}
|
||||
|
||||
public static void main(String argv[]) {
|
||||
director_smartptr.FooBar fooBar = new director_smartptr.FooBar();
|
||||
|
||||
director_smartptr.Foo myBarFoo = new director_smartptr_MyBarFoo();
|
||||
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()");
|
||||
check(director_smartptr.Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()");
|
||||
check(director_smartptr.Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()");
|
||||
|
||||
director_smartptr.Foo myFoo = myBarFoo.makeFoo();
|
||||
check(myFoo.pong(), "Foo::pong();Foo::ping()");
|
||||
check(director_smartptr.Foo.callPong(myFoo), "Foo::pong();Foo::ping()");
|
||||
check(myFoo.upcall(fooBar), "Bar::Foo2::Foo2Bar()");
|
||||
|
||||
director_smartptr.Foo myFoo2 = new director_smartptr.Foo().makeFoo();
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()");
|
||||
check(director_smartptr.Foo.callPong(myFoo2), "Foo::pong();Foo::ping()");
|
||||
}
|
||||
}
|
||||
|
||||
class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
||||
|
||||
@Override
|
||||
public String ping() {
|
||||
return "director_smartptr_MyBarFoo.ping();";
|
||||
return "director_smartptr_MyBarFoo.ping()";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -32,17 +49,12 @@ class director_smartptr_MyBarFoo extends director_smartptr.Foo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_smartptr.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
public String upcall(director_smartptr.FooBar fooBarPtr) {
|
||||
return "override;" + fooBarPtr.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.Foo makeFoo() {
|
||||
return new director_smartptr.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_smartptr.FooBar makeFooBar() {
|
||||
return new director_smartptr.FooBar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
54
Examples/test-suite/ruby/director_smartptr_runme.rb
Normal file
54
Examples/test-suite/ruby/director_smartptr_runme.rb
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env ruby
|
||||
#
|
||||
# Put description here
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
require 'director_smartptr'
|
||||
|
||||
include Director_smartptr
|
||||
|
||||
class Director_smartptr_MyBarFoo < Foo
|
||||
|
||||
def ping()
|
||||
return "director_smartptr_MyBarFoo.ping()"
|
||||
end
|
||||
|
||||
def pong()
|
||||
return "director_smartptr_MyBarFoo.pong();" + ping()
|
||||
end
|
||||
|
||||
def upcall(fooBarPtr)
|
||||
return "override;" + fooBarPtr.FooBarDo()
|
||||
end
|
||||
|
||||
def makeFoo()
|
||||
return Foo.new()
|
||||
end
|
||||
end
|
||||
|
||||
def check(got, expected)
|
||||
if (got != expected)
|
||||
raise RuntimeError, "Failed, got: #{got} expected: #{expected}"
|
||||
end
|
||||
end
|
||||
|
||||
fooBar = Director_smartptr::FooBar.new()
|
||||
|
||||
myBarFoo = Director_smartptr_MyBarFoo.new()
|
||||
check(myBarFoo.ping(), "director_smartptr_MyBarFoo.ping()")
|
||||
check(Foo.callPong(myBarFoo), "director_smartptr_MyBarFoo.pong();director_smartptr_MyBarFoo.ping()")
|
||||
check(Foo.callUpcall(myBarFoo, fooBar), "override;Bar::Foo2::Foo2Bar()")
|
||||
|
||||
myFoo = myBarFoo.makeFoo()
|
||||
check(myFoo.pong(), "Foo::pong();Foo::ping()")
|
||||
check(Foo.callPong(myFoo), "Foo::pong();Foo::ping()")
|
||||
check(myFoo.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()")
|
||||
|
||||
myFoo2 = Foo.new().makeFoo()
|
||||
check(myFoo2.pong(), "Foo::pong();Foo::ping()")
|
||||
check(Foo.callPong(myFoo2), "Foo::pong();Foo::ping()")
|
||||
check(myFoo2.upcall(FooBar.new()), "Bar::Foo2::Foo2Bar()")
|
||||
Loading…
Add table
Add a link
Reference in a new issue