From eaa97fa8c76ec841b20f1cd9d0ef45bd6d620ec8 Mon Sep 17 00:00:00 2001 From: Luca Morgado Date: Thu, 3 Oct 2024 10:01:49 +0200 Subject: [PATCH] updated function and anonymous function decl tests to reflect the previous changes --- parser/Parser_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/parser/Parser_test.go b/parser/Parser_test.go index 30f5a2a..002b194 100644 --- a/parser/Parser_test.go +++ b/parser/Parser_test.go @@ -1588,6 +1588,13 @@ func TestParser_ParseAnonymousFunctionExpr(t *testing.T) { t.Errorf("ParseAnonymousFunctionExpr() raised an error when it should not") } ok = false + // function declaration with structs as parameters and field access in the body + resetWithTokens(&par, lexer.Lexer("function(a : Test, b : Test)( string) {return a.test + b.test;}")) + par.VarTypes["Test"] = "struct" + par.ParseAnonymousFunctionExpr() + if ok { + t.Errorf("ParseAnonymousFunctionExpr() raised an error when it should not") + } e.RestoreExit() } @@ -1645,6 +1652,13 @@ func TestParser_ParseFunctionDecl(t *testing.T) { t.Errorf("ParseFunctionDecl() did not raise the missing left parenthesis error") } ok = false + // function declaration with structs as parameters and field access in the body + resetWithTokens(&par, lexer.Lexer("function test(a : Test, b : Test)( string) {return a.test + b.test;}")) + par.VarTypes["Test"] = "struct" + par.ParseFunctionDecl() + if ok { + t.Errorf("ParseFunctionDecl() raised an error when it should not") + } e.RestoreExit() }