summaryrefslogtreecommitdiff
path: root/tests/delegates
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2019-10-02 19:07:17 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2019-10-03 15:15:46 +0200
commitc054da918a40f8ef93c1a006034fb6ab4717c135 (patch)
tree8d507d7d5924696de01edc0c8b4a5cb452c577b6 /tests/delegates
parentca7ab54681593a25b51c118e9aba40f44adf3f3d (diff)
downloadvala-c054da918a40f8ef93c1a006034fb6ab4717c135.tar.gz
vala: Add DelegateType.target/destroy fields to access its user-data
Fixes https://gitlab.gnome.org/GNOME/vala/issues/857
Diffstat (limited to 'tests/delegates')
-rw-r--r--tests/delegates/member-target-destroy.vala23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/delegates/member-target-destroy.vala b/tests/delegates/member-target-destroy.vala
new file mode 100644
index 000000000..468bff95f
--- /dev/null
+++ b/tests/delegates/member-target-destroy.vala
@@ -0,0 +1,23 @@
+delegate string Foo ();
+
+string bar (string s) {
+ return s;
+}
+
+void foo_free (void* data) {
+ GLib.free (data);
+}
+
+void main () {
+ Foo foo = (Foo) bar;
+ assert (foo.target == null);
+ assert (foo.destroy == null);
+
+ string* foo_data = "foo".dup ();
+ foo.target = foo_data;
+ foo.destroy = (GLib.DestroyNotify) foo_free;
+
+ assert (foo () == "foo");
+ assert (foo.target == foo_data);
+ assert (foo.destroy == (GLib.DestroyNotify) foo_free);
+}