aboutsummaryrefslogtreecommitdiff
path: root/spec/inputs/destructure.yue
diff options
context:
space:
mode:
Diffstat (limited to 'spec/inputs/destructure.yue')
-rw-r--r--spec/inputs/destructure.yue117
1 files changed, 117 insertions, 0 deletions
diff --git a/spec/inputs/destructure.yue b/spec/inputs/destructure.yue
new file mode 100644
index 0000000..49e6393
--- /dev/null
+++ b/spec/inputs/destructure.yue
@@ -0,0 +1,117 @@
1
2do
3 {a, b} = hello
4
5 {{a}, b, {c}} = hello
6
7 { :hello, :world } = value
8
9do
10 { yes: no, thing } = world
11
12 {:a,:b,:c,:d} = yeah
13
14 {a} = one, two
15 {b}, c = one
16 {d}, e = one, two
17
18 x, {y} = one, two
19
20 xx, yy = 1, 2
21 {yy, xx} = {xx, yy}
22
23 {a, :b, c, :d, e, :f, g} = tbl
24
25---
26
27do
28 futurists =
29 sculptor: "Umberto Boccioni"
30 painter: "Vladimir Burliuk"
31 poet:
32 name: "F.T. Marinetti"
33 address: {
34 "Via Roma 42R"
35 "Bellagio, Italy 22021"
36 }
37
38 {poet: {:name, address: {street, city}}} = futurists
39
40--
41
42do
43 { @world } = x
44 { a.b, c.y, func!.z } = x
45
46 { world: @world } = x
47
48--
49
50do
51 thing = {{1,2}, {3,4}}
52
53 for {x,y} in *thing
54 print x,y
55
56
57--
58
59do
60 with {a,b} = thing
61 print a, b
62
63
64--
65
66do
67 thing = nil
68 if {a} = thing
69 print a
70 else
71 print "nothing"
72
73 thang = {1,2}
74 if {a,b} = thang
75 print a,b
76
77 if {a,b} = thing
78 print a,b
79 elseif {c,d} = thang
80 print c,d
81 else
82 print "NO"
83
84--
85
86do
87 z = "yeah"
88 {a,b,c} = z
89
90do
91 {a,b,c} = z
92
93_ = (z) ->
94 {a,b,c} = z
95
96do
97 z = "oo"
98 _ = (k) ->
99 {a,b,c} = z
100
101do
102 {function:{end:endVar}} = thing
103
104do
105 {if:{a,b,c}} = thing
106
107do
108 {:a, :b} = {a: "Hello", b: "World"} if true
109
110 {days, hours, mins, secs} = [tonumber a for a in *{
111 string.match "1 2 3 4", "(.+)%s(.+)%s(.+)%s(.+)"
112 }]
113
114 {:one, :two, :three} = {w,true for w in foo\gmatch("%S+")}
115
116 {:a},b = a\if(123) + t, 123
117