Sha256: 3a1a8c2e74468b0e5081814c0523f8cc2c9968b955e1d687dead1f9cc9075510

Contents?: true

Size: 1.23 KB

Versions: 13

Compression:

Stored size: 1.23 KB

Contents

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

    :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
    :license: BSD, see LICENSE for details.
"""

import unittest

from pygments.token import Text
from pygments.lexer import RegexLexer
from pygments.lexer import bygroups


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.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')])

Version data entries

13 entries across 13 versions & 4 rubygems

Version Path
mortar-pygments.rb-0.5.7 vendor/pygments-main/tests/test_regexlexer.py
mortar-pygments.rb-0.5.6 vendor/pygments-main/tests/test_regexlexer.py
mortar-pygments.rb-0.5.5 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-jruby-0.5.4.2 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-jruby-0.5.4.1 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-jruby-0.5.4 vendor/pygments-main/tests/test_regexlexer.py
gitlab-pygments.rb-0.5.4 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.5.4 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.5.2 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.5.1 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.5.0 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.4.2 vendor/pygments-main/tests/test_regexlexer.py
pygments.rb-0.4.1 vendor/pygments-main/tests/test_regexlexer.py