@@ -12,7 +12,7 @@ def assert_tokens_equal(actual_tokens, expected_tokens_data):
1212
1313 for i , (token_type , value ) in enumerate (expected_tokens_data ):
1414 assert actual_tokens [i ].type == token_type , f"Token { i } type mismatch: Expected { token_type } , got { actual_tokens [i ].type } ({ actual_tokens [i ].value } )"
15- assert actual_tokens [i ].value == value , f"Token { i } value mismatch: Expected { value } , got { actual_tokens [i ].value } "
15+ assert actual_tokens [i ].value == value , f"Token { i } value mismatch: Expected ' { value } ' , got ' { actual_tokens [i ].value } ' "
1616
1717# --- Test Cases ---
1818
@@ -67,13 +67,13 @@ def test_go_numbers():
6767 assert_tokens_equal (tokens , expected )
6868
6969def test_go_strings ():
70- code = "\" hello\" `raw string\\ nwith newline` \" with \\ \" escape\\ \" \" "
70+ code = "\" hello\" `raw string\n with newline` \" with \\ \" escape\\ \" \" "
7171 lexer = GoLexer (code )
7272 tokens = lexer .tokenize ()
7373 expected = [
7474 (TokenType .STRING , "\" hello\" " ),
7575 (TokenType .STRING , "`raw string\n with newline`" ),
76- (TokenType .STRING , "\" with \\ " escape \\ "\" " ),
76+ (TokenType .STRING , "\" with \\ \ " escape\ \\" \" " ),
7777 ]
7878 assert_tokens_equal (tokens , expected )
7979
@@ -145,7 +145,7 @@ def test_go_mixed_code():
145145 (TokenType .KEYWORD , "func" ), (TokenType .IDENTIFIER , "main" ), (TokenType .DELIMITER , "(" ), (TokenType .DELIMITER , ")" ), (TokenType .DELIMITER , "{" ), (TokenType .NEWLINE , "\\ n" ),
146146 (TokenType .COMMENT , "// Declare and initialize" ), (TokenType .NEWLINE , "\\ n" ),
147147 (TokenType .IDENTIFIER , "message" ), (TokenType .OPERATOR , ":=" ), (TokenType .STRING , "\" Hello, Go!\" " ), (TokenType .NEWLINE , "\\ n" ),
148- (TokenType .IDENTIFIER , "fmt" ), (TokenType .OPERATOR , "." ), (TokenType .IDENTIFIER , "Println" ), (TokenType .DELIMITER , "(" ), (TokenType .IDENTIFIER , "message" ), (TokenType .DELIMITER , ")" ), (TokenType .COMMENT , "// Print message" ), (TokenType .NEWLINE , "\\ n" ),
148+ (TokenType .IDENTIFIER , "fmt" ), (TokenType .DELIMITER , "." ), (TokenType .IDENTIFIER , "Println" ), (TokenType .DELIMITER , "(" ), (TokenType .IDENTIFIER , "message" ), (TokenType .DELIMITER , ")" ), (TokenType .COMMENT , "// Print message" ), (TokenType .NEWLINE , "\\ n" ),
149149 (TokenType .IDENTIFIER , "num" ), (TokenType .OPERATOR , ":=" ), (TokenType .NUMBER , "10" ), (TokenType .OPERATOR , "+" ), (TokenType .NUMBER , "5" ), (TokenType .NEWLINE , "\\ n" ),
150150 (TokenType .KEYWORD , "if" ), (TokenType .IDENTIFIER , "num" ), (TokenType .OPERATOR , ">" ), (TokenType .NUMBER , "10" ), (TokenType .DELIMITER , "{" ), (TokenType .NEWLINE , "\\ n" ),
151151 (TokenType .KEYWORD , "return" ), (TokenType .NEWLINE , "\\ n" ),
@@ -193,6 +193,4 @@ def test_go_unterminated_comment():
193193 # Go lexer returns an ERROR token for unterminated multi-line comments
194194 assert len (tokens ) == 2 # ERROR token + EOF
195195 assert tokens [0 ].type == TokenType .ERROR
196- assert "comentário não fechado" in tokens [0 ].value
197-
198-
196+ assert "unterminated comment" in tokens [0 ].value .lower ()
0 commit comments