summaryrefslogtreecommitdiff
path: root/tests/test_regexlexer.py
diff options
context:
space:
mode:
authorgbrandl <devnull@localhost>2007-09-28 19:03:07 +0200
committergbrandl <devnull@localhost>2007-09-28 19:03:07 +0200
commit2f8728aaa5d2562880487295fc6e11411df5ef04 (patch)
tree4a12061c2343af65f661804f60c7223970464147 /tests/test_regexlexer.py
parent3d2eae0ea357ed504ee5a88a53c468e40d0f5539 (diff)
downloadpygments-2f8728aaa5d2562880487295fc6e11411df5ef04.tar.gz
Add a new test for the latest RegexLexer change, multiple new states
including '#pop'.
Diffstat (limited to 'tests/test_regexlexer.py')
-rw-r--r--tests/test_regexlexer.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_regexlexer.py b/tests/test_regexlexer.py
new file mode 100644
index 00000000..de19934d
--- /dev/null
+++ b/tests/test_regexlexer.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+"""
+ Pygments regex lexer tests
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ :copyright: 2007 by Georg Brandl.
+ :license: BSD, see LICENSE for more details.
+"""
+
+import unittest
+
+from pygments.token import Text
+from pygments.lexer import RegexLexer
+
+class TestLexer(RegexLexer):
+ """Test tuple state transitions including #pop."""
+ tokens = {
+ 'root': [
+ ('a', Text.Root, 'rag'),
+ ('e', Text.Root),
+ ],
+ 'beer': [
+ ('d', Text.Beer, ('#pop', '#pop')),
+ ],
+ 'rag': [
+ ('b', Text.Rag, '#push'),
+ ('c', Text.Rag, ('#pop', 'beer')),
+ ],
+ }
+
+class TupleTransTest(unittest.TestCase):
+ def test(self):
+ lx = TestLexer()
+ toks = list(lx.get_tokens_unprocessed('abcde'))
+ self.assertEquals(toks,
+ [(0, Text.Root, 'a'), (1, Text.Rag, 'b'), (2, Text.Rag, 'c'),
+ (3, Text.Beer, 'd'), (4, Text.Root, 'e')])