]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: add the option for "const" sections
[ocean] / csrc / oceani-tests.mdc
index a41b199d0cb6e14e2d839b821714f8325c45e88f..10a3b709daa49c5bc92122ee1d3eb0820561b285 100644 (file)
@@ -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
@@ -646,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