-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscope.spec.js
42 lines (32 loc) · 1.3 KB
/
scope.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var newScope = require("../lib/scope").newScope;
describe('LispScript', function() {
describe('scope', function() {
it('set and get value', function() {
var scope1 = newScope(undefined, {a: 1}), provider = {b: 2}, scope2 = newScope(scope1, provider);
expect(scope2.has('a')).toBe(true);
expect(scope2.localHas('a')).toBe(false);
expect(scope2.get('a')).toBe(1);
scope2.set('a', 2);
expect(scope2.get('a')).toBe(2);
expect(scope1.get('a')).toBe(2);
expect(scope2.get('b')).toBe(2);
expect(scope1.get('b')).toBe(undefined);
scope2.set('b', 3);
expect(scope2.get('b')).toBe(3);
expect(scope1.get('b')).toBe(undefined);
scope1.set('b', 5);
expect(scope2.get('b')).toBe(3);
expect(scope1.get('b')).toBe(5);
scope2.local('a', 6);
expect(scope2.get('a')).toBe(6);
expect(scope1.get('a')).toBe(2);
scope2.set('a', 8);
expect(scope2.get('a')).toBe(8);
expect(scope1.get('a')).toBe(2);
scope2.remove('a');
scope2.set('a', 9);
expect(scope2.get('a')).toBe(9);
expect(scope1.get('a')).toBe(9);
});
});
});