From 3e6b4957d1b50948b419a9290cb04b022777b0b3 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 15 Nov 2017 00:48:19 -0500 Subject: Renamed `defmacro` to `define-macro`, we're not heathens. Started a language manual outline. Removed stray primer. --- tests/test_expander.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/test_expander.py (limited to 'tests') diff --git a/tests/test_expander.py b/tests/test_expander.py new file mode 100644 index 0000000..3e32d2c --- /dev/null +++ b/tests/test_expander.py @@ -0,0 +1,36 @@ +import actinide + +def test_known_expansion(): + s = actinide.Session() + s.run(''' + (begin + (define-macro (let-one binding body) + (begin + (define name (head binding)) + (define val (head (tail binding))) + `((lambda (,name) ,body) ,val)))) + ''') + program = s.read('(let-one (x 1) x)') + assert s.symbol('x') not in s.environment + assert (1,) == s.eval(program) + +def test_quasiquote_expansion(): + s = actinide.Session() + + program = s.read('`(a ,b c)`') + expansion = s.expand(program) + assert s.read("(cons 'a (cons b (cons 'c ())))") == expansion + +def test_nested_qq_expansion(): + s = actinide.Session() + + program = s.read('`((,a))`') + expansion = s.expand(program) + assert s.read("(cons (cons a ()) ())") == expansion + +def test_shorter_qq_expansion(): + s = actinide.Session() + + program = s.read('`(,a b)`') + expansion = s.expand(program) + assert s.read("(cons a (cons 'b ()))") == expansion -- cgit v1.2.3