[vala/staging] tests: Add asynchronous "catch-error-scope" regression test



commit 1dd63caaa083c8d2f298a763d515badf8f34524c
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Jan 21 16:13:45 2019 +0100

    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(+)
---
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 ();
+}


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