]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Extent "post-condition" method test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 1 Mar 2019 13:16:14 +0000 (14:16 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 1 Mar 2019 13:16:14 +0000 (14:16 +0100)
tests/methods/prepostconditions.vala

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