Evaluate numbers and Booleans:
lisp_eval("1").should == 1
lisp_eval("#t").should == true
Evaluate simple addition and multiplication function calls:
lisp_eval("(+ 1 2)").should == 3
lisp_eval("(* 2 2 3)").should == 12
Evaluate nested addition and multiplication calls
lisp_eval("(+ 1 (* 2 3))").should == 7
Evaluate conditionals:
lisp_eval("(if #t 1 2)").should == 1
lisp_eval("(if #f #t #f)").should == false
Evaluate top-level definitions:
lisp_eval("(def x 3)
(+ x 1)").should == 4
Evaluate simple let
bindings:
lisp_eval("(let (x 3)
x)").should == 3
Evaluate more sophisticated let
bindings:
lisp_eval("(let (x 3)
(+ x 1))").should == 4
Evaluate let
bindings with multiple variables:
lisp_eval("(let (x 3
y 4)
(+ x y))").should == 7
Evaluate function definitions:
code = "(defn add2 (x)
(+ x 2))
(add2 9)"
lisp_eval(code).should == 1
Evaluates function definitions with multiple variables:
code = "(defn maybeAdd2 (bool x)
(if bool
(+ x 2)
x))
(+ (maybeAdd2 1 #t) (maybeAdd2 1 #f))"
lisp_eval(code).should == 4