summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2018-07-31 17:00:10 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2018-08-01 08:02:53 +0200
commited1ba8c6cdf8cd0d796b258d22f6977ce2502702 (patch)
tree02726b116608af765cbc18ed564271941c3e87cf
parent93cfba91bd50849a74e372cf66975fcaf31dfcba (diff)
downloadvala-ed1ba8c6cdf8cd0d796b258d22f6977ce2502702.tar.gz
tests: Add more "method" tests to increase coverage
-rw-r--r--tests/Makefile.am3
-rw-r--r--tests/methods/same-name.vala19
-rw-r--r--tests/semantic/method-interface-already-found.test16
-rw-r--r--tests/semantic/method-interface-not-found.test16
4 files changed, 54 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e9574e09b..830a90472 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
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 () {
+}