X-Git-Url: https://ocean-lang.org/code/?a=blobdiff_plain;f=csrc%2Foceani-tests.mdc;h=e7e9f22486df6bdac410d996b2d7de05f7bd4e1b;hb=19148dce964ae988dab3981c8d7365576fb4767b;hp=e3739ed940802dd324eebc14fec1eefdc03c8be4;hpb=1dd9f61bbc7e8890b5407ba084793817e55fe502;p=ocean diff --git a/csrc/oceani-tests.mdc b/csrc/oceani-tests.mdc index e3739ed..e7e9f22 100644 --- a/csrc/oceani-tests.mdc +++ b/csrc/oceani-tests.mdc @@ -282,7 +282,9 @@ Here I break it into two parts, keeping the array code separate. ###### test: sayhello - program A B astr bbool: + program As Bs astr bbools: + A := $As; B := $Bs + bbool := bbools == "True" print "Hello World, what lovely oceans you have!" /* When a variable is defined in both branches of an 'if', * and used afterwards, the variables are merged. @@ -530,11 +532,15 @@ ad-hoc things array related. bools[1] = strings[2] <= "there" for i:=0; then i=i+1; while i<5: - print '', bools[i], + j ::= i + ra:[j]number + ra[i-1] = i*i + ra[6] = 42 // mustn't crash + print '', bools[i], ra[j-1], print ###### output: arrays - False True False False False + False 0 True 1 False 4 False 9 False 16 ## Structures @@ -545,8 +551,9 @@ Time to test if structure declarations and accesses work correctly. ###### test: structs + const three ::= 3 struct foo - size:[3]number + size:[three]number name:string active:Boolean