[vala/0.46] tests: Add dedicated "delegate without target through varargs" test
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] tests: Add dedicated "delegate without target through varargs" test
- Date: Sat, 5 Oct 2019 12:09:32 +0000 (UTC)
commit f8b63171cc2c1ce30ad3ecbd1b170a1d9d6d07a3
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 3efdffbba..b0323a475 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]