C# runtime test, based on Java one.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5593 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9129f61a39
commit
a272be6e65
1 changed files with 29 additions and 0 deletions
29
SWIG/Examples/test-suite/csharp/virtual_poly_runme.cs
Normal file
29
SWIG/Examples/test-suite/csharp/virtual_poly_runme.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public class runme {
|
||||||
|
static void Main() {
|
||||||
|
|
||||||
|
NDouble d = new NDouble(3.5);
|
||||||
|
NInt i = new NInt(2);
|
||||||
|
|
||||||
|
//
|
||||||
|
// These two natural 'copy' forms fail because no covariant (polymorphic) return types
|
||||||
|
// are supported in C#.
|
||||||
|
//
|
||||||
|
// NDouble dc = d.copy();
|
||||||
|
// NInt ic = i.copy();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Unlike C++, we have to downcast instead.
|
||||||
|
//
|
||||||
|
NDouble dc = (NDouble)d.copy();
|
||||||
|
NInt ic = (NInt)i.copy();
|
||||||
|
|
||||||
|
NDouble ddc = (NDouble)NDouble.narrow(dc);
|
||||||
|
NInt dic = (NInt)NInt.narrow(ic);
|
||||||
|
|
||||||
|
virtual_poly.incr(ic);
|
||||||
|
if ( (i.get() + 1) != ic.get() )
|
||||||
|
throw new Exception("incr test failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue