[vala/0.40] tests: Extent "post-condition" method test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.40] tests: Extent "post-condition" method test to increase coverage
- Date: Tue, 9 Apr 2019 13:48:20 +0000 (UTC)
commit 4e4c44e4115daba4f084b4ba879928c72ec3211a
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Fri Mar 1 14:16:14 2019 +0100
tests: Extent "post-condition" method test to increase coverage
tests/methods/prepostconditions.vala | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
---
diff --git a/tests/methods/prepostconditions.vala b/tests/methods/prepostconditions.vala
index aeae32a9f..f7c4eaf68 100644
--- a/tests/methods/prepostconditions.vala
+++ b/tests/methods/prepostconditions.vala
@@ -1,5 +1,9 @@
class Foo {
public bool ensured = false;
+ public bool required = false;
+
+ public Foo () requires (required = true) {
+ }
public void foo () ensures (ensured = true) {
}
@@ -7,11 +11,23 @@ class Foo {
public string bar () ensures (result.length >= 3) {
return "bar";
}
+
+ public void foo_pre (int i) requires (i > 23) {
+ assert (i == 42);
+ }
+
+ public int bar_pre (int i) requires (i > 42) {
+ assert (i == 4711);
+ return i;
+ }
}
void main () {
var foo = new Foo();
+ assert(foo.required);
foo.foo();
assert(foo.ensured);
assert(foo.bar () == "bar");
+ foo.foo_pre (42);
+ assert(foo.bar_pre (4711) == 4711);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]