Skip to content

Commit 1b7f7dd

Browse files
committed
destructure spec
1 parent fb270ad commit 1b7f7dd

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spec/destructure_spec.moon

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
describe "destructure", ->
2+
it "should unpack array", ->
3+
input = {1,2,3}
4+
5+
{a,b,c} = {1,2,3}
6+
{d,e,f} = input
7+
8+
assert.same a, 1
9+
assert.same b, 2
10+
assert.same c, 3
11+
12+
assert.same d, 1
13+
assert.same e, 2
14+
assert.same f, 3
15+
16+
it "should destructure", ->
17+
futurists =
18+
sculptor: "Umberto Boccioni"
19+
painter: "Vladimir Burliuk"
20+
poet:
21+
name: "F.T. Marinetti"
22+
address: {
23+
"Via Roma 42R"
24+
"Bellagio, Italy 22021"
25+
}
26+
27+
{poet: {:name, address: {street, city}}} = futurists
28+
29+
assert.same name, "F.T. Marinetti"
30+
assert.same street, "Via Roma 42R"
31+
assert.same city, "Bellagio, Italy 22021"
32+

0 commit comments

Comments
 (0)