[vala] Add test for closures in async methods



commit 4ba52a117418889bcb5d82a51a8defdee48fe551
Author: Jürg Billeter <j bitron ch>
Date:   Thu Jan 20 11:04:11 2011 +0100

    Add test for closures in async methods

 tests/Makefile.am                 |    1 +
 tests/asynchronous/closures.vala  |   25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fdc6702..a36720c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -90,6 +90,7 @@ TESTS = \
 	asynchronous/bug613484.vala \
 	asynchronous/bug620740.vala \
 	asynchronous/bug639591.vala \
+	asynchronous/closures.vala \
 	dbus/basic-types.test \
 	dbus/arrays.test \
 	dbus/structs.test \
diff --git a/tests/asynchronous/bug639591.vala b/tests/asynchronous/bug639591.vala
old mode 100755
new mode 100644
diff --git a/tests/asynchronous/closures.vala b/tests/asynchronous/closures.vala
new file mode 100644
index 0000000..79b020a
--- /dev/null
+++ b/tests/asynchronous/closures.vala
@@ -0,0 +1,25 @@
+delegate void Func ();
+
+MainLoop main_loop;
+
+async void foo () {
+	string bar = "hello";
+	Func foobar = () => {
+		bar = "world";
+	};
+	foobar ();
+	assert (bar == "world");
+
+	Idle.add (foo.callback);
+	yield;
+
+	main_loop.quit ();
+}
+
+void main () {
+	foo.begin ();
+
+        main_loop = new MainLoop (null, false);
+        main_loop.run ();
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]