From 85996b25542b9c640d3be4dd76ecb59512223054 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 18 Aug 2022 01:47:35 -0400 Subject: [PATCH] Added more error test cases --- lexer/lexer_test.go | 21 +++++++++++++++++-- tests/lexer/error/excessDataRune.arf | 2 ++ tests/lexer/error/unexpectedSymbol.arf | 2 ++ .../{error.arf => error/unknownEscape.arf} | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/lexer/error/excessDataRune.arf create mode 100644 tests/lexer/error/unexpectedSymbol.arf rename tests/lexer/{error.arf => error/unknownEscape.arf} (50%) diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index d67e691..08b6942 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -68,6 +68,9 @@ func compareErr ( _, err = Tokenize(file) check := err.(infoerr.Error) + test.Log("error that was recieved:") + test.Log(check) + if check.Kind() != correctKind { test.Log("mismatched error kind") test.Log("- want:", correctKind) @@ -222,9 +225,23 @@ func TestTokenizeIndent (test *testing.T) { func TestTokenizeErr (test *testing.T) { compareErr ( - "../tests/lexer/error.arf", + "../tests/lexer/error/unexpectedSymbol.arf", infoerr.ErrorKindError, "unexpected symbol character ;", - 1, 0, 1, + 1, 5, 1, + test) + + compareErr ( + "../tests/lexer/error/excessDataRune.arf", + infoerr.ErrorKindError, + "excess data in rune literal", + 1, 8, 1, + test) + + compareErr ( + "../tests/lexer/error/unknownEscape.arf", + infoerr.ErrorKindError, + "unknown escape character g", + 1, 2, 1, test) } diff --git a/tests/lexer/error/excessDataRune.arf b/tests/lexer/error/excessDataRune.arf new file mode 100644 index 0000000..a0174af --- /dev/null +++ b/tests/lexer/error/excessDataRune.arf @@ -0,0 +1,2 @@ +:arf +'aaaaaaa' diff --git a/tests/lexer/error/unexpectedSymbol.arf b/tests/lexer/error/unexpectedSymbol.arf new file mode 100644 index 0000000..2de6f2a --- /dev/null +++ b/tests/lexer/error/unexpectedSymbol.arf @@ -0,0 +1,2 @@ +:arf +hello; diff --git a/tests/lexer/error.arf b/tests/lexer/error/unknownEscape.arf similarity index 50% rename from tests/lexer/error.arf rename to tests/lexer/error/unknownEscape.arf index 9957cde..cff9a06 100644 --- a/tests/lexer/error.arf +++ b/tests/lexer/error/unknownEscape.arf @@ -1,2 +1,2 @@ :arf -; +"\g"