[vala/staging] tests: Add and improve "foreach iterator" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add and improve "foreach iterator" tests to increase coverage
- Date: Tue, 27 Nov 2018 10:28:46 +0000 (UTC)
commit 0615a4d7e74de4c9db9ab8f8ef26c5896b609846
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 3284569d7..61ad4bbb8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
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]