From e635c33d0d336e7be54336ed2d6e043470f00398 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 19 Sep 2023 11:40:54 +0200 Subject: Fix "string mode". Previously parenthesis were (incorrectly) highlighted even in strings. Now they are correctly ignored inside. --- tests/test_string.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/test_string.py') diff --git a/tests/test_string.py b/tests/test_string.py index 5d3040b..1101d26 100644 --- a/tests/test_string.py +++ b/tests/test_string.py @@ -4,3 +4,19 @@ import io def test_escaped_parenthesis(): assert list(r"\(") == list(colorize(io.StringIO(r"\("))) + + +def test_escaped_parenthesis_in_string(): + assert list(r"'\('") == list(colorize(io.StringIO(r"'\('"))) + + +def test_escaped_quot_in_string(): + assert list(r"'\''") == list(colorize(io.StringIO(r"'\''"))) + + +def test_embedded_string(): + assert list(colorize(io.StringIO("( '(' )"))) == [ + Colored(depth=0, item='('), + *" '(' ", + Colored(depth=0, item=')'), + ] -- cgit v1.2.3