From ba777227310b9a690dae52fce75b89588f6d7847 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Jun 2019 09:54:39 +1000 Subject: [PATCH] scanner: test for errors with multi-line objects crossing node. multi-line strings and comments musn't cross nodes. Testing this increases coverage above 94% Signed-off-by: NeilBrown --- csrc/scanner-tests.mdc | 58 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/csrc/scanner-tests.mdc b/csrc/scanner-tests.mdc index 7858e1d..6a81989 100644 --- a/csrc/scanner-tests.mdc +++ b/csrc/scanner-tests.mdc @@ -38,7 +38,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.92) exit(1) }' \ + if (ran < (ran + skip) *0.94) exit(1) }' \ coverage/scanner.mdc.gcov @rm -f .tmp* @@ -742,7 +742,7 @@ to one. done ###### test list - scanner_section_tests += section1 + scanner_section_tests += section1 section_string section_comment ###### test: section1 @@ -778,6 +778,60 @@ to one. 4:0 newline() 4:0 eof() +###### test: section_string + a = ''' + A sting mustn't cross + ## string B + skip + +###### string B + to a new node + ''' + +###### output: section_string + Tokenizing: test: section_string + 1:8 ident(a) + 1:10 mark(=) + 1:12 ERROR('''\x0a\x09 A sting mus..) + 7:8 in() + 7:8 ident(to) + 7:11 ident(a) + 7:13 ident(new) + 7:17 ident(node) + 8:8 newline() + 8:8 ERROR(''') + 4:8 newline() + 4:8 out() + 4:8 newline() + 4:8 ident(skip) + 5:0 newline() + 5:0 eof() + +###### test: section_comment + /* Mult-line comment must stay within + ## comment B + */ + +###### comment B + a single node, they cannot cross nodes. + +###### output: section_comment + Tokenizing: test: section_comment + 1:8 ERROR(/* Mult-line comme..) + 6:8 ident(a) + 6:10 ident(single) + 6:17 ident(node) + 6:21 mark(,) + 6:23 ident(they) + 6:28 ident(cannot) + 6:35 ident(cross) + 6:41 ident(nodes) + 6:46 mark(.) + 3:8 newline() + 3:8 mark(*/) + 4:0 newline() + 4:0 eof() + ## Ad-hoc test These tests test bugs that were found in practice, and so prevent them recuring. -- 2.43.0