Sha256: 04f2236adbd8d0116561a929ef4da7a33423e51792e249260d90fd8406f4777f

Contents?: true

Size: 995 Bytes

Versions: 5

Compression:

Stored size: 995 Bytes

Contents

# -*- coding: utf-8 -*-
"""
    Pygments regex lexer tests
    ~~~~~~~~~~~~~~~~~~~~~~~~~~

    :copyright: Copyright 2006-2011 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for 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')])

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pygments.rb-0.2.4 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.2.3 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.2.2 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.2.1 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.2.0 vendor/pygments-main/tests/test_regexlexer.py