Example #1
0
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
Example #2
0
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
Example #3
0
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')
Example #4
0
def eval(str):
    form = pysch.read(str)
    return pysch.eval(form, env)
Example #5
0
def test_signed_ints():
  assert read('+20')  == 20
  assert read('-500') == -500
Example #6
0
def test_quasiquote():
  cons = read("`(foo)")
  assert cons.car == get_symbol('quasiquote')
  assert cons.caadr == get_symbol('foo')
Example #7
0
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
Example #8
0
def test_quote_symbol():
  cons = read("'a")
  assert cons.car == get_symbol('quote')
  assert cons.cadr == get_symbol('a')
  assert cons.cddr == nil
Example #9
0
def test_string_literal():
  val = read('"a string literal"')
  assert val == 'a string literal', val
Example #10
0
def test_ints():
  assert read('10') == 10
  assert read('1000000000') == 1000000000
Example #11
0
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
Example #12
0
def test_nil():
  assert read('()') == nil
Example #13
0
def eval(str):
  return pysch.eval(pysch.read(str), env)