X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;h=10a3b709daa49c5bc92122ee1d3eb0820561b285;hb=4b606ddde48d77e17516373af8dc852df3b26651;hp=a41b199d0cb6e14e2d839b821714f8325c45e88f;hpb=b5118330ab3e8d5eaaeca4087f2e2e92380678dd;p=ocean diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index a41b199..10a3b70 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -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