[vala/wip/issue/838: 1/6] tests: Extend "pre- and post-condition" test to increase coverage



commit 378b9e66f5bcbc76e21936d1b75c3291f3ff1534
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Aug 29 17:08:46 2019 +0200

    tests: Extend "pre- and post-condition" test to increase coverage

 tests/methods/prepostconditions.vala | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/tests/methods/prepostconditions.vala b/tests/methods/prepostconditions.vala
index f7c4eaf68..214c4800a 100644
--- a/tests/methods/prepostconditions.vala
+++ b/tests/methods/prepostconditions.vala
@@ -20,6 +20,24 @@ class Foo {
                assert (i == 4711);
                return i;
        }
+
+       public int faz (int i) ensures (result > 23) {
+               switch (i) {
+               case 42:
+                       return i;
+               default:
+                       assert_not_reached ();
+               }
+       }
+
+       public int faz_pre (int i) requires (i > 23) {
+               switch (i) {
+               case 4711:
+                       return i;
+               default:
+                       assert_not_reached ();
+               }
+       }
 }
 
 void main () {
@@ -30,4 +48,6 @@ void main () {
        assert(foo.bar () == "bar");
        foo.foo_pre (42);
        assert(foo.bar_pre (4711) == 4711);
+       assert (foo.faz (42) == 42);
+       assert (foo.faz_pre (4711) == 4711);
 }


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