[vala/wip/issue/658: 24/30] Added more tests for anonymous delegates




commit 0fbc8758aba7354c126c418ec0aa01d0c714b55b
Author: Nick Schrader <nick schrader mailbox org>
Date:   Tue Oct 20 16:23:54 2020 -0300

    Added more tests for anonymous delegates

 tests/Makefile.am                                     |  6 ++++--
 tests/delegates/anonymous-generics.test               | 19 +++++++++++++++++++
 ...initializer.test => anonymous-optional-param.test} |  4 ++--
 tests/delegates/anonymous-params.test                 | 19 +++++++++++++++++++
 4 files changed, 44 insertions(+), 4 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6a8158b06..ca795818a 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -336,10 +336,12 @@ TESTS = \
        structs/bug777194-2.vala \
        delegates/anonymous.vala \
        delegates/anonymous-array.vala \
-       delegates/anonymous-type-param.vala \
+       delegates/anonymous-generics.test \
+       delegates/anonymous-optional-param.test \
+       delegates/anonymous-params.test \
        delegates/anonymous-throws.test \
+       delegates/anonymous-type-param.vala \
        delegates/anonymous-variadic.test \
-       delegates/anonymous-initializer.test \
        delegates/casting.vala \
        delegates/compatible.vala \
        delegates/delegate_only.vala \
diff --git a/tests/delegates/anonymous-generics.test b/tests/delegates/anonymous-generics.test
new file mode 100644
index 000000000..de46d6d56
--- /dev/null
+++ b/tests/delegates/anonymous-generics.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+/*
+ * 13.17-13.17: error: syntax error, expected `('
+ * void f (delegate<T>(int) => void y) {
+ *                 ^
+ */
+
+void main() {
+    f (t);
+}
+
+void f (delegate<T>(int) => void y) {
+    y(1);
+}
+
+void t(int a) {
+    assert (a == 1);
+}
diff --git a/tests/delegates/anonymous-initializer.test b/tests/delegates/anonymous-optional-param.test
similarity index 60%
rename from tests/delegates/anonymous-initializer.test
rename to tests/delegates/anonymous-optional-param.test
index f47ebbaeb..4ac24c470 100644
--- a/tests/delegates/anonymous-initializer.test
+++ b/tests/delegates/anonymous-optional-param.test
@@ -1,9 +1,9 @@
 Invalid Code
 
 /*
- * 11.18-11.20: error: syntax error, following expression/statement delimiter `)' missing
+ * 11.21-11.21: error: Optional parameters not allowed in anonymous delegates
  * void f (delegate(int=123) => int y) {
- *                  ^^^
+ *                     ^
  */
 
 void main () {
diff --git a/tests/delegates/anonymous-params.test b/tests/delegates/anonymous-params.test
new file mode 100644
index 000000000..4dcb3e698
--- /dev/null
+++ b/tests/delegates/anonymous-params.test
@@ -0,0 +1,19 @@
+Invalid Code
+
+/*
+ * 13.18-13.23: error: Params-arrays not allowed in anonymous delegates
+ * void f (delegate(params string[]) => void y) {
+ *                  ^^^^^^
+ */
+
+void main () {
+    f (t);
+}
+
+void f (delegate(params string[]) => void y) {
+    y ("1", "2", "3");
+}
+
+void t (params string[] p) {
+    assert (p.length == 3);
+}


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