def test_improper_list(): rep = '(foo bar . baz)' cons = read(rep) assert cons.car == get_symbol('foo') assert cons.cadr == get_symbol('bar') assert cons.cddr == get_symbol('baz') assert str(cons) == rep
def test_plain_list(): rep = '(foo bar baz)' cons = read(rep) assert cons.car == get_symbol('foo') assert cons.cadr == get_symbol('bar') assert cons.caddr == get_symbol('baz') assert cons.cdddr == nil assert str(cons) == rep
def test_nested_lists(): cons = read('((foo) (bar baz) (qux (quux) quuux) thud (splat))') assert cons.caar == get_symbol('foo') assert cons.caadr == get_symbol('bar') assert cons.cadadr == get_symbol('baz') assert cons.caaddr == get_symbol('qux') assert cons.caadaddr == get_symbol('quux') assert cons.caddaddr == get_symbol('quuux') assert cons.cadddr == get_symbol('thud') assert cons.caaddddr == get_symbol('splat')
def test_equality(): x = get_symbol('foo') y = get_symbol('foo') assert x == y
def test_class(): x = get_symbol('foo') assert type(x) == Symbol
def test_inequality(): x = get_symbol('foo') y = get_symbol('bar') assert x != y
def test_value(): x = get_symbol('foo') assert x.string == 'foo'
def test_quasiquote(): cons = read("`(foo)") assert cons.car == get_symbol('quasiquote') assert cons.caadr == get_symbol('foo')
def test_quote_list(): cons = read("'(foo bar)") assert cons.car == get_symbol('quote') assert cons.caadr == get_symbol('foo') assert cons.cadadr == get_symbol('bar') assert cons.cddadr == nil
def test_quote_symbol(): cons = read("'a") assert cons.car == get_symbol('quote') assert cons.cadr == get_symbol('a') assert cons.cddr == nil
def test_pair(): rep = '(foo . bar)' cons = read(rep) assert cons.car == get_symbol('foo') assert cons.cdr == get_symbol('bar') assert str(cons) == rep