From d2aaffc083bb1aa54301d0e908be0a0e412af8c9 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Wed, 28 Jul 2021 23:00:33 +0900 Subject: Add a token position and detailed info to a lexical error message --- spec/lexer_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'spec/lexer_test.go') diff --git a/spec/lexer_test.go b/spec/lexer_test.go index 569f278..e016def 100644 --- a/spec/lexer_test.go +++ b/spec/lexer_test.go @@ -24,6 +24,10 @@ func TestLexer_Run(t *testing.T) { return newPositionToken(num, newPosition(1)) } + invalidTok := func(text string) *token { + return newInvalidToken(text, newPosition(1)) + } + tests := []struct { caption string src string @@ -131,7 +135,7 @@ bar // This is the fourth comment. src: `abc!!!def`, tokens: []*token{ idTok("abc"), - newInvalidToken("!!!"), + invalidTok("!!!"), idTok("def"), newEOFToken(), }, -- cgit v1.2.3