]> ocean-lang.org Git - ocean/commitdiff
oceani-tests: add tests for various token-errors
authorNeilBrown <neil@brown.name>
Mon, 6 May 2019 07:57:05 +0000 (17:57 +1000)
committerNeilBrown <neil@brown.name>
Mon, 6 May 2019 08:30:05 +0000 (18:30 +1000)
This pushes our coverage over 80%

Signed-off-by: NeilBrown <neil@brown.name>
csrc/oceani-tests.mdc

index 80160a0becc355a704e9d99157d563e2daba8675..d0b14190e7a31ff1fc59a0f7c1c0c6bdbcff7279 100644 (file)
@@ -68,7 +68,7 @@ arguments separated from the name by commas.  For each test, there is a section
                @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage
                @ awk '/^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
                    END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
                @mv *.gcov coverage ; [ -f .gcov ] && mv .gcov coverage
                @ awk '/^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \
                    END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \
-                        if (ran < (ran + skip) *0.75) exit(1) }' \
+                        if (ran < (ran + skip) *0.8) exit(1) }' \
                        coverage/oceani.mdc.gcov
                @rm -f .tmp*
 
                        coverage/oceani.mdc.gcov
                @rm -f .tmp*
 
@@ -399,6 +399,11 @@ Syntax errors aren't handled well yet - the result is almost always a
 single message about the first error.  So this section will be fairly
 thin until we add proper parsing recovery in the face of common errors.
 
 single message about the first error.  So this section will be fairly
 thin until we add proper parsing recovery in the face of common errors.
 
+A special case of syntax errors is token errors, when a token is only
+accepted because the parser doesn't know quite enough to reject it.
+There are handled better as they are quite local, so a single test
+program can trigger most of the possible errors.
+
 To handle erronous code, we need a different set of tests, as we need to
 capture `stderr`. The same test code will be used for type errors too.
 As error messages contain the line number, and we don't want changes to
 To handle erronous code, we need a different set of tests, as we need to
 capture `stderr`. The same test code will be used for type errors too.
 As error messages contain the line number, and we don't want changes to
@@ -420,6 +425,7 @@ separate file first, then run from there.
 
 ###### test list
        oceani_failing_tests := syn1
 
 ###### test list
        oceani_failing_tests := syn1
+       oceani_failing_tests += tokerr
 
 ###### test: syn1
 
 
 ###### test: syn1
 
@@ -429,6 +435,37 @@ separate file first, then run from there.
 ###### output: syn1
        .tmp.code:3:11: error: unhandled parse error: then
 
 ###### output: syn1
        .tmp.code:3:11: error: unhandled parse error: then
 
+###### test: tokerr
+       program:
+               a := 1i  // imaginary numbers aren't understood
+               b:[2i]number // array sizes are handled separately
+               c:[3.14159]Boolean // array sizes must be integers
+               d:[1_000_000_000_000]number // they mustn't be huge
+               patn: string = "foo[ ,_]*bar"re // regexp strings are just a dream
+
+               multi := """
+               This is a multiline string
+               With an unsupportable suffix
+               """Aa
+
+               xx:unknown = 24
+               yy:[unknowable]number
+               zzsize := 4
+               zz:[zzsize]string // size must be constant, use ::=
+
+###### output: tokerr
+       .tmp.code:3:13: error: unsupported number suffix: 1i
+       .tmp.code:4:11: error: unsupported number suffix: 2i
+       .tmp.code:5:11: error: array size must be an integer: 3.14159
+       .tmp.code:6:11: error: array size is too large: 1_000_000_000_000
+       .tmp.code:7:23: error: unsupported string suffix: "foo[ ,_]*bar"re
+       .tmp.code:9:17: error: unsupported string suffix: """
+               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
 
 ## Test erroneous command line args
 
 
 ## Test erroneous command line args