From 7581a35be41b7239946247afb22813d6814d1ef3 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Mon, 18 May 2026 13:43:12 +0200 Subject: [PATCH] tests(parser): add syntax error test --- tests/lexer/test_annotation_lexer.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/lexer/test_annotation_lexer.py b/tests/lexer/test_annotation_lexer.py index 2ab91dd..33a83a1 100644 --- a/tests/lexer/test_annotation_lexer.py +++ b/tests/lexer/test_annotation_lexer.py @@ -103,3 +103,27 @@ def test_literals(src: str, expected_type: TokenType, expected_value: Any): assert_n_tokens(tokens, 1) assert tokens[0].type == expected_type assert tokens[0].value == expected_value + + +def test_single_bang_error(): + with pytest.raises(SyntaxError): + scan("!") + + +@pytest.mark.parametrize( + "src", + [ + "-", + "*", + "/", + "{", + "}", + "@", + '"', + "'", + ".", + ], +) +def test_unexpected_character(src: str): + with pytest.raises(SyntaxError): + scan(src)