]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add more "method" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 31 Jul 2018 15:00:10 +0000 (17:00 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 1 Aug 2018 06:02:53 +0000 (08:02 +0200)
tests/Makefile.am
tests/methods/same-name.vala [new file with mode: 0644]
tests/semantic/method-interface-already-found.test [new file with mode: 0644]
tests/semantic/method-interface-not-found.test [new file with mode: 0644]

index e9574e09b9f8eaa0fd4be7617e3ae2ddadeab5bd..830a904729e0ef4942c7ce77f7d23a29402b18c9 100644 (file)
@@ -75,6 +75,7 @@ TESTS = \
        methods/contains.vala \
        methods/iterator.vala \
        methods/prepostconditions.vala \
+       methods/same-name.vala \
        methods/symbolresolution.vala \
        methods/bug595538.vala \
        methods/bug596726.vala \
@@ -532,6 +533,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 (file)
index 0000000..a62a07d
--- /dev/null
@@ -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 (file)
index 0000000..47ae22f
--- /dev/null
@@ -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 (file)
index 0000000..a22278f
--- /dev/null
@@ -0,0 +1,16 @@
+Invalid Code
+
+interface IFoo {
+       public abstract void foo ();
+}
+
+class Foo : IFoo {
+       public void foo () {
+       }
+
+       public void IFoo.bar () {
+       }
+}
+
+void main () {
+}