[vala/wip/tests] tests: Add invalid "foreach" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/tests] tests: Add invalid "foreach" tests to increase coverage
- Date: Wed, 7 Feb 2018 08:49:01 +0000 (UTC)
commit ea0941c3e97ac62bbce83816cb879cc219d0e658
Author: Corentin Noël <corentin elementary io>
Date: Tue Feb 6 23:45:27 2018 +0000
tests: Add invalid "foreach" tests to increase coverage
tests/Makefile.am | 14 +++++++++++++
tests/semantic/foreach-iterator-args.test | 16 +++++++++++++++
tests/semantic/foreach-iterator-void.test | 13 ++++++++++++
tests/semantic/foreach-iterator-wrong-types.test | 7 ++++++
tests/semantic/foreach-missing-generic-type.test | 7 ++++++
tests/semantic/foreach-missing-iterator.test | 10 +++++++++
tests/semantic/foreach-missing-next-value.test | 16 +++++++++++++++
tests/semantic/foreach-next-args.test | 19 ++++++++++++++++++
tests/semantic/foreach-next-get-args.test | 23 ++++++++++++++++++++++
tests/semantic/foreach-next-get-void.test | 23 ++++++++++++++++++++++
tests/semantic/foreach-next-missing-get.test | 19 ++++++++++++++++++
tests/semantic/foreach-next-value-args.test | 19 ++++++++++++++++++
tests/semantic/foreach-next-value-void.test | 19 ++++++++++++++++++
tests/semantic/foreach-next-void.test | 19 ++++++++++++++++++
tests/semantic/foreach-wrong-types.test | 7 ++++++
15 files changed, 231 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 063c7e8..70d861e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -445,6 +445,20 @@ TESTS = \
semantic/field-namespace-owned.test \
semantic/field-non-constant.test \
semantic/field-void.test \
+ semantic/foreach-iterator-args.test \
+ semantic/foreach-iterator-void.test \
+ semantic/foreach-iterator-wrong-types.test \
+ semantic/foreach-missing-generic-type.test \
+ semantic/foreach-missing-iterator.test \
+ semantic/foreach-missing-next-value.test \
+ semantic/foreach-next-args.test \
+ semantic/foreach-next-get-args.test \
+ semantic/foreach-next-get-void.test \
+ semantic/foreach-next-missing-get.test \
+ semantic/foreach-next-value-args.test \
+ semantic/foreach-next-value-void.test \
+ semantic/foreach-next-void.test \
+ semantic/foreach-wrong-types.test \
semantic/method-abstract.test \
semantic/method-abstract-body.test \
semantic/method-async-ref-parameter.test \
diff --git a/tests/semantic/foreach-iterator-args.test b/tests/semantic/foreach-iterator-args.test
new file mode 100644
index 0000000..3638b55
--- /dev/null
+++ b/tests/semantic/foreach-iterator-args.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+public class Iterator<G> {
+}
+
+public class Test<G> {
+ public Iterator<G> iterator (int foo) {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-iterator-void.test b/tests/semantic/foreach-iterator-void.test
new file mode 100644
index 0000000..b2f6e64
--- /dev/null
+++ b/tests/semantic/foreach-iterator-void.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+public class Test<G> {
+ public void iterator () {
+ return;
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-iterator-wrong-types.test
b/tests/semantic/foreach-iterator-wrong-types.test
new file mode 100644
index 0000000..eb43741
--- /dev/null
+++ b/tests/semantic/foreach-iterator-wrong-types.test
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+ var test = new GLib.List<int> ();
+ foreach (string t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-missing-generic-type.test
b/tests/semantic/foreach-missing-generic-type.test
new file mode 100644
index 0000000..8b5640e
--- /dev/null
+++ b/tests/semantic/foreach-missing-generic-type.test
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+ GLib.List test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-missing-iterator.test b/tests/semantic/foreach-missing-iterator.test
new file mode 100644
index 0000000..a224d77
--- /dev/null
+++ b/tests/semantic/foreach-missing-iterator.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+public class Test<G> {
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-missing-next-value.test b/tests/semantic/foreach-missing-next-value.test
new file mode 100644
index 0000000..a88d37a
--- /dev/null
+++ b/tests/semantic/foreach-missing-next-value.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+public class Iterator<G> {
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-args.test b/tests/semantic/foreach-next-args.test
new file mode 100644
index 0000000..069353b
--- /dev/null
+++ b/tests/semantic/foreach-next-args.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public bool next (string test) {
+ return true;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-get-args.test b/tests/semantic/foreach-next-get-args.test
new file mode 100644
index 0000000..368269f
--- /dev/null
+++ b/tests/semantic/foreach-next-get-args.test
@@ -0,0 +1,23 @@
+Invalid Code
+
+public class Iterator<G> {
+ public bool next () {
+ return true;
+ }
+
+ public G get (int arg) {
+ return (G)null;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-get-void.test b/tests/semantic/foreach-next-get-void.test
new file mode 100644
index 0000000..92c0dea
--- /dev/null
+++ b/tests/semantic/foreach-next-get-void.test
@@ -0,0 +1,23 @@
+Invalid Code
+
+public class Iterator<G> {
+ public bool next () {
+ return true;
+ }
+
+ public void get () {
+ return;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-missing-get.test b/tests/semantic/foreach-next-missing-get.test
new file mode 100644
index 0000000..10e7b04
--- /dev/null
+++ b/tests/semantic/foreach-next-missing-get.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public bool next () {
+ return true;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-value-args.test b/tests/semantic/foreach-next-value-args.test
new file mode 100644
index 0000000..ff422f8
--- /dev/null
+++ b/tests/semantic/foreach-next-value-args.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public bool next_value (string test) {
+ return true;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-value-void.test b/tests/semantic/foreach-next-value-void.test
new file mode 100644
index 0000000..4a082af
--- /dev/null
+++ b/tests/semantic/foreach-next-value-void.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public void next_value () {
+ return;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-next-void.test b/tests/semantic/foreach-next-void.test
new file mode 100644
index 0000000..a5152f6
--- /dev/null
+++ b/tests/semantic/foreach-next-void.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public void next () {
+ return;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test test;
+ foreach (var t in test) {
+ }
+}
diff --git a/tests/semantic/foreach-wrong-types.test b/tests/semantic/foreach-wrong-types.test
new file mode 100644
index 0000000..3229b4e
--- /dev/null
+++ b/tests/semantic/foreach-wrong-types.test
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+ string[] test = { "foo", "bar" };
+ foreach (int t in test) {
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]