C# directors override/virtual - additional testing
Add runtime test for scenario described in #1323. Expand testing to cover a mix of override/virtual method overloading. Remove testSwigDerivedClassHasMethod() test - not fixed yet.
This commit is contained in:
parent
e4a251f321
commit
b90e3ae35d
2 changed files with 59 additions and 3 deletions
|
|
@ -49,7 +49,35 @@ public class runme
|
|||
throw new Exception("non-null pointer marshalling problem");
|
||||
myNewBar.x = 10;
|
||||
|
||||
my.testSwigDerivedClassHasMethod();
|
||||
// Low level implementation check
|
||||
// my.testSwigDerivedClassHasMethod();
|
||||
|
||||
// These should not call the C# implementations as they are not overridden
|
||||
int v;
|
||||
v = MyClass.call_nonVirtual(my);
|
||||
if (v != 100) throw new Exception("call_nonVirtual broken() " + v);
|
||||
|
||||
v = MyClass.call_nonOverride(my);
|
||||
if (v != 101) throw new Exception("call_nonOverride broken() " + v);
|
||||
|
||||
// A mix of overridden and non-overridden
|
||||
MyClassEnd myend = new MyClassEnd();
|
||||
MyClass mc = myend;
|
||||
|
||||
v = mc.nonVirtual();
|
||||
if (v != 202) throw new Exception("mc.nonVirtual() broken " + v);
|
||||
|
||||
v = MyClass.call_nonVirtual(mc);
|
||||
if (v != 202) throw new Exception("call_nonVirtual(mc) broken " + v);
|
||||
|
||||
v = MyClass.call_nonVirtual(myend);
|
||||
if (v != 202) throw new Exception("call_nonVirtual(myend) broken" + v);
|
||||
|
||||
v = MyClass.call_nonOverride(mc);
|
||||
if (v != 101) throw new Exception("call_nonOverride(mc) broken" + v);
|
||||
|
||||
v = MyClass.call_nonOverride(myend);
|
||||
if (v != 101) throw new Exception("call_nonOverride(myend) broken" + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,4 +109,20 @@ class MyOverriddenClass : MyClass {
|
|||
}
|
||||
}
|
||||
|
||||
class MyClassMiddle : MyClass {
|
||||
public override int nonVirtual() {
|
||||
return 202;
|
||||
}
|
||||
}
|
||||
|
||||
class MyClassEnd : MyClassMiddle {
|
||||
public new bool nonVirtual() {
|
||||
throw new Exception("non-virtual overrides virtual method");
|
||||
}
|
||||
|
||||
public new virtual bool nonOverride() {
|
||||
throw new Exception("non-override overrides virtual method");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue