From: Rico Tzschichholz Date: Mon, 21 Jan 2019 15:13:45 +0000 (+0100) Subject: tests: Add asynchronous "catch-error-scope" regression test X-Git-Tag: 0.43.6~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1dd63caaa083c8d2f298a763d515badf8f34524c;p=thirdparty%2Fvala.git tests: Add asynchronous "catch-error-scope" regression test See https://gitlab.gnome.org/GNOME/vala/issues/741 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 554c235f7..c1f971b87 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -412,6 +412,7 @@ TESTS = \ asynchronous/bug792660.vala \ asynchronous/bug792942.vala \ asynchronous/bug793158.vala \ + asynchronous/catch-error-scope.vala \ asynchronous/closures.vala \ asynchronous/generator.vala \ asynchronous/out-parameter-invalid.test \ diff --git a/tests/asynchronous/catch-error-scope.vala b/tests/asynchronous/catch-error-scope.vala new file mode 100644 index 000000000..b479e8633 --- /dev/null +++ b/tests/asynchronous/catch-error-scope.vala @@ -0,0 +1,27 @@ +errordomain FooError { + FAIL +} + +async void foo () { + try { + throw new FooError.FAIL ("Foo"); + } catch (GLib.Error e) { + assert (e is FooError); + assert (e.message == "Foo"); + } + try { + throw new FooError.FAIL ("Bar"); + } catch (GLib.Error e) { + assert (e is FooError); + assert (e.message == "Bar"); + } +} + +void main () { + var loop = new MainLoop (); + foo.begin ((o, res) => { + foo.end (res); + loop.quit (); + }); + loop.run (); +}