]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: add the option for "const" sections
[ocean] / csrc / oceani-tests.mdc
index 8649f6e2e77290fe3dbde90f7d83835d67eee4c0..10a3b709daa49c5bc92122ee1d3eb0820561b285 100644 (file)
@@ -72,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*
 
@@ -131,6 +131,29 @@ Next we change the value of variables
 ###### output: setvar
        1.07374e+09 1
 
+Now some contants
+
+###### test list
+       oceani_tests += "consts"
+
+###### test: consts
+       const:
+               pi ::= 3.1415926
+               four ::= 2 + 2 ; five ::= 10/2
+       const pie ::= "I like Pie";
+               cake ::= "The cake is"
+                 ++ " a lie"
+
+       program:
+               print "Hello World, what lovely oceans you have!"
+               print "are there", five, "?"
+               print pi, pie, "but", cake
+
+###### output: consts
+       Hello World, what lovely oceans you have!
+       are there 5 ?
+       3.14159 I like Pie but The cake is a lie
+
 ## Conditions and Loops
 
 Now we need to test if/else and some different loops
@@ -487,6 +510,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:
@@ -645,6 +669,39 @@ various places that `type_err()` are called.
        .tmp.code:3:14: info: this is where 'b' was set to label
        oceani: type error in program - not running.
 
+###### test list
+       oceani_failing_tests += type_err_const type_err_const1
+
+###### test: type_err_const
+       const:
+               foo :: number = 45
+               bar ::= "string" + 56
+       const:
+               bar ::= "baz"
+       program:
+               foo := 4
+               print foo, bar
+
+###### output: type_err_const
+       .tmp.code:4:16: error: expected number found string
+       .tmp.code:6:8: error: name already declared: bar
+       .tmp.code:4:8: info: this is where 'bar' was first declared
+       .tmp.code:8:8: error: variable 'foo' redeclared
+       .tmp.code:3:8: info: this is where 'foo' was first declared
+
+###### test: type_err_const1
+       const:
+               foo : number = 45
+               bar := "string"
+       program:
+               foo := 4
+               print foo, bar
+
+###### output: type_err_const1
+       .tmp.code:3:12: error: unhandled parse error: :
+       oceani: no program found.
+
+
 ## Test erroneous command line args
 
 To improve coverage, we want to test correct handling of strange command