summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-10-03 13:34:52 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2019-10-05 13:45:55 +0200
commit0c428afc82b9910e9f9553792e25af7a54cd09a3 (patch)
treed9b48d27340a11e0754ed163e5512e0343bc96e5
parentb717186b076e19a14f03484a9c2b8e6d4b302428 (diff)
downloadvala-0c428afc82b9910e9f9553792e25af7a54cd09a3.tar.gz
tests: Add dedicated "delegate without target through varargs" test
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/methods/varargs-delegate-without-target.vala31
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b8fd4d20e..4bb01b38f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
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);
+ }
+}