]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extent "post-condition" virtual method test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 17 Oct 2019 07:51:21 +0000 (09:51 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 7 Nov 2019 10:52:38 +0000 (11:52 +0100)
tests/methods/prepostconditions.vala

index 0ae57e054edead6f33a7bf6f47176a7be2c468a8..d7474df757f384f07c18f7d193c8d305724974a4 100644 (file)
@@ -41,6 +41,24 @@ class Foo {
                        assert_not_reached ();
                }
        }
+
+       public virtual int manam (int i) ensures (result > 23) {
+               switch (i) {
+               case 67:
+                       return i;
+               default:
+                       assert_not_reached ();
+               }
+       }
+
+       public virtual int manam_pre (int i) requires (i > 23) {
+               switch (i) {
+               case 231:
+                       return i;
+               default:
+                       assert_not_reached ();
+               }
+       }
 }
 
 void main () {
@@ -53,6 +71,8 @@ void main () {
        assert(foo.bar_pre (4711) == 4711);
        assert (foo.faz (42) == 42);
        assert (foo.faz_pre (4711) == 4711);
+       assert (foo.manam (67) == 67);
+       assert (foo.manam_pre (231) == 231);
 
        var foo2 = new Foo.post ();
        assert (foo2.ensured);