]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add dedicated "delegate without target through varargs" test
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 3 Oct 2019 11:34:52 +0000 (13:34 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 5 Oct 2019 11:45:55 +0000 (13:45 +0200)
tests/Makefile.am
tests/methods/varargs-delegate-without-target.vala [new file with mode: 0644]

index b8fd4d20ef3c4c99f16938db5b86311b8394087a..4bb01b38f51e62bd0f08d8dda252240edb61106b 100644 (file)
@@ -147,6 +147,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 (file)
index 0000000..49d5182
--- /dev/null
@@ -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);
+       }
+}