]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add and improve "foreach iterator" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 10:08:15 +0000 (11:08 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 10:12:16 +0000 (11:12 +0100)
tests/Makefile.am
tests/semantic/foreach-iterator-element-owned.test [new file with mode: 0644]
tests/semantic/foreach-iterator-wrong-types.test

index 3284569d74e1783dfe81d6640cbc3adcccd8934f..61ad4bbb8ac76e82e1972d388487e123a4703d2a 100644 (file)
@@ -559,6 +559,7 @@ TESTS = \
        semantic/field-void.test \
        semantic/floating-reference.vala \
        semantic/foreach-iterator-args.test \
+       semantic/foreach-iterator-element-owned.test \
        semantic/foreach-iterator-void.test \
        semantic/foreach-iterator-wrong-types.test \
        semantic/foreach-missing-generic-type.test \
diff --git a/tests/semantic/foreach-iterator-element-owned.test b/tests/semantic/foreach-iterator-element-owned.test
new file mode 100644 (file)
index 0000000..b647a9e
--- /dev/null
@@ -0,0 +1,23 @@
+Invalid Code
+
+public class Iterator<G> {
+       public bool next () {
+               return true;
+       }
+
+       public G get () {
+               return (G) null;
+       }
+}
+
+public class Test<G> {
+       public Iterator<G> iterator () {
+               return new Iterator<G> ();
+       }
+}
+
+void main () {
+       Test<string?> test = null;
+       foreach (unowned string? t in test) {
+       }
+}
index eb43741726a8231dd3b0ac8fce8320584f801ae0..e7824a81e84167a04e95a76bb5742aa2a9b3fe0b 100644 (file)
@@ -1,7 +1,23 @@
 Invalid Code
 
+public class Iterator<G> {
+       public bool next () {
+               return true;
+       }
+
+       public G get () {
+               return (G) null;
+       }
+}
+
+public class Test<G> {
+       public Iterator<G> iterator () {
+               return new Iterator<G> ();
+       }
+}
+
 void main () {
-       var test = new GLib.List<int> ();
-       foreach (string t in test) {
+       Test<string?> test = null;
+       foreach (int t in test) {
        }
 }