def test_car(): '(car (t f t f f))' assert L(S('car'), L(S('quote'), L(S('t'), S('f')))).eval(env) == S('t') with pytest.raises(TypeError): L(S('car'), L(S('t'), S('f'))).eval(env)
def test_atom(): assert L(S('atom'), S('t')).eval(env) == T assert L(S('atom'), S('f')).eval(env) == T assert L(S('atom'), S('nil')).eval(env) == T assert L(S('atom'), L(S('quote'), L(S('t')))).eval(env) == F assert L(S('atom'), L(S('quote'), L(S('atom')))).eval(env) == F
def test_eval_quoted_list(): l = L(S('quote'), L(T, F, NIL)).eval(env) assert type(l) is L assert str(l) == '(t () NIL)'
def test_eval_symbol(): t = S('t').eval(env) assert t != None assert str(t) == 't'
def test_parser_14(): assert parse(""" (+ 1 2) """) == (L(S('+'), I(1), I(2)))
def test_parser_13(): assert parse(""" (cons "1" '("2" "3")) """) == (L(S('cons'), Str('1'), L(S('quote'), L(Str('2'), Str('3')))))
def test_parser_1(): assert parse('(atom ())') == L(S('atom'), L())
def test_cons(): assert ( L(S('cons'), S('t'), L(S('quote'), L(S('t'), S('f')))).eval(env) ) == ( L(S('t'), S('t'), S('f')) )
def test_parser_10(): assert parse("((()) (() () ((cons () '(() ())))) ())") == (L( L(L()), L(L(), L(), L(L(S('cons'), L(), L(S('quote'), L(F, F))))), L()))
def test_parser_9(): assert parse("(cons t '((atom ()) (atom t)))") == (L( S('cons'), T, L(S('quote'), L(L(S('atom'), L()), L(S('atom'), T)))))
def test_parser_8(): assert parse("(cons t '(t t))") == (L(S('cons'), T, L(S('quote'), L(T, T))))
def test_parser_6(): assert parse('t') == S('t')
def test_parser_3(): assert parse('(quote () ((1 2)) (atom (t (t f))))') == (L( S('quote'), L(), L(L(I(1), I(2))), L(S('atom'), L(S('t'), L(S('t'), S('f'))))))
def test_parser_2(): assert parse('(atom (quote (t f t)))') == (L( S('atom'), L(S('quote'), L(S('t'), S('f'), S('t')))))
def test_eq(): assert L(S('eq'), S('t'), S('t')).eval(env) == T assert L(S('eq'), S('t'), S('f')).eval(env) == F assert L(S('eq'), S('t'), L(S('quote'), S('f'))).eval(env) == F
def test_parser_11(): assert parse("'(t '(t '(() () ()) t))") == (L( S('quote'), L(T, L(S('quote'), L(T, L(S('quote'), L(F, F, F)), T)))))
def test_parser_13(): assert parse(""" (cond (f "false") ((atom t) "true")) """) == (L(S('cond'), L(S('f'), Str("false")), L(L(S('atom'), T), Str('true'))))
def test_label_correctly_assigns_value_to_name(env, name): value = List(S('label'), S(name), List(S('quote'), List(S('t'), S('f')))).eval(env) assert value == env.get(name)
def test_parser_0(): assert parse('(atom t)') == L(S('atom'), S('t'))