From: NeilBrown Date: Wed, 29 May 2019 08:27:47 +0000 (+1000) Subject: scanner tests: handle errors and more X-Git-Url: https://ocean-lang.org/code/?p=ocean;a=commitdiff_plain;h=744a59663bace6a4d9db58ec97c4cf9aa24082a9 scanner tests: handle errors and more Handle assorted more cases, particularly errors. Now coverage has passed 90% Signed-off-by: NeilBrown --- diff --git a/csrc/scanner-tests.mdc b/csrc/scanner-tests.mdc index 3646208..9756b08 100644 --- a/csrc/scanner-tests.mdc +++ b/csrc/scanner-tests.mdc @@ -36,7 +36,7 @@ about each test. @mv *.gcov coverage; [ -f .gcov ] && mv .gcov coverage || true @awk '/NOTEST/ { next } /^ *[1-9]/ {ran+=1} /^ *###/ {skip+=1} \ END {printf "coverage: %6.2f%%\n", ran * 100 / (ran + skip); \ - if (ran < (ran + skip) *0.85) exit(1) }' \ + if (ran < (ran + skip) *0.90) exit(1) }' \ coverage/scanner.mdc.gcov @rm -f .tmp* @@ -77,7 +77,7 @@ Some simple tests... maybe all tests are simple. if else then fi while 1234, 1.234 -123.456e45 - 0x1234 + 0x543p3 + 0x1234 + 0x543p+3 "This is a string" &"so is this"a a = """ This is a multi- @@ -151,7 +151,7 @@ Some simple tests... maybe all tests are simple. 19:0 newline() 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 + 19:10 number(0x543p+3) 10776 20:0 newline() 20:0 string("This is a string") This is a string 20:19 mark(&) @@ -238,7 +238,7 @@ Some simple tests... maybe all tests are simple. 19:0 newline() 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 + 19:10 number(0x543p+3) 10776 20:0 newline() 20:0 string("This is a string") This is a string 20:19 mark(&) @@ -314,8 +314,8 @@ Some simple tests... maybe all tests are simple. 18:24 newline() 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 - 19:17 newline() + 19:10 number(0x543p+3) 10776 + 19:18 newline() 20:0 string("This is a string") This is a string 20:19 mark(&) 20:20 string("so is this"a) a so is this @@ -373,7 +373,7 @@ Some simple tests... maybe all tests are simple. 18:14 number(123.456e45) 123456000000000000000000000000000000000000000000 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 + 19:10 number(0x543p+3) 10776 20:0 string("This is a string") This is a string 20:19 mark(&) 20:20 string("so is this"a) a so is this @@ -425,7 +425,7 @@ Some simple tests... maybe all tests are simple. 18:14 number(123.456e45) 123456000000000000000000000000000000000000000000 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 + 19:10 number(0x543p+3) 10776 20:0 string("This is a string") This is a string 20:19 mark(&) 20:20 string("so is this"a) a so is this @@ -474,7 +474,7 @@ Some simple tests... maybe all tests are simple. 18:14 number(123.456e45) 123456000000000000000000000000000000000000000000 19:0 number(0x1234 ) 4660 19:7 + - 19:10 number(0x543p3) 10776 + 19:10 number(0x543p+3) 10776 20:0 mark(") 20:1 ident(This) 20:6 ident(is) @@ -513,3 +513,119 @@ Some simple tests... maybe all tests are simple. 31:10 + 31:12 ident(divisor) 32:0 eof() + +## Error tests + +Now to test for some errors ... though things I thought would be errors +sometimes aren't. + +###### test list + scanner_tests += "errtest,--ignore-ident,--ignore-mark,-W_,-w_,if,then,+,-" + scanner_tests += "errtest,--ignore-ident,--ignore-mark,-N,if,then,+,-" + +###### test: errtest + + multiple decimal pointer 3.141.59 + "Check for decimal commas" 3,14159 = 3,141,59 + """A multi-string must not have text here + """ + "or after close" + """ + no text .. + """ here + + /* No embedded /* comments */ in comments */ + /* or content after + * a multiline comment */ Error + + " \\ \t \n special chars in strings" + +###### output: errtest,--ignore-ident,--ignore-mark,-W_,-w_,if,then,+,- + + Tokenizing: + 2:0 ERROR(multiple) + 2:9 ERROR(decimal) + 2:17 ERROR(pointer) + 2:25 number(3.141) 3141/1000 + 2:30 ERROR(.) + 2:31 number(59) 59 + 3:0 newline() + 3:0 string("Check for decimal..) Check for decimal .. + 3:27 number(3,14159) 314159/100000 + 3:35 ERROR(=) + 3:37 number(3,141) 3141/1000 + 3:42 ERROR(,) + 3:43 number(59) 59 + 4:0 newline() + 4:0 string("") + 4:2 ERROR("A multi-string mu..) + 5:0 newline() + 5:0 ERROR("""\x0a"or after clos..) + 8:12 ERROR(here) + 10:0 newline() + 10:0 newline() + 10:0 ERROR(/* No embedded /*) + 10:15 bcomment(/* comments */) + 10:30 ERROR(in) + 10:33 ERROR(comments) + 10:42 ERROR(*/) + 11:0 newline() + 11:0 ERROR(/* or content afte..) + 12:26 ERROR(Error) + 14:0 newline() + 14:0 newline() + 14:0 string(" \\\\ \\t \\n specia..) \\ \x09 \x0a special ch.. + 15:0 newline() + 15:0 eof() + +###### output: errtest,--ignore-ident,--ignore-mark,-N,if,then,+,- + Tokenizing: + 2:0 ERROR(multiple) + 2:9 ERROR(decimal) + 2:17 ERROR(pointer) + 2:25 ERROR(3) + 2:26 ERROR(.) + 2:27 ERROR(1) + 2:28 ERROR(4) + 2:29 ERROR(1) + 2:30 ERROR(.) + 2:31 ERROR(5) + 2:32 ERROR(9) + 3:0 newline() + 3:0 string("Check for decimal..) Check for decimal .. + 3:27 ERROR(3) + 3:28 ERROR(,) + 3:29 ERROR(1) + 3:30 ERROR(4) + 3:31 ERROR(1) + 3:32 ERROR(5) + 3:33 ERROR(9) + 3:35 ERROR(=) + 3:37 ERROR(3) + 3:38 ERROR(,) + 3:39 ERROR(1) + 3:40 ERROR(4) + 3:41 ERROR(1) + 3:42 ERROR(,) + 3:43 ERROR(5) + 3:44 ERROR(9) + 4:0 newline() + 4:0 string("") + 4:2 ERROR("A multi-string mu..) + 5:0 newline() + 5:0 ERROR("""\x0a"or after clos..) + 8:12 ERROR(here) + 10:0 newline() + 10:0 newline() + 10:0 ERROR(/* No embedded /*) + 10:15 bcomment(/* comments */) + 10:30 ERROR(in) + 10:33 ERROR(comments) + 10:42 ERROR(*/) + 11:0 newline() + 11:0 ERROR(/* or content afte..) + 12:26 ERROR(Error) + 14:0 newline() + 14:0 newline() + 14:0 string(" \\\\ \\t \\n specia..) \\ \x09 \x0a special ch.. + 15:0 newline() + 15:0 eof()