Ejemplo n.º 1
0
def test__recursive__basic_1():
    rl = RecursiveLexer()
    pc = PositionedChunk('   ', 0, 1, None)
    res, _ = rl.lex(pc)
    assert isinstance(res, ChunkString)
    assert len(res) == 1
    assert res[0].chunk == '   '
Ejemplo n.º 2
0
def test__recursive__multi_whitespace_a():
    rl = RecursiveLexer()
    pc = PositionedChunk('    SELECT    \n', 0, 1, None)
    res, _ = rl.lex(pc)
    assert isinstance(res, ChunkString)
    assert len(res) == 3
    assert res[0].context == 'whitespace'
    assert res[1].chunk == 'SELECT'
Ejemplo n.º 3
0
def test__recursive__comment_a():
    # This test requires recursion
    rl = RecursiveLexer()
    # The whitespace on the end of a comment should be it's own chunk
    pc = PositionedChunk('SELECT    -- Testing Comment\n', 0, 1, None)
    res, _ = rl.lex(pc)
    assert res.context_list() == [
        'content', 'whitespace', 'comment', 'whitespace'
    ]
    assert res[3].chunk == '\n'
Ejemplo n.º 4
0
def test__recursive__multi_whitespace_b():
    # This test requires recursion
    rl = RecursiveLexer()
    pc = PositionedChunk('    SELECT   foo    \n', 0, 1, None)
    res, _ = rl.lex(pc)
    assert isinstance(res, ChunkString)
    assert len(res) == 5
    assert res[0].context == 'whitespace'
    assert res[1].chunk == 'SELECT'
    assert res[3].chunk == 'foo'
    assert res[3].start_pos == 13