|
@@ -4,18 +4,18 @@ const helpers = require('./helpers')
|
4
|
4
|
const AST = require('../src/ast')
|
5
|
5
|
const Evaluator = require('../src/evaluator')
|
6
|
6
|
|
7
|
|
-test('looks up and injects the function to which a symbol refers', t => {
|
8
|
|
- t.plan(2)
|
|
7
|
+test('applies functions from core library', t => {
|
|
8
|
+ t.plan(1)
|
9
|
9
|
|
10
|
10
|
const tree = helpers.evaluate('(+ 1 2)')
|
11
|
11
|
|
12
|
|
- t.deepEqual(tree[0].function.constructor, Function)
|
13
|
|
- t.deepEqual(
|
14
|
|
- tree[0].function.call(
|
15
|
|
- this,
|
16
|
|
- new AST.Number({ value: 4 }),
|
17
|
|
- new AST.Number({ value: 5 })
|
18
|
|
- ),
|
19
|
|
- new AST.Number({ value: 9 })
|
20
|
|
- )
|
|
12
|
+ t.deepEqual(tree[0], new AST.Number({ value: 3 }))
|
|
13
|
+})
|
|
14
|
+
|
|
15
|
+test('applies lambda functions', t => {
|
|
16
|
+ t.plan(1)
|
|
17
|
+
|
|
18
|
+ const tree = helpers.evaluate('((lambda (x y) (+ x y)) 1 2)')
|
|
19
|
+
|
|
20
|
+ t.deepEqual(tree[0], new AST.Number({ value: 3 }))
|
21
|
21
|
})
|