From cf04dfd6007fbe972ad613a502c540fdea816da7 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Wed, 10 Aug 2022 12:58:47 -0400 Subject: [PATCH] Lexer unit test now works properly --- lexer/lexer_test.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go index 492ebfd..0ea97af 100644 --- a/lexer/lexer_test.go +++ b/lexer/lexer_test.go @@ -5,16 +5,18 @@ import "github.com/sashakoshka/arf/file" import "github.com/sashakoshka/arf/types" func TestTokenizeAll (test *testing.T) { - file, err := file.Open("tests/lexer/all") + file, err := file.Open("../tests/lexer/all") if err != nil { test.Log(err) test.Fail() + return } tokens, err := Tokenize(file) if err == nil { - test.Log("Tokenize() have returned an error") + test.Log("Tokenize() should have returned an error") test.Fail() + return } correct := []Token { @@ -57,13 +59,18 @@ func TestTokenizeAll (test *testing.T) { } if len(tokens) != len(correct) { - test.Log("lexed", tokens, "tokens, want", correct) + test.Log("lexed", len(tokens), "tokens, want", len(correct)) + test.Fail() + return } + test.Log("token slice length match", len(tokens), "=", len(correct)) for index, token := range tokens { if !token.Equals(correct[index]) { test.Log("token", index, "not equal") test.Fail() + return } } + test.Log("token slice content match") }