Skip to content

Commit 11a4ef7

Browse files
committed
Fix tests
1 parent c7c9b4c commit 11a4ef7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/lisp.test.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ import {
1515
import { L } from './helper.js'
1616
import { UnboundVariableError } from './errors.js'
1717

18+
const x = Symbol('x')
19+
const y = Symbol('y')
20+
1821
describe('apply', () => {
1922
describe('CAR', () => {
2023
test('returns the head elements when present', () => {
@@ -72,7 +75,8 @@ describe('apply', () => {
7275

7376
describe('function is unknown atom', () => {
7477
test('function value is evaluated from context and then applies to arguments', () => {
75-
assert.strictEqual(lApply('atomAlias', L(NIL), L(['atomAlias', ATOM])), T)
78+
const mySymbol = Symbol('mySymbol')
79+
assert.strictEqual(lApply(mySymbol, L(NIL), L([mySymbol, ATOM])), T)
7680
})
7781
test('function that does not exist in context should throw exception', () => {
7882
assert.throws(() => lApply('unknownSymbol', L(), L()))
@@ -81,23 +85,19 @@ describe('apply', () => {
8185

8286
describe('lambda', () => {
8387
test('returns evaluation result from lambda expression binding argument to parameter symbol', () => {
84-
assert.strictEqual(lApply(L(LAMBDA, L('x'), 'x'), L(12)), 12)
88+
assert.strictEqual(lApply(L(LAMBDA, L(x), x), L(12)), 12)
8589
})
8690

8791
test('multiple parameter bindings and function call expressions are evaluated', () => {
8892
assert.deepStrictEqual(
89-
lApply(L(LAMBDA, L('x', 'y'), L(CONS, 'x', 'y')), L(1, 2)),
93+
lApply(L(LAMBDA, L(x, y), L(CONS, x, y)), L(1, 2)),
9094
[1, 2],
9195
)
9296
})
9397

9498
test('parameter bound variable value should shadow variable value in context', () => {
9599
assert.strictEqual(
96-
lApply(
97-
L(LAMBDA, L('x'), 'x'),
98-
L('localValue'),
99-
L(['x', 'shadowedValue']),
100-
),
100+
lApply(L(LAMBDA, L(x), x), L('localValue'), L([x, 'shadowedValue'])),
101101
'localValue',
102102
)
103103
})
@@ -107,10 +107,10 @@ describe('apply', () => {
107107
describe('eval', () => {
108108
describe('binding', () => {
109109
test('should return bound argument', () => {
110-
assert.strictEqual(lEval('x', L(['x', 1])), 1)
110+
assert.strictEqual(lEval(x, L([x, 1])), 1)
111111
})
112112
test('should throw if symbol not found', () => {
113-
assert.throws(() => lEval('x', L()), UnboundVariableError)
113+
assert.throws(() => lEval(x, L()), UnboundVariableError)
114114
})
115115
})
116116
})

0 commit comments

Comments
 (0)