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
43
44
45
46
47
48
49
50
51
|
describe "attrib", ->
it "should support const attribute", ->
do
const x = 10
assert.same x, 10
it "should support const with multiple variables", ->
do
const a, b, c = 1, 2, 3
assert.same a, 1
assert.same b, 2
assert.same c, 3
it "should support close attribute", ->
-- close attribute for to-be-closed variables
do
close x = <close>: ->
assert.same "table", type x
it "should work with destructuring", ->
do
const :a, :b = {a: 1, b: 2}
assert.same a, 1
assert.same b, 2
it "should work in conditional", ->
do
flag = true
const x = 5 if flag
assert.same x, 5
it "should work with switch", ->
do
const y = switch 2
when 2 then 100
else 0
assert.same y, 100
it "should work with table literals", ->
do
const [a, b] = [1, 2]
assert.same a, 1
assert.same b, 2
it "should support close in expressions", ->
do
close result = if true
value: 42, <close>: ->
else
value: 0, <close>: ->
assert.same result.value, 42
|