]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add test for closures in async methods
authorJürg Billeter <j@bitron.ch>
Thu, 20 Jan 2011 10:04:11 +0000 (11:04 +0100)
committerJürg Billeter <j@bitron.ch>
Thu, 20 Jan 2011 10:19:58 +0000 (11:19 +0100)
tests/Makefile.am
tests/asynchronous/bug639591.vala [changed mode: 0755->0644]
tests/asynchronous/closures.vala [new file with mode: 0644]

index fdc67028b14e66921aeb33dfe2cf10e359993f0a..a36720cb31c2936447c9075cc81c0544d441d80a 100644 (file)
@@ -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 \
old mode 100755 (executable)
new mode 100644 (file)
diff --git a/tests/asynchronous/closures.vala b/tests/asynchronous/closures.vala
new file mode 100644 (file)
index 0000000..79b020a
--- /dev/null
@@ -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 ();
+}
+