]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: allow list of declarations as top level structure
[ocean] / csrc / oceani-tests.mdc
index f5f097a1b4ac0a77c648552fb0f00658fa710084..a41b199d0cb6e14e2d839b821714f8325c45e88f 100644 (file)
@@ -38,6 +38,8 @@ arguments separated from the name by commas.  For each test, there is a section
 
        tests:: oceani_test_suite
        oceani_test_suite: oceani coverage_oceani
+               @./parsergen --report --LR1 --tag Parser oceani.mdc | grep " - no conflicts" > /dev/null || \
+                   { echo "Grammar container conflicts, please review" ; exit 1; }
                @rm -rf coverage; mkdir -p coverage
                @cp *.gcno coverage
                @for T in $(oceani_tests); do \
@@ -48,9 +50,13 @@ arguments separated from the name by commas.  For each test, there is a section
                    if ! cmp -s .tmp.want .tmp.have; then \
                       echo "FAILED"; diff -u .tmp.want .tmp.have ; exit 1; fi ;\
                    echo -n "passed ... "; \
-                   if ! valgrind ./oceani --section "test: $$t" oceani-tests.mdc $${1+"$$@"} \
-                        > /dev/null 2> .tmp.valg; then \
+                   if ! valgrind --error-exitcode=1 --log-file=.tmp.valg ./oceani --section "test: $$t" oceani-tests.mdc $${1+"$$@"} \
+                        > /dev/null 2>&1 ; then \
                       echo "valgrind FAILED"; cat .tmp.valg; exit 1; fi ; \
+                   if grep 'LEAK SUMMARY' .tmp.valg > /dev/null; then \
+                      echo "valgrind found LEAKS"; cat .tmp.valg ; exit 1 ; fi; \
+                   if grep 'in use at exit [1-9]' .tmp.valg > /dev/null; then \
+                      echo "valgrind found memory in use at exit"; cat .tmp.valg ; exit 1 ; fi; \
                    echo -n "valgrind passed ... "; \
                    echo '``````' > .tmp.code1; echo '``````' > .tmp.code2 ;\
                    ./oceani --noexec --print --section "test: $$t" oceani-tests.mdc >> .tmp.code1; \
@@ -66,9 +72,9 @@ arguments separated from the name by commas.  For each test, there is a section
 
                @gcov -o coverage oceani.mdc > /dev/null 2> /dev/null
                @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage
-               @ awk '/^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
+               @ awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
                    END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
-                        if (ran < (ran + skip) *0.90) exit(1) }' \
+                        if (ran < (ran + skip) *0.93) exit(1) }' \
                        coverage/oceani.mdc.gcov
                @rm -f .tmp*
 
@@ -157,6 +163,16 @@ Now we need to test if/else and some different loops
                        count = count + 1
                print "error is ", target - guess * guess
 
+               for j:=0; then j = j+3 ; while j < 10:
+                       if j != 0 and then 20 / j > 3:
+                               print "20 /", j," =", 20 / j
+                       else:
+                               print "I won't calculate 20 /", j
+               pi ::= 3.1415926535897
+               if 355/113 == pi or else +(pi - 355/113) < 0.001:
+                       print "Close enough"
+               print "lower" if 355/113 < pi else "higher"
+
 ###### output: cond_loop
        Success
         1 2 4 8 16 32 64
@@ -165,6 +181,12 @@ Now we need to test if/else and some different loops
        2 1.41422
        3 1.41421
        error is  -4.51095e-12
+       I won't calculate 20 / 0
+       20 / 3  = 6.66667
+       20 / 6  = 3.33333
+       I won't calculate 20 / 9
+       Close enough
+       higher
 
 ## Say Hello
 
@@ -465,6 +487,7 @@ separate file first, then run from there.
 
 ###### output: syn1
        .tmp.code:3:11: error: unhandled parse error: then
+       oceani: no program found.
 
 ###### test: tokerr
        program: