コード例 #1
0
ファイル: lexer_test.py プロジェクト: henry-kr/sqlfluff
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 == '   '
コード例 #2
0
ファイル: lexer_test.py プロジェクト: henry-kr/sqlfluff
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'
コード例 #3
0
ファイル: lexer_test.py プロジェクト: henry-kr/sqlfluff
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'
コード例 #4
0
ファイル: lexer_test.py プロジェクト: henry-kr/sqlfluff
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