コード例 #1
0
def test_string():
    string_exp = '"Here\'s a semi hairy example"'
    assert list(lex(string_exp)) == [string_exp]

    lambda_string_exp = "(lambda () '({}))".format(string_exp)
    assert list(lex(lambda_string_exp)) == [
        "(", "lambda", "(", ")", "'", "(", string_exp, ")", ")"
    ]
コード例 #2
0
def test_lambda_exp():
    lambda_exp = "(lambda () nil)"
    assert list(lex(lambda_exp)) == ["(", "lambda", "(", ")", "nil", ")"]
コード例 #3
0
def test_single_digits():
    digits_exp = "(define () 5)"
    assert list(lex(digits_exp)) == ["(", "define", "(", ")", "5", ")"]
コード例 #4
0
def test_empty_exp():
    empty = ""
    assert list(lex(empty)) == []
コード例 #5
0
def test_quoted_list():
    quoted_exp = "'()"
    assert list(lex(quoted_exp)) == ["'", "(", ")"]

    quasi_quoted_exp = "`()"
    assert list(lex(quasi_quoted_exp)) == ["`", "(", ")"]