diff options
Diffstat (limited to 'tests/test_regexlexer.py')
-rw-r--r-- | tests/test_regexlexer.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/test_regexlexer.py b/tests/test_regexlexer.py index d919a950..778f3d03 100644 --- a/tests/test_regexlexer.py +++ b/tests/test_regexlexer.py @@ -11,7 +11,6 @@ import unittest from pygments.token import Text from pygments.lexer import RegexLexer -from pygments.lexer import bygroups from pygments.lexer import default @@ -21,6 +20,8 @@ class TestLexer(RegexLexer): 'root': [ ('a', Text.Root, 'rag'), ('e', Text.Root), + ('#', Text.Root, '#pop'), + ('@', Text.Root, ('#pop', '#pop')), default(('beer', 'beer')) ], 'beer': [ @@ -37,18 +38,29 @@ class TupleTransTest(unittest.TestCase): def test(self): lx = TestLexer() toks = list(lx.get_tokens_unprocessed('abcde')) - self.assertEqual(toks, - [(0, Text.Root, 'a'), (1, Text.Rag, 'b'), (2, Text.Rag, 'c'), + self.assertEqual(toks, [ + (0, Text.Root, 'a'), (1, Text.Rag, 'b'), (2, Text.Rag, 'c'), (3, Text.Beer, 'd'), (4, Text.Root, 'e')]) def test_multiline(self): lx = TestLexer() toks = list(lx.get_tokens_unprocessed('a\ne')) - self.assertEqual(toks, - [(0, Text.Root, 'a'), (1, Text, u'\n'), - (2, Text.Root, 'e')]) + self.assertEqual(toks, [ + (0, Text.Root, 'a'), (1, Text, u'\n'), (2, Text.Root, 'e')]) def test_default(self): lx = TestLexer() toks = list(lx.get_tokens_unprocessed('d')) self.assertEqual(toks, [(0, Text.Beer, 'd')]) + + +class PopEmptyTest(unittest.TestCase): + def test_regular(self): + lx = TestLexer() + toks = list(lx.get_tokens_unprocessed('#e')) + self.assertEqual(toks, [(0, Text.Root, '#'), (1, Text.Root, 'e')]) + + def test_tuple(self): + lx = TestLexer() + toks = list(lx.get_tokens_unprocessed('@e')) + self.assertEqual(toks, [(0, Text.Root, '@'), (1, Text.Root, 'e')]) |