reorganize destructure tests

This commit is contained in:
leaf corcoran 2013-06-06 19:33:08 -07:00
parent 9ac382fc49
commit e1c2829d0e
2 changed files with 204 additions and 164 deletions

View File

@ -1,10 +1,12 @@
do
{a, b} = hello {a, b} = hello
{{a}, b, {c}} = hello {{a}, b, {c}} = hello
{ :hello, :world } = value { :hello, :world } = value
do
{ yes: no, thing } = world { yes: no, thing } = world
{:a,:b,:c,:d} = yeah {:a,:b,:c,:d} = yeah
@ -22,6 +24,7 @@ xx, yy = 1, 2
--- ---
do
futurists = futurists =
sculptor: "Umberto Boccioni" sculptor: "Umberto Boccioni"
painter: "Vladimir Burliuk" painter: "Vladimir Burliuk"
@ -34,10 +37,9 @@ futurists =
{poet: {:name, address: {street, city}}} = futurists {poet: {:name, address: {street, city}}} = futurists
print name, street, city
-- --
do
{ @world } = x { @world } = x
{ a.b, c.y, func!.z } = x { a.b, c.y, func!.z } = x
@ -45,6 +47,7 @@ print name, street, city
-- --
do
thing = {{1,2}, {3,4}} thing = {{1,2}, {3,4}}
for {x,y} in *thing for {x,y} in *thing
@ -53,12 +56,14 @@ for {x,y} in *thing
-- --
do
with {a,b} = thing with {a,b} = thing
print a, b print a, b
-- --
do
thing = nil thing = nil
if {a} = thing if {a} = thing
print a print a
@ -76,7 +81,6 @@ elseif {c,d} = thang
else else
print "NO" print "NO"
-- --
do do

View File

@ -1,3 +1,4 @@
do
local a, b local a, b
do do
local _obj_0 = hello local _obj_0 = hello
@ -13,9 +14,14 @@ do
local _obj_0 = value local _obj_0 = value
hello, world = _obj_0.hello, _obj_0.world hello, world = _obj_0.hello, _obj_0.world
end end
end
do
local no, thing local no, thing
no, thing = world.yes, world[1] do
local d local _obj_0 = world
no, thing = _obj_0.yes, _obj_0[1]
end
local a, b, c, d
do do
local _obj_0 = yeah local _obj_0 = yeah
a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d
@ -54,6 +60,8 @@ do
local _obj_0 = tbl local _obj_0 = tbl
a, b, c, d, e, f, g = _obj_0[1], _obj_0.b, _obj_0[2], _obj_0.d, _obj_0[3], _obj_0.f, _obj_0[4] a, b, c, d, e, f, g = _obj_0[1], _obj_0.b, _obj_0[2], _obj_0.d, _obj_0[3], _obj_0.f, _obj_0[4]
end end
end
do
local futurists = { local futurists = {
sculptor = "Umberto Boccioni", sculptor = "Umberto Boccioni",
painter = "Vladimir Burliuk", painter = "Vladimir Burliuk",
@ -67,11 +75,23 @@ local futurists = {
} }
local name, street, city local name, street, city
name, street, city = futurists.poet.name, futurists.poet.address[1], futurists.poet.address[2] name, street, city = futurists.poet.name, futurists.poet.address[1], futurists.poet.address[2]
print(name, street, city) end
self.world = x[1] do
a.b, c.y, func().z = x[1], x[2], x[3] do
self.world = x.world local _obj_0 = x
thing = { self.world = _obj_0[1]
end
do
local _obj_0 = x
a.b, c.y, func().z = _obj_0[1], _obj_0[2], _obj_0[3]
end
do
local _obj_0 = x
self.world = _obj_0.world
end
end
do
local thing = {
{ {
1, 1,
2 2
@ -84,18 +104,25 @@ thing = {
local _list_0 = thing local _list_0 = thing
for _index_0 = 1, #_list_0 do for _index_0 = 1, #_list_0 do
local _des_0 = _list_0[_index_0] local _des_0 = _list_0[_index_0]
local x, y
x, y = _des_0[1], _des_0[2] x, y = _des_0[1], _des_0[2]
print(x, y) print(x, y)
end end
end
do
do do
local _with_0 = thing local _with_0 = thing
local a, b
a, b = _with_0[1], _with_0[2] a, b = _with_0[1], _with_0[2]
print(a, b) print(a, b)
end end
thing = nil end
do
local thing = nil
do do
local _des_0 = thing local _des_0 = thing
if _des_0 then if _des_0 then
local a
a = _des_0[1] a = _des_0[1]
print(a) print(a)
else else
@ -109,6 +136,7 @@ local thang = {
do do
local _des_0 = thang local _des_0 = thang
if _des_0 then if _des_0 then
local a, b
a, b = _des_0[1], _des_0[2] a, b = _des_0[1], _des_0[2]
print(a, b) print(a, b)
end end
@ -116,12 +144,14 @@ end
do do
local _des_0 = thing local _des_0 = thing
if _des_0 then if _des_0 then
local a, b
a, b = _des_0[1], _des_0[2] a, b = _des_0[1], _des_0[2]
print(a, b) print(a, b)
else else
do do
local _des_1 = thang local _des_1 = thang
if _des_1 then if _des_1 then
local c, d
c, d = _des_1[1], _des_1[2] c, d = _des_1[1], _des_1[2]
print(c, d) print(c, d)
else else
@ -130,22 +160,28 @@ do
end end
end end
end end
end
do do
local z = "yeah" local z = "yeah"
local a, b, c
a, b, c = z[1], z[2], z[3] a, b, c = z[1], z[2], z[3]
end end
do do
local a, b, c
do do
local _obj_0 = z local _obj_0 = z
a, b, c = _obj_0[1], _obj_0[2], _obj_0[3] a, b, c = _obj_0[1], _obj_0[2], _obj_0[3]
end end
end end
local _
_ = function(z) _ = function(z)
local a, b, c
a, b, c = z[1], z[2], z[3] a, b, c = z[1], z[2], z[3]
end end
do do
local z = "oo" local z = "oo"
return function(k) return function(k)
local a, b, c
a, b, c = z[1], z[2], z[3] a, b, c = z[1], z[2], z[3]
end end
end end