]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add invalid "foreach" tests to increase coverage cd7f8f8ec99e5b4539c91d349a5229f7728351f4
authorCorentin Noël <corentin@elementary.io>
Tue, 6 Feb 2018 23:45:27 +0000 (23:45 +0000)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Feb 2018 08:26:40 +0000 (09:26 +0100)
15 files changed:
tests/Makefile.am
tests/semantic/foreach-iterator-args.test [new file with mode: 0644]
tests/semantic/foreach-iterator-void.test [new file with mode: 0644]
tests/semantic/foreach-iterator-wrong-types.test [new file with mode: 0644]
tests/semantic/foreach-missing-generic-type.test [new file with mode: 0644]
tests/semantic/foreach-missing-iterator.test [new file with mode: 0644]
tests/semantic/foreach-missing-next-value.test [new file with mode: 0644]
tests/semantic/foreach-next-args.test [new file with mode: 0644]
tests/semantic/foreach-next-get-args.test [new file with mode: 0644]
tests/semantic/foreach-next-get-void.test [new file with mode: 0644]
tests/semantic/foreach-next-missing-get.test [new file with mode: 0644]
tests/semantic/foreach-next-value-args.test [new file with mode: 0644]
tests/semantic/foreach-next-value-void.test [new file with mode: 0644]
tests/semantic/foreach-next-void.test [new file with mode: 0644]
tests/semantic/foreach-wrong-types.test [new file with mode: 0644]

index c8f8416574a0936f1c3731a70679302061a35da4..37e8821080b6e3ef082909f43880889cfc180b62 100644 (file)
@@ -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 (file)
index 0000000..37fce34
--- /dev/null
@@ -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 (file)
index 0000000..1b147bd
--- /dev/null
@@ -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 (file)
index 0000000..eb43741
--- /dev/null
@@ -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 (file)
index 0000000..8b5640e
--- /dev/null
@@ -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 (file)
index 0000000..66e67a0
--- /dev/null
@@ -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 (file)
index 0000000..77533d3
--- /dev/null
@@ -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 (file)
index 0000000..0240d38
--- /dev/null
@@ -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 (file)
index 0000000..dc784db
--- /dev/null
@@ -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 (file)
index 0000000..8b32fda
--- /dev/null
@@ -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 (file)
index 0000000..3cb75d9
--- /dev/null
@@ -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 (file)
index 0000000..c0a3e57
--- /dev/null
@@ -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 (file)
index 0000000..68125b6
--- /dev/null
@@ -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 (file)
index 0000000..c6198b0
--- /dev/null
@@ -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 (file)
index 0000000..3229b4e
--- /dev/null
@@ -0,0 +1,7 @@
+Invalid Code
+
+void main () {
+       string[] test = { "foo", "bar" };
+       foreach (int t in test) {
+       }
+}