]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: free variables as soon as they go out of scope.
[ocean] / csrc / oceani-tests.mdc
index 2433cce68593ee7f01153beec063927f4259b05f..dccfb2a47bc2bdb50f7f3a39e7c3adf09ccf1b01 100644 (file)
@@ -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.948) 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:
@@ -378,6 +387,7 @@ Here I break it into two parts, keeping the array code separate.
        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
@@ -387,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