From 1dd63caaa083c8d2f298a763d515badf8f34524c Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Mon, 21 Jan 2019 16:13:45 +0100 Subject: [PATCH] tests: Add asynchronous "catch-error-scope" regression test See https://gitlab.gnome.org/GNOME/vala/issues/741 --- tests/Makefile.am | 1 + tests/asynchronous/catch-error-scope.vala | 27 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/asynchronous/catch-error-scope.vala 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 (); +} -- 2.47.2