[vala/0.40] 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.40] tests: Add dedicated "delegate without target through varargs" test
- Date: Wed, 9 Oct 2019 17:35:21 +0000 (UTC)
commit 9567951a62671b679435b361f33a527996176ec5
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 a95daf3ae..88beb89ec 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -137,6 +137,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]