[vala/0.48] tests: Extend "finally block execution" test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] tests: Extend "finally block execution" test to increase coverage
- Date: Wed, 28 Apr 2021 07:47:06 +0000 (UTC)
commit d23cb165f9bdfd649003d69b03e16b1aa72c6510
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Apr 18 21:02:21 2021 +0200
tests: Extend "finally block execution" test to increase coverage
In addition to 9f21d0b182edad861f93a91674787b8b3b4fc2c5
See https://bugzilla.gnome.org/show_bug.cgi?id=579101
tests/errors/bug579101.vala | 54 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
---
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");
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]