[vala/0.40] tests: Add and improve "foreach iterator" tests to increase coverage



commit 88c74ca514898f59e1782c0e025d30b63c54214d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Tue Nov 27 11:08:15 2018 +0100

    tests: Add and improve "foreach iterator" tests to increase coverage

 tests/Makefile.am                                  |  1 +
 tests/semantic/foreach-iterator-element-owned.test | 23 ++++++++++++++++++++++
 tests/semantic/foreach-iterator-wrong-types.test   | 20 +++++++++++++++++--
 3 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6c06fcbef..0a1713f4a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -535,6 +535,7 @@ TESTS = \
        semantic/field-owned-to-unowned.test \
        semantic/field-void.test \
        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
index 000000000..b647a9e2c
--- /dev/null
+++ b/tests/semantic/foreach-iterator-element-owned.test
@@ -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) {
+       }
+}
diff --git a/tests/semantic/foreach-iterator-wrong-types.test 
b/tests/semantic/foreach-iterator-wrong-types.test
index eb4374172..e7824a81e 100644
--- a/tests/semantic/foreach-iterator-wrong-types.test
+++ b/tests/semantic/foreach-iterator-wrong-types.test
@@ -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) {
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]