X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;h=dccfb2a47bc2bdb50f7f3a39e7c3adf09ccf1b01;hp=8eebb8c3f6757d4472889f0128db1dd9e75429ff;hb=84f4783c47a0fcb74b7f46d3ff96fe8a3ad1b278;hpb=66f3d29e6a32a78cc54af282491683b7d2746ca4 diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index 8eebb8c..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.95) 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