]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: implement struct field initialisation properly.
[ocean] / csrc / oceani-tests.mdc
index 90bfc19da11d84241256fdba41c6b06bd5376db9..d5541e9c3e21ea27ddb418d666789d8062c60beb 100644 (file)
@@ -533,7 +533,7 @@ ad-hoc things array related.
 
                for i:=0; then i=i+1; while i<5:
                        j ::= i
-                       ra:[5]number
+                       ra:[j]number
                        ra[i-1] = i*i
                        ra[6] = 42 // mustn't crash
                        print '', bools[i], ra[j-1],
@@ -551,10 +551,11 @@ 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
+               active:Boolean = True
 
        struct baz { a:number; b:Boolean; }
 
@@ -570,7 +571,8 @@ Time to test if structure declarations and accesses work correctly.
 
                        info[i].name = nm
                        info[i].size[0] = i*i
-                       info[i].active = nm == "jane"
+                       if nm != "jane":
+                               info[i].active = False
 
                for i:=0; then i=i+1; while i < 4:
                        print info[i].name, info[i].active, info[i].size[0]