comparison tests/test_algpseudo.py @ 276:397ed930a5ba

Allow more separator characters for explicit token types. Extensive tests including a special test when using the backslash.
author Franz Glasner <fzglas.hg@dom66.de>
date Wed, 20 May 2026 12:10:01 +0200
parents f365d9d2c0ad
children ee512932d603
comparison
equal deleted inserted replaced
275:f365d9d2c0ad 276:397ed930a5ba
698 pygments.lex( 698 pygments.lex(
699 r"""\ttx-nd[a_Decorator](p1, p2) \rem (Python) annotation""", 699 r"""\ttx-nd[a_Decorator](p1, p2) \rem (Python) annotation""",
700 self.lexer)) 700 self.lexer))
701 701
702 def test_explicit_tokentype_all_seps(self): 702 def test_explicit_tokentype_all_seps(self):
703 for sep in r"/:|=*+!\$~": 703 for sep in r"""/?.,:;%|=*+!$"'~_-#@""":
704 self.assertTokenStreamEqualComplete( 704 self.assertTokenStreamEqualComplete(
705 [("Name.Decorator", "word"), 705 [("Name.Decorator", "word"),
706 ("Text", sep),
706 ("Text.Whitespace", "\n"), 707 ("Text.Whitespace", "\n"),
707 ], 708 ],
708 pygments.lex( 709 pygments.lex(
709 r"\ttx-nd%sword%s" % (sep, sep,), 710 r"\text{\ttx-nd%sword%s%s}" % (sep, sep, sep),
710 self.lexer)) 711 self.lexer))
712
713 def test_explicit_tokentype_backslash(self):
714 self.assertTokenStreamEqualComplete(
715 [("Name.Decorator", "word"),
716 ("Text", "\\"),
717 ("Text", " "),
718 ("Text.Whitespace", "\n"),
719 ],
720 pygments.lex(r"\text{\ttx-nd\word\\ }", self.lexer))
711 721
712 def test_explicit_tokentype_error(self): 722 def test_explicit_tokentype_error(self):
713 self.assertTokenStreamEqualComplete( 723 self.assertTokenStreamEqualComplete(
714 [("Generic.Error", r"""\ttx-non-existing[a_Decorator]"""), 724 [("Generic.Error", r"""\ttx-non-existing[a_Decorator]"""),
715 ("Text.Whitespace", "\n"), 725 ("Text.Whitespace", "\n"),