]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extend "pre- and post-condition" test to increase coverage 378b9e66f5bcbc76e21936d1b75c3291f3ff1534
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 29 Aug 2019 15:08:46 +0000 (17:08 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 29 Aug 2019 17:22:00 +0000 (19:22 +0200)
tests/methods/prepostconditions.vala

index f7c4eaf68953201e429b62ee5bf6f99bd548225a..214c4800a61cd06f5b9f820110d19c7fc1850ba8 100644 (file)
@@ -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);
 }