]> ocean-lang.org Git - ocean/commitdiff
oceani-tests: continue to improve test coverage
authorNeilBrown <neil@brown.name>
Wed, 3 Nov 2021 01:29:34 +0000 (12:29 +1100)
committerNeilBrown <neil@brown.name>
Mon, 8 Nov 2021 09:56:36 +0000 (20:56 +1100)
Add a couple of error tests, and mark some code as NOTEST

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani-tests.mdc
csrc/oceani.mdc

index 4a3f5aa129962fb9932c0429efdde81c272f24f4..8eebb8c3f6757d4472889f0128db1dd9e75429ff 100644 (file)
@@ -80,7 +80,7 @@ arguments separated from the name by commas.  For each test, there is a section
                @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage || true
                @ awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
                    END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
-                        if (ran < (ran + skip) *0.947) exit(1) }' \
+                        if (ran < (ran + skip) *0.95) exit(1) }' \
                        coverage/oceani.mdc.gcov
                @rm -f .tmp*
 
@@ -768,6 +768,13 @@ various places that `type_err()` are called.
                foo.c = 43
                print c.foo
                print bar.c
+               print bar.b + 42
+               
+
+               // trigger 'labels not permitted' error message
+               while 1 if True else False:
+                       print
+               case 2: print "two"
 
 ###### output: type_err3
        .tmp.code:8:12: error: expected number but variable 'c' is string
@@ -798,6 +805,8 @@ various places that `type_err()` are called.
        .tmp.code:32:16: error: expected none found number
        .tmp.code:33:14: error: field reference attempted on string, not a struct
        .tmp.code:34:14: error: cannot find requested field in foo
+       .tmp.code:35:17: error: have string but need number
+       .tmp.code:39:29: error: expected number (labels not permitted) found Boolean
        oceani: type error in program - not running.
 
 ###### test: type_err4
index 5e26237d7463b0f4e63939c553170959c1006ce0..e399a2a88374389ada32a9315ea51f84b822e877 100644 (file)
@@ -618,9 +618,9 @@ A separate function encoding these cases will simplify some code later.
        static int type_compat(struct type *require, struct type *have, int rules)
        {
                if ((rules & Rboolok) && have == Tbool)
-                       return 1;
+                       return 1;       // NOTEST
                if ((rules & Rnolabel) && have == Tlabel)
-                       return 0;
+                       return 0;       // NOTEST
                if (!require || !have)
                        return 1;
 
@@ -772,7 +772,7 @@ A separate function encoding these cases will simplify some code later.
                t->size = size;
                t->align = size > sizeof(void*) ? sizeof(void*) : size;
                if (t->size & (t->align - 1))
-                       t->size = (t->size | (t->align - 1)) + 1;
+                       t->size = (t->size | (t->align - 1)) + 1;       // NOTEST
                return t;
        }