[vala/staging] tests: Add dedicated "delegate without target through varargs" test



commit 1bce8c0287e12783e846ee52b1eca1526a0510bc
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Oct 3 13:34:52 2019 +0200

    tests: Add dedicated "delegate without target through varargs" test

 tests/Makefile.am                                  |  1 +
 tests/methods/varargs-delegate-without-target.vala | 31 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc3f0773e..068914630 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -149,6 +149,7 @@ TESTS = \
        methods/printf-invalid.test \
        methods/printf-constructor.vala \
        methods/printf-constructor-invalid.test \
+       methods/varargs-delegate-without-target.vala \
        methods/varargs-gvalue.vala \
        methods/varargs-out.vala \
        methods/varargs-struct.vala \
diff --git a/tests/methods/varargs-delegate-without-target.vala 
b/tests/methods/varargs-delegate-without-target.vala
new file mode 100644
index 000000000..49d5182f4
--- /dev/null
+++ b/tests/methods/varargs-delegate-without-target.vala
@@ -0,0 +1,31 @@
+[CCode (has_target = false)]
+delegate string Foo ();
+
+string foo (void* data) {
+       return "foo";
+}
+
+void bar (int first, ...) {
+       assert (first == 23);
+       var args = va_list ();
+       Foo** out_func = args.arg ();
+       *out_func = (Foo) foo;
+}
+
+void baz (int first, ...) {
+       assert (first == 42);
+       var args = va_list ();
+       Foo func = args.arg ();
+       assert (func () == "foo");
+}
+
+void main () {
+       {
+               Foo func;
+               bar (23, out func);
+               assert (func () == "foo");
+       }
+       {
+               baz (42, foo);
+       }
+}


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