]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: add conditional expression
[ocean] / csrc / oceani-tests.mdc
index f5f097a1b4ac0a77c648552fb0f00658fa710084..d5e60b739236ab9417b19fa11e329d49e1032a22 100644 (file)
@@ -157,6 +157,16 @@ Now we need to test if/else and some different loops
                        count = count + 1
                print "error is ", target - guess * guess
 
+               for j:=0; then j = j+3 ; while j < 10:
+                       if j != 0 and then 20 / j > 3:
+                               print "20 /", j," =", 20 / j
+                       else:
+                               print "I won't calculate 20 /", j
+               pi ::= 3.1415926535897
+               if 355/113 == pi or else +(pi - 355/113) < 0.001:
+                       print "Close enough"
+               print "lower" if 355/113 < pi else "higher"
+
 ###### output: cond_loop
        Success
         1 2 4 8 16 32 64
@@ -165,6 +175,12 @@ Now we need to test if/else and some different loops
        2 1.41422
        3 1.41421
        error is  -4.51095e-12
+       I won't calculate 20 / 0
+       20 / 3  = 6.66667
+       20 / 6  = 3.33333
+       I won't calculate 20 / 9
+       Close enough
+       higher
 
 ## Say Hello