]> git.eshelyaron.com Git - emacs.git/commitdiff
Tests for polymorphism
authorEric Ludlam <eric@siege-engine.com>
Sun, 18 Oct 2015 14:15:30 +0000 (10:15 -0400)
committerEdward John Steere <edward.steere@gmail.com>
Wed, 25 Jan 2017 15:59:25 +0000 (17:59 +0200)
* test/manual/cedet/cedet/semantic/tests/testpoly.cpp
 Tests for polymorphism with a couple examples where we could try to
 disambiguate.

test/manual/cedet/cedet/semantic/tests/testpoly.cpp [new file with mode: 0644]

diff --git a/test/manual/cedet/cedet/semantic/tests/testpoly.cpp b/test/manual/cedet/cedet/semantic/tests/testpoly.cpp
new file mode 100644 (file)
index 0000000..769a5be
--- /dev/null
@@ -0,0 +1,59 @@
+// Test disambiguation of polymorphic methods.
+
+class xx {
+public:
+  int int_field;
+  int char_field;
+  char foo(char x);
+  int foo (int x);
+};
+
+int whatever() {
+  xx x;
+
+  char same_char;
+  int same_int;
+  int i;
+  char c;
+
+  i = x.foo(same // -1-
+           // #1# ( "same_int" )
+           );
+
+  c = x.foo(same // -2-
+           // #2# ( "same_char" )
+           );
+
+}
+
+// Example from Dmitry
+struct foo {
+  int a;
+  int b;
+};
+
+struct bar {
+  int c;
+  int d;
+};
+
+foo tee(int i) {
+  foo f;
+  return f;
+}
+
+bar tee(long i) {
+  bar b;
+  return b;
+}
+
+int main() {
+  int i = 1;
+  long l = 2;
+
+  tee(i).//-3-
+    ; // #3# ( "a" "b" )
+
+  tee(l).//-4-
+    ; // #4# ( "c" "d" )
+}