summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Jezabek <jezabek@poczta.onet.pl>2008-08-07 19:23:14 +0000
committerJan Jezabek <jezabek@poczta.onet.pl>2008-08-07 19:23:14 +0000
commitdba08849265744b9391ab38836ba0afa2dc9fcd4 (patch)
treef4d3a3ad126dcb425ac43ccb820e44f44de75706
parentf254d97bf8d94fe30fea2befd9b2a0e7f6301d29 (diff)
downloadswig-dba08849265744b9391ab38836ba0afa2dc9fcd4.tar.gz
Added 2 tricky test cases along with run tests for C#.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-jezabek@10740 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Examples/test-suite/common.mk2
-rw-r--r--Examples/test-suite/csharp/inherit_same_name2_runme.cs26
-rw-r--r--Examples/test-suite/csharp/inherit_same_name3_runme.cs33
-rw-r--r--Examples/test-suite/inherit_same_name2.i51
-rw-r--r--Examples/test-suite/inherit_same_name3.i55
5 files changed, 167 insertions, 0 deletions
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 0a3a0858a..bcb5e9773 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -199,6 +199,8 @@ CPP_TEST_CASES += \
inherit \
inherit_missing \
inherit_same_name \
+ inherit_same_name2 \
+ inherit_same_name3 \
inherit_target_language \
inherit_void_arg \
inline_initializer \
diff --git a/Examples/test-suite/csharp/inherit_same_name2_runme.cs b/Examples/test-suite/csharp/inherit_same_name2_runme.cs
new file mode 100644
index 000000000..d87ef0fbc
--- /dev/null
+++ b/Examples/test-suite/csharp/inherit_same_name2_runme.cs
@@ -0,0 +1,26 @@
+
+using inherit_same_name2Namespace;
+using System;
+
+public class inherit_same_name2_runme {
+ public static void Main() {
+ D e = (D) new E();
+
+ /* Function aaa is virtual in C (a superclass of D), therefore it should be virtual in D and E */
+ Assert(e.aaa() == 2);
+
+ G g = new G();
+ F g_as_f = (F) g;
+
+ /* Virtual function G::aaa is renamed to aaa2, but should still be accessible */
+ Assert(g.aaa2() == 2);
+ Assert(g.aaa() == 2);
+ Assert(g_as_f.aaa() == 2);
+ }
+
+ private static void Assert(bool val) {
+ if (!val)
+ throw new Exception("assertion failure in test inherit_same_name2");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/inherit_same_name3_runme.cs b/Examples/test-suite/csharp/inherit_same_name3_runme.cs
new file mode 100644
index 000000000..c3ec77fc3
--- /dev/null
+++ b/Examples/test-suite/csharp/inherit_same_name3_runme.cs
@@ -0,0 +1,33 @@
+
+using inherit_same_name3Namespace;
+using System;
+
+public class inherit_same_name3_runme {
+ public static void Main() {
+ A c_as_A = (A) new C();
+
+ /* C::xyz is a static function and should not override A::xyz */
+ Assert(c_as_A.xyz(0) == 1);
+
+ /* Now the static function is called directly */
+ Assert(C.xyz(0) == 2);
+
+ E f = (E) new F();
+
+ /* E::xyz and F::xyz should be virtual */
+ Assert(f.xyz(0) == 3);
+
+ H h = new H();
+ G h_as_G = (G) h;
+
+ /* H::xyz should not override G::xyz because it has been renamed from H::xyz2 */
+ Assert(h_as_G.xyz(0) == 1);
+ Assert(h.xyz(0) == 2);
+ }
+
+ private static void Assert(bool val) {
+ if (!val)
+ throw new Exception("assertion failure in test inherit_same_name3");
+ }
+}
+
diff --git a/Examples/test-suite/inherit_same_name2.i b/Examples/test-suite/inherit_same_name2.i
new file mode 100644
index 000000000..2f3dc2aa2
--- /dev/null
+++ b/Examples/test-suite/inherit_same_name2.i
@@ -0,0 +1,51 @@
+%module inherit_same_name2
+
+%rename (aaa2) B::aaa();
+%rename (bbb) B::bbb2();
+
+%ignore C;
+
+%rename (aaa2) G::aaa();
+
+%inline %{
+
+class A {
+ public:
+ int aaa() { return 0; }
+ int bbb() { return 0; }
+ int ccc;
+};
+
+class B : public A {
+ public:
+ int aaa() { return 1; }
+ int bbb2() { return 1; }
+ void ccc(int) {}
+};
+
+class C {
+ public:
+ virtual int aaa() { return 0; }
+};
+
+class D : public C {
+ public:
+ int aaa() { return 1; }
+};
+
+class E : public D {
+ public:
+ int aaa() { return 2; }
+};
+
+class F {
+ public:
+ virtual int aaa() { return 1; }
+};
+
+class G : public F {
+ public:
+ virtual int aaa() { return 2; }
+};
+
+%}
diff --git a/Examples/test-suite/inherit_same_name3.i b/Examples/test-suite/inherit_same_name3.i
new file mode 100644
index 000000000..3f32313d0
--- /dev/null
+++ b/Examples/test-suite/inherit_same_name3.i
@@ -0,0 +1,55 @@
+%module inherit_same_name3
+
+%rename (xyz) C::xyz2;
+%rename (xyz) H::xyz2;
+%ignore I::xyz(int);
+
+%inline %{
+class A {
+ public:
+ virtual int xyz(int) { return 1; }
+};
+
+class C : public A {
+ public:
+ static int xyz2(int) { return 2; }
+};
+
+class D {
+ protected:
+ virtual int xyz(int) { return 1; }
+};
+
+class E : public D {
+ public:
+ int xyz(int) { return 2; }
+};
+
+class F : public E {
+ public:
+ int xyz(int) { return 3; }
+};
+
+class G {
+ public:
+ virtual int xyz(int) { return 1; }
+};
+
+class H : public G {
+ public:
+ virtual int xyz2(int) { return 2; }
+};
+
+/* This is a compile test -J::xyz (renamed from J::xyz2) should have no override modifier */
+
+class I {
+ public:
+ virtual int xyz(int) { return 1; }
+};
+
+class J : public I {
+ public:
+ virtual int xyz2(int) { return 2; }
+};
+
+%}