From: Rico Tzschichholz Date: Sun, 18 Apr 2021 19:02:21 +0000 (+0200) Subject: tests: Extend "finally block execution" test to increase coverage X-Git-Tag: 0.50.8~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2278792c6d707f4efae935e606e497b53adcb985;p=thirdparty%2Fvala.git tests: Extend "finally block execution" test to increase coverage In addition to 9f21d0b182edad861f93a91674787b8b3b4fc2c5 See https://bugzilla.gnome.org/show_bug.cgi?id=579101 --- diff --git a/tests/errors/bug579101.vala b/tests/errors/bug579101.vala index 68726bac1..0f01887ad 100644 --- a/tests/errors/bug579101.vala +++ b/tests/errors/bug579101.vala @@ -1,3 +1,7 @@ +errordomain FooError { + FAIL +} + void do_foo (out int i) { i = 0; try { @@ -5,10 +9,54 @@ void do_foo (out int i) { } finally { i = 42; } + + assert_not_reached (); +} + +string do_bar (out int i) { + string s = "bar"; + try { + if (s == "bar") { + return s; + } + } finally { + i = 23; + } + + assert_not_reached (); +} + +string do_manam (out int i) { + string s = "manam"; + try { + throw new FooError.FAIL ("manam"); + } catch { + if (s == "manam") { + return s; + } + } finally { + i = 4711; + } + + assert_not_reached (); } void main () { - int i; - do_foo (out i); - assert (i == 42); + { + int i; + do_foo (out i); + assert (i == 42); + } + { + int i; + string s = do_bar (out i); + assert (i == 23); + assert (s == "bar"); + } + { + int i; + string s = do_manam (out i); + assert (i == 4711); + assert (s == "manam"); + } }