Skip to content

Commit ea3140a

Browse files
rokupswsfulton
authored andcommitted
Improve correctness of SwigDerivedClassHasMethod() tests
Tests first added in issue swig#1323
1 parent 7eba1cf commit ea3140a

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

Examples/test-suite/csharp/director_basic_runme.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ void run()
4848
if (myNewBar == null)
4949
throw new Exception("non-null pointer marshalling problem");
5050
myNewBar.x = 10;
51+
52+
my.testSwigDerivedClassHasMethod();
5153
}
5254
}
5355
}
@@ -69,6 +71,14 @@ public override Bar pmethod(Bar b) {
6971
throw new Exception("null not received as expected");
7072
return b;
7173
}
74+
75+
public bool nonVirtual() {
76+
throw new Exception("non-virtual overrides virtual method");
77+
}
78+
79+
public virtual bool nonOverride() {
80+
throw new Exception("non-override overrides virtual method");
81+
}
7282
}
7383

7484
}

Examples/test-suite/director_basic.i

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@
6565

6666
%}
6767

68+
%typemap(cscode) MyClass %{
69+
public void testSwigDerivedClassHasMethod() {
70+
if (SwigDerivedClassHasMethod("nonVirtual", swigMethodTypes3))
71+
throw new global::System.Exception("non-overriding non-virtual method would be when connecting director");
72+
if (SwigDerivedClassHasMethod("nonOverride", swigMethodTypes4))
73+
throw new global::System.Exception("non-overriding virtual method would be when connecting director");
74+
}
75+
%}
6876

6977
%feature("director") MyClass;
7078

@@ -122,8 +130,16 @@ public:
122130
return myclass->pmethod(b);
123131
}
124132

125-
// Collisions with generated method names
126-
virtual void Connect() { }
133+
virtual void nonVirtual()
134+
{
135+
}
136+
137+
virtual void nonOverride()
138+
{
139+
}
140+
141+
// Collisions with generated method names
142+
virtual void Connect() { }
127143
};
128144

129145
template<class T>

0 commit comments

Comments
 (0)