From: Corentin Noël Date: Tue, 6 Feb 2018 23:45:27 +0000 (+0000) Subject: tests: Add invalid "foreach" tests to increase coverage X-Git-Tag: 0.39.91~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd7f8f8ec99e5b4539c91d349a5229f7728351f4;p=thirdparty%2Fvala.git tests: Add invalid "foreach" tests to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index c8f841657..37e882108 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 000000000..37fce34a9 --- /dev/null +++ b/tests/semantic/foreach-iterator-args.test @@ -0,0 +1,16 @@ +Invalid Code + +public class Iterator { +} + +public class Test { + public Iterator iterator (int foo) { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..1b147bdd9 --- /dev/null +++ b/tests/semantic/foreach-iterator-void.test @@ -0,0 +1,13 @@ +Invalid Code + +public class Test { + public void iterator () { + return; + } +} + +void main () { + Test 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 000000000..eb4374172 --- /dev/null +++ b/tests/semantic/foreach-iterator-wrong-types.test @@ -0,0 +1,7 @@ +Invalid Code + +void main () { + var test = new GLib.List (); + 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 000000000..8b5640ec0 --- /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 000000000..66e67a045 --- /dev/null +++ b/tests/semantic/foreach-missing-iterator.test @@ -0,0 +1,10 @@ +Invalid Code + +public class Test { +} + +void main () { + Test 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 000000000..77533d3d8 --- /dev/null +++ b/tests/semantic/foreach-missing-next-value.test @@ -0,0 +1,16 @@ +Invalid Code + +public class Iterator { +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..0240d38c9 --- /dev/null +++ b/tests/semantic/foreach-next-args.test @@ -0,0 +1,19 @@ +Invalid Code + +public class Iterator { + public bool next (string test) { + return true; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..dc784db73 --- /dev/null +++ b/tests/semantic/foreach-next-get-args.test @@ -0,0 +1,23 @@ +Invalid Code + +public class Iterator { + public bool next () { + return true; + } + + public G get (int arg) { + return (G)null; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..8b32fda61 --- /dev/null +++ b/tests/semantic/foreach-next-get-void.test @@ -0,0 +1,23 @@ +Invalid Code + +public class Iterator { + public bool next () { + return true; + } + + public void get () { + return; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..3cb75d98c --- /dev/null +++ b/tests/semantic/foreach-next-missing-get.test @@ -0,0 +1,19 @@ +Invalid Code + +public class Iterator { + public bool next () { + return true; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..c0a3e575d --- /dev/null +++ b/tests/semantic/foreach-next-value-args.test @@ -0,0 +1,19 @@ +Invalid Code + +public class Iterator { + public G? next_value (string test) { + return null; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..68125b674 --- /dev/null +++ b/tests/semantic/foreach-next-value-void.test @@ -0,0 +1,19 @@ +Invalid Code + +public class Iterator { + public void next_value () { + return; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..c6198b0d4 --- /dev/null +++ b/tests/semantic/foreach-next-void.test @@ -0,0 +1,19 @@ +Invalid Code + +public class Iterator { + public void next () { + return; + } +} + +public class Test { + public Iterator iterator () { + return new Iterator (); + } +} + +void main () { + Test 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 000000000..3229b4eff --- /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) { + } +}