X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;h=dccfb2a47bc2bdb50f7f3a39e7c3adf09ccf1b01;hp=4a3f5aa129962fb9932c0429efdde81c272f24f4;hb=84f4783c47a0fcb74b7f46d3ff96fe8a3ad1b278;hpb=c2a0a93d47f0a1d63c1a794d8f5cf99e04a85588 diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 4a3f5aa..dccfb2a 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -80,7 +80,7 @@ arguments separated from the name by commas. For each test, there is a section @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage || true @ awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \ END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \ - if (ran < (ran + skip) *0.947) exit(1) }' \ + if (ran < (ran + skip) *0.959) exit(1) }' \ coverage/oceani.mdc.gcov @rm -f .tmp* @@ -193,7 +193,7 @@ Test merging of variables from multiple cases for i:=0; then i=i+1; while i < 5: switch i: case 0: num:="zero" - case 1: num:="one" + case 1: scratch:=42; num:="one" case 2: num:="two" case 3: num:="three" else num:="many" @@ -267,6 +267,13 @@ Now we need to test if/else and some different loops else pass print "sum 1..10 is", sum + if + PI1 := 22/7 + use PI1 < pi + then + print "Smaller" + else + print 'larger' ###### output: cond_loop Success @@ -285,6 +292,7 @@ Now we need to test if/else and some different loops pi exceeds three pi sufficient sum 1..10 is 55 + larger ## Say Hello @@ -323,6 +331,7 @@ Here I break it into two parts, keeping the array code separate. a : number a = A; b:number = B + print "still", bigger // check for regression in scoping if a > 0 and b > 0: while a != b: if a < b: @@ -365,18 +374,20 @@ Here I break it into two parts, keeping the array code separate. else hi = mid if hi - lo < 1: + lo = mid use GiveUp use True do pass case Found: print "Yay, I found", target case GiveUp: - print "Closest I found was", mid + print "Closest I found was", lo ###### output: sayhello,55,33,hello,True Hello World, what lovely oceans you have! Is 55 bigger than 33 ? yes double 33 is 66 + still yes GCD of 55 and 33 is 11 Fibonacci: 1 1 2 3 5 8 13 21 34 55 89 144 hello was the str @@ -386,6 +397,7 @@ Here I break it into two parts, keeping the array code separate. Hello World, what lovely oceans you have! Is 12 bigger than 60 ? no double 60 is 120 + still no GCD of 12 and 60 is 12 Fibonacci: 1 1 2 3 5 8 13 21 34 55 89 144 I found the str over there @@ -768,6 +780,13 @@ various places that `type_err()` are called. foo.c = 43 print c.foo print bar.c + print bar.b + 42 + + + // trigger 'labels not permitted' error message + while 1 if True else False: + print + case 2: print "two" ###### output: type_err3 .tmp.code:8:12: error: expected number but variable 'c' is string @@ -798,6 +817,8 @@ various places that `type_err()` are called. .tmp.code:32:16: error: expected none found number .tmp.code:33:14: error: field reference attempted on string, not a struct .tmp.code:34:14: error: cannot find requested field in foo + .tmp.code:35:17: error: have string but need number + .tmp.code:39:29: error: expected number (labels not permitted) found Boolean oceani: type error in program - not running. ###### test: type_err4