[vala/0.40] tests: Add more "method" tests to increase coverage



commit ca57e4d4791b320d244c8f1fa823f06e2a7ad10a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Jul 31 17:00:10 2018 +0200

    tests: Add more "method" tests to increase coverage

 tests/Makefile.am                                  |  3 +++
 tests/methods/same-name.vala                       | 19 +++++++++++++++++++
 tests/semantic/method-interface-already-found.test | 16 ++++++++++++++++
 tests/semantic/method-interface-not-found.test     | 16 ++++++++++++++++
 4 files changed, 54 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7c046625d..f36214c7f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -78,6 +78,7 @@ TESTS = \
        methods/contains.vala \
        methods/iterator.vala \
        methods/prepostconditions.vala \
+       methods/same-name.vala \
        methods/symbolresolution.vala \
        methods/bug595538.vala \
        methods/bug596726.vala \
@@ -545,6 +546,8 @@ TESTS = \
        semantic/method-extern-abstract.test \
        semantic/method-extern-body.test \
        semantic/method-extern-virtual.test \
+       semantic/method-interface-already-found.test \
+       semantic/method-interface-not-found.test \
        semantic/method-main-async.test \
        semantic/method-main-inline.test \
        semantic/method-main-throws.test \
diff --git a/tests/methods/same-name.vala b/tests/methods/same-name.vala
new file mode 100644
index 000000000..a62a07dd7
--- /dev/null
+++ b/tests/methods/same-name.vala
@@ -0,0 +1,19 @@
+interface IFoo {
+       public abstract bool foo ();
+}
+
+class Foo : IFoo {
+       public bool IFoo.foo () {
+               return true;
+       }
+
+       public int foo () {
+               return 42;
+       }
+}
+
+void main () {
+       var foo = new Foo ();
+       assert (((IFoo) foo).foo ());
+       assert (foo.foo () == 42);
+}
diff --git a/tests/semantic/method-interface-already-found.test 
b/tests/semantic/method-interface-already-found.test
new file mode 100644
index 000000000..47ae22f75
--- /dev/null
+++ b/tests/semantic/method-interface-already-found.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+interface IFoo {
+       public abstract void foo ();
+}
+
+class Foo : IFoo {
+       public void IFoo.foo () {
+       }
+
+       public void IFoo.foo () {
+       }
+}
+
+void main () {
+}
diff --git a/tests/semantic/method-interface-not-found.test b/tests/semantic/method-interface-not-found.test
new file mode 100644
index 000000000..a22278feb
--- /dev/null
+++ b/tests/semantic/method-interface-not-found.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+interface IFoo {
+       public abstract void foo ();
+}
+
+class Foo : IFoo {
+       public void foo () {
+       }
+
+       public void IFoo.bar () {
+       }
+}
+
+void main () {
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]