From: Jürg Billeter Date: Thu, 20 Jan 2011 10:04:11 +0000 (+0100) Subject: Add test for closures in async methods X-Git-Tag: 0.11.5~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ba52a117418889bcb5d82a51a8defdee48fe551;p=thirdparty%2Fvala.git Add test for closures in async methods --- diff --git a/tests/Makefile.am b/tests/Makefile.am index fdc67028b..a36720cb3 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 000000000..79b020a19 --- /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 (); +} +