]> ocean-lang.org Git - ocean/blobdiff - csrc/oceani-tests.mdc
oceani: allow types to be used before declaration
[ocean] / csrc / oceani-tests.mdc
index c13a9d173a5f0d876a500791f05fe2630023f073..d1557010e9c03d1cd27b895ace23989ef6227ff0 100644 (file)
@@ -585,6 +585,7 @@ Time to test if structure declarations and accesses work correctly.
        struct foo
                size:[three]number
                name:string
+               thing:baz
                active:Boolean = True
 
        struct baz { a:number; b:Boolean; }
@@ -607,6 +608,7 @@ Time to test if structure declarations and accesses work correctly.
 
                for i:=0; then i=i+1; while i < 4:
                        print info[i].name, info[i].active, info[i].size[0]
+               info[0].thing.b = True
 
 ###### output: structs
 
@@ -776,10 +778,10 @@ separate file first, then run from there.
                This is a multiline string
                With an unsupportable suffix
                """Aa
-       .tmp.code:14:11: error: undefined type: unknown
        .tmp.code:15:12: error: name undeclared: unknowable
        .tmp.code:17:12: error: array size must be a constant: zzsize
        .tmp.code:20:12: error: unrecognised number: 00123
+       .tmp.code:14:11: error: type used but not declared: unknown
 
 ## Tests for type errors
 
@@ -792,7 +794,7 @@ These programs were generated by looking for the
 various places that `type_err()` are called.
 
 ###### test list
-       oceani_failing_tests += type_err1 type_err2 type_err3 type_err4
+       oceani_failing_tests += type_err1 type_err2 type_err3 type_err4 type_err5
 
 ###### test: type_err1
 
@@ -921,6 +923,22 @@ various places that `type_err()` are called.
        .tmp.code:3:14: info: variable 'b' was set as none here.
        oceani: type error in program - not running.
 
+###### test: type_err5
+       struct foo
+               bar:baz
+               a:number
+       struct baz
+               bat:foo
+               b:string
+       struct foo
+               c:number
+
+###### output: type_err5
+       .tmp.code:8:7: error: type already declared: foo
+       .tmp.code:2:7: info: this is location of declartion: foo
+       .tmp.code:2:7: error: type has recursive definition: foo
+       .tmp.code:5:7: error: type has recursive definition: baz
+
 ###### test list
        oceani_failing_tests += type_err_const type_err_const1 type_err_const2 missing_program bad_main