Exemple #1
0
def test_tokens():
    t = list(core.tokenize(r'(xy 1. "ab\c\"")'))
    assert t == [core.BEGIN, 'xy', 1., 'abc"', core.END]
    assert [type(x) for x in t] == [
        type(core.BEGIN),
        core.Symbol,
        float,
        str,
        type(core.END),
    ]
Exemple #2
0
def test_empty():
    t = list(core.tokenize(''))
    assert t == []  # pylint:disable=use-implicit-booleaness-not-comparison # Lets use x == [..] like in other asserts
Exemple #3
0
def test_invalid_token():
    with pytest.raises(core.LispError) as excinfo:
        list(core.tokenize('A\\'))
    assert str(excinfo.value) == 'Unexpected symbols: "A<HERE>\\"'
Exemple #4
0
def test_comment():
    t = list(core.tokenize('#x\nA'))
    assert t == ['A']