X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;fp=csrc%2Foceani-tests.mdc;h=6d513487e619bc695ed3b25fd6048c789971a745;hp=9db8e9363a469d66beb43cdceae215136542a862;hb=454d1b434bdcc76d33d3eb5eace74a3de2fd1aa3;hpb=2d3b3f67a78d853da192c5568a29710fb8898a6c diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 9db8e93..6d51348 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -97,7 +97,7 @@ arguments separated from the name by commas. For each test, there is a section ## valgrind test code @[ -n "$$SKIP_COVERAGE_CHECK" ] || awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \ END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \ - if (ran < (ran + skip) *0.972) exit(1) }' \ + if (ran < (ran + skip) *0.98) exit(1) }' \ coverage/oceani.mdc.gcov coverage_oceani: oceani.c @@ -142,6 +142,9 @@ calculations on them. print "z??False", z??False, "w??False", w??False if ?w: print "Weird?" + print $"-34.56", $"not-a-number" + print $"4i" + if True { pass; pass } ###### output: valvar @@ -154,6 +157,9 @@ calculations on them. w??z True z??w True z??False True w??False False + -34.56 0 + Unsupported suffix: 4i + 4 Next we change the value of variables @@ -271,6 +277,7 @@ Now we need to test if/else and some different loops if 355/113 == pi or else +(pi - 355/113) < 0.001: print "Close enough" print "lower" if 355/113 < pi else "higher" + print "higher" if 355/113 > pi else "lower" if pi > 3 then print "pi exceeds three"; else print "need more pie" if (pi < 3) { print "not enough pi" } else { print "pi sufficient" } @@ -303,6 +310,7 @@ Now we need to test if/else and some different loops I won't calculate 20 / 9 Close enough higher + higher pi exceeds three pi sufficient sum 1..10 is 55 @@ -597,7 +605,7 @@ Time to test if structure declarations and accesses work correctly. const three ::= 3 struct foo size:[three]number - name:string + name:string = "Hello" thing:baz active:Boolean = True @@ -951,6 +959,8 @@ various places that `type_err()` are called. case 2: print "two" print "one" ++ a4[], c[] + x:Boolean = $"42" + ###### output: type_err3 .tmp.code:8:12: error: expected number but variable 'c' is string .tmp.code:7:8: info: this is where 'c' was set to string @@ -987,6 +997,8 @@ various places that `type_err()` are called. .tmp.code:38:29: error: expected number found Boolean .tmp.code:41:23: error: have number but need string .tmp.code:41:29: error: string cannot provide length + .tmp.code:43:21: error: Can only convert string to number, not Boolean + .tmp.code:43:8: info: variable 'x' was set as Boolean here. oceani: type error in program - not running. ###### test: type_err4