Exemple #1
0
def test_is_next_char():
    stream = CharStream('a3')
    assert stream.get(0).value == 'a'
    assert not stream.get(1).value == 'C'
    assert stream.get(1).value == '3'
Exemple #2
0
def test_char_values():
    text = 'i76hj-'
    stream = CharStream(text)
    values = ''.join([stream.get(i).value for i, _ in enumerate(text)])
    assert values == text
Exemple #3
0
def test_empty_text_is_eof():
    stream = CharStream()
    assert stream.get().is_eof()
Exemple #4
0
def test_char_column():
    text = 'ab\nc\n\nd'
    stream = CharStream(text)
    lines = [stream.get(i).column for i, _ in enumerate(text)]
    assert lines == [0, 1, 2, 0, 1, 0, 0]
Exemple #5
0
def test_char_line():
    text = 'ab\nc\n\nd'
    stream = CharStream(text)
    lines = [stream.get(i).line for i, _ in enumerate(text)]
    assert lines == [0, 0, 0, 1, 1, 2, 3]
Exemple #6
0
def test_char_type(test_input, method):
    stream = CharStream(test_input)
    ch = stream.get()
    assert getattr(ch, method)()