[vala/staging] tests: Add invalid "foreach" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add invalid "foreach" tests to increase coverage
- Date: Thu, 8 Feb 2018 08:29:53 +0000 (UTC)
commit cd7f8f8ec99e5b4539c91d349a5229f7728351f4
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 c8f8416..37e8821 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..37fce34
--- /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<string?> test = null;
+ 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..1b147bd
--- /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<string?> test = null;
+ 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..66e67a0
--- /dev/null
+++ b/tests/semantic/foreach-missing-iterator.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+public class Test<G> {
+}
+
+void main () {
+ Test<string?> test = null;
+ 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..77533d3
--- /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<string?> test = null;
+ 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..0240d38
--- /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<string?> test = null;
+ 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..dc784db
--- /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<string?> test = null;
+ 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..8b32fda
--- /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<string?> test = null;
+ 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..3cb75d9
--- /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<string?> test = null;
+ 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..c0a3e57
--- /dev/null
+++ b/tests/semantic/foreach-next-value-args.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+public class Iterator<G> {
+ public G? next_value (string test) {
+ return null;
+ }
+}
+
+public class Test<G> {
+ public Iterator<G> iterator () {
+ return new Iterator<G> ();
+ }
+}
+
+void main () {
+ Test<string?> test = null;
+ 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..68125b6
--- /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<string?> test = null;
+ 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..c6198b0
--- /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<string?> test = null;
+ 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]