diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2017-11-15 00:48:19 -0500 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2017-11-15 00:48:19 -0500 |
| commit | 3e6b4957d1b50948b419a9290cb04b022777b0b3 (patch) | |
| tree | 2fd87bc4e2a7be18e83101dd257fd7318d66f81d /tests | |
| parent | 6ab0fb837e5b1cc40002037e2ed15505f99cbbe3 (diff) | |
Renamed `defmacro` to `define-macro`, we're not heathens.
Started a language manual outline.
Removed stray primer.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_expander.py | 36 |
1 files changed, 36 insertions, 0 deletions
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 |
