From c55240fb05151cae046c75a793c164d72c988db2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 6 Jan 2017 18:46:58 +0300 Subject: Tests cleanup (take 2) --- unit-tests/lexer/comment.test | 221 ++++++++++++++++++++++++------------------ unit-tests/lexer/quoting.test | 145 ++++++++++++++------------- 2 files changed, 203 insertions(+), 163 deletions(-) (limited to 'unit-tests/lexer') diff --git a/unit-tests/lexer/comment.test b/unit-tests/lexer/comment.test index 025b0a2..6840219 100644 --- a/unit-tests/lexer/comment.test +++ b/unit-tests/lexer/comment.test @@ -2,111 +2,138 @@ # copyright : Copyright (c) 2014-2017 Code Synthesis Ltd # license : MIT; see accompanying LICENSE file -# Single-line comments. +: single-line +: +{ + : only + : + $* <>:EOO + # comment + EOI + EOO -$* <>:EOO # single-only -# comment -EOI -EOO + : first + : + $* <>EOO + # comment + foo + EOI + 'foo' + + EOO -$* <>EOO # single-first -# comment -foo -EOI -'foo' - -EOO + : last + : + $* <>EOO + foo + # comment + EOI + 'foo' + + EOO -$* <>EOO # single-last -foo -# comment -EOI -'foo' - -EOO + : few + : + $* <>EOO + foo + # comment + # comment + EOI + 'foo' + + EOO -$* <>EOO # single-few -foo -# comment -# comment -EOI -'foo' - -EOO + : cont + : + $* <>EOO + foo + # comment\\ + bar + EOI + 'foo' + + 'bar' + + EOO -$* <>EOO # single-cont -foo -# comment\\ -bar -EOI -'foo' - -'bar' - -EOO + : same + : + $* <>EOO + foo # comment + bar # comment + EOI + 'foo' + + 'bar' + + EOO +} -$* <>EOO # single-same -foo # comment -bar # comment -EOI -'foo' - -'bar' - -EOO +: multi-line +: +{ + : only + : + $* <>:EOO + #\ + comment + comment + #\ + EOI + EOO -# Multi-line comments. -# + : empty + : + $* <>:EOO + #\ + #\ + EOI + EOO -$* <>:EOO # multi-only -#\ -comment -comment -#\ -EOI -EOO + : start-same + : + $* <>EOO + foo #\ + comment + comment + #\ + EOI + 'foo' + + EOO -$* <>:EOO # multi-empty -#\ -#\ -EOI -EOO + : end-same + : + $* <>EOO + #\ + comment + comment + foo #\ + bar + EOI + 'bar' + + EOO -$* <>EOO # multi-start-same -foo #\ -comment -comment -#\ -EOI -'foo' - -EOO + : end-not + : + $* <>EOO + #\ + comment + #\ not an end + foo #\ + bar + EOI + 'bar' + + EOO -$* <>EOO # multi-end-same -#\ -comment -comment -foo #\ -bar -EOI -'bar' - -EOO - -$* <>EOO # multi-end-not -#\ -comment -#\ not an end -foo #\ -bar -EOI -'bar' - -EOO - -$* <>EOE != 0 # multi-unterm -#\ -comment -EOI -stdin:3:1: error: unterminated multi-line comment -EOE + : unterm + : + $* <>EOE != 0 + #\ + comment + EOI + stdin:3:1: error: unterminated multi-line comment + EOE +} diff --git a/unit-tests/lexer/quoting.test b/unit-tests/lexer/quoting.test index 84818fc..a44d6af 100644 --- a/unit-tests/lexer/quoting.test +++ b/unit-tests/lexer/quoting.test @@ -11,81 +11,94 @@ $* <'foo' >>EOO EOO -: single-comp +: comp : -$* <":'foo':" >>EOO -: -'foo' [S/C] -: - -EOO +{ + : single + : + $* <":'foo':" >>EOO + : + 'foo' [S/C] + : + + EOO -: double-comp -: -$* <':"foo":' >>EOO -: -'foo' [D/C] -: - -EOO + : double + : + $* <':"foo":' >>EOO + : + 'foo' [D/C] + : + + EOO -: single-empty-comp -: -$* <"''" >>EOO -'' [S/C] - -EOO + : single-empty + : + $* <"''" >>EOO + '' [S/C] + + EOO -: double-empty-comp -: -$* <'""' >>EOO -'' [D/C] - -EOO + : double-empty + : + $* <'""' >>EOO + '' [D/C] + + EOO +} -: part-start-quoted -: Token start already quoted -: -$* <'"$foo"' >>EOO -'' [D/P] -$ [D/C] -'foo' [D/P] - -EOO +: part +{ + : quoted + { + : start + : Token start already quoted + : + $* <'"$foo"' >>EOO + '' [D/P] + $ [D/C] + 'foo' [D/P] + + EOO -: part-end-quoted -: Token end still quoted -: -$* <'"foo$"' >>EOO -'foo' [D/P] -$ [D/C] -'' [D/P] - -EOO + : end + : Token end still quoted + : + $* <'"foo$"' >>EOO + 'foo' [D/P] + $ [D/C] + '' [D/P] + + EOO + } -: part-start-unquoted -: Token starts with unquoted character -: -$* <'f"oo"' >>EOO -'foo' [D/P] - -EOO + : unquoted + { + : start + : Token starts with unquoted character + : + $* <'f"oo"' >>EOO + 'foo' [D/P] + + EOO -: part-unquoted -: Token continous with unquoted character -: -$* <'"fo"o' >>EOO -'foo' [D/P] - -EOO + : end + : Token continous with unquoted character + : + $* <'"fo"o' >>EOO + 'foo' [D/P] + + EOO -: part-unquoted-escape -: Token continous with unquoted escaped character -: -$* <'"fo"\"' >>EOO -'fo"' [D/P] - -EOO + : escape + : Token continous with unquoted escaped character + : + $* <'"fo"\"' >>EOO + 'fo"' [D/P] + + EOO + } +} : mixed : -- cgit v1.1