]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
tests: restore coverage testing.
[ocean] / csrc / oceani-tests.mdc
index 5366bf92ddf60e1045c5b0ed3a9bc6bee6cc560f..87a7aa99a548b876a4ef5962b446d03f0ec74800 100644 (file)
@@ -54,9 +54,16 @@ arguments separated from the name by commas.  For each test, there is a section
                    echo -n "printing.. "; \
                    echo '``````' > .tmp.code1; echo '``````' > .tmp.code2 ;\
                    ./oceani --noexec --print --section "test: $$t" oceani-tests.mdc >> .tmp.code1; \
-                   ./oceani --noexec --print .tmp.code1 >> .tmp.code2 ;\
+                   ./oceani --noexec --print .tmp.code1 >> .tmp.code2 || exit 1;\
                    if ! cmp -s .tmp.code1 .tmp.code2; then \
                       echo " Failed"; diff -u .tmp.code1 .tmp.code2; exit 1 ; fi ; \
+                   echo -n "extra-newlines.. "; \
+                   sed -e 'i\
+                   ' .tmp.code1 > .tmp.code1a; \
+                   echo '``````' > .tmp.code2a ;\
+                   ./oceani --noexec --print .tmp.code1a >> .tmp.code2a || exit 1;\
+                   if ! cmp -s .tmp.code1 .tmp.code2a; then \
+                      echo " Failed"; diff -u .tmp.code1 .tmp.code2a; exit 1; fi ; \
                    echo -n "exec-after-print.. "; \
                    ./oceani .tmp.code1 $${1+"$$@"} > .tmp.have ; \
                    if ! cmp -s .tmp.want .tmp.have; then \
@@ -68,8 +75,9 @@ arguments separated from the name by commas.  For each test, there is a section
 
                ## test code
 
+               @for i in coverage/#*.gcda; do mv $$i coverage/$${i##*#}; done
                @gcov -o coverage oceani.mdc > /dev/null 2> /dev/null
-               @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage
+               @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.94) exit(1) }' \
@@ -235,6 +243,16 @@ Now we need to test if/else and some different loops
                        print "Close enough"
                print "lower" if 355/113 < pi else "higher"
 
+               if pi > 3 then print "pi exceeds three"; else print "need more pie"
+               if (pi < 3) { print "not enough pi" } else { print "pi sufficient" }
+               for { i := 0; sum := 0 }
+               then { i = i+1 }
+               while i <= 10:
+                       sum = sum + i
+               else:
+                       pass
+                       print "sum 1..10 is", sum
+
 ###### output: cond_loop
        Success
         1 2 4 8 16 32 64
@@ -249,6 +267,9 @@ Now we need to test if/else and some different loops
        I won't calculate 20 / 9
        Close enough
        higher
+       pi exceeds three
+       pi sufficient
+       sum 1..10 is 55
 
 ## Say Hello
 
@@ -793,7 +814,7 @@ various places that `type_err()` are called.
 
 ###### output: type_err_const1
        .tmp.code:3:12: Syntax error in constant: :
-       .tmp.code:4:8: Syntax error in constant: bar
+       .tmp.code:4:12: Syntax error in constant: :
 
 ## Test erroneous command line args