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,81 +1,85 @@
{a, b} = hello do
{a, b} = hello
{{a}, b, {c}} = hello {{a}, b, {c}} = hello
{ :hello, :world } = value { :hello, :world } = value
{ yes: no, thing } = world do
{ yes: no, thing } = world
{:a,:b,:c,:d} = yeah {:a,:b,:c,:d} = yeah
{a} = one, two {a} = one, two
{b}, c = one {b}, c = one
{d}, e = one, two {d}, e = one, two
x, {y} = one, two x, {y} = one, two
xx, yy = 1, 2 xx, yy = 1, 2
{yy, xx} = {xx, yy} {yy, xx} = {xx, yy}
{a, :b, c, :d, e, :f, g} = tbl {a, :b, c, :d, e, :f, g} = tbl
--- ---
futurists = do
sculptor: "Umberto Boccioni" futurists =
painter: "Vladimir Burliuk" sculptor: "Umberto Boccioni"
poet: painter: "Vladimir Burliuk"
name: "F.T. Marinetti" poet:
address: { name: "F.T. Marinetti"
"Via Roma 42R" address: {
"Bellagio, Italy 22021" "Via Roma 42R"
} "Bellagio, Italy 22021"
}
{poet: {:name, address: {street, city}}} = futurists {poet: {:name, address: {street, city}}} = futurists
print name, street, city
-- --
{ @world } = x do
{ a.b, c.y, func!.z } = x { @world } = x
{ a.b, c.y, func!.z } = x
{ world: @world } = x { world: @world } = x
-- --
thing = {{1,2}, {3,4}} do
thing = {{1,2}, {3,4}}
for {x,y} in *thing for {x,y} in *thing
print x,y print x,y
-- --
with {a,b} = thing do
print a, b with {a,b} = thing
print a, b
-- --
thing = nil do
if {a} = thing thing = nil
print a if {a} = thing
else print a
print "nothing" else
print "nothing"
thang = {1,2} thang = {1,2}
if {a,b} = thang if {a,b} = thang
print a,b print a,b
if {a,b} = thing
print a,b
elseif {c,d} = thang
print c,d
else
print "NO"
if {a,b} = thing
print a,b
elseif {c,d} = thang
print c,d
else
print "NO"
-- --

View File

@ -1,151 +1,187 @@
local a, b
do do
local _obj_0 = hello local a, b
a, b = _obj_0[1], _obj_0[2] do
end local _obj_0 = hello
local c a, b = _obj_0[1], _obj_0[2]
do end
local _obj_0 = hello local c
a, b, c = _obj_0[1][1], _obj_0[2], _obj_0[3][1] do
end local _obj_0 = hello
local hello, world a, b, c = _obj_0[1][1], _obj_0[2], _obj_0[3][1]
do end
local _obj_0 = value local hello, world
hello, world = _obj_0.hello, _obj_0.world do
end local _obj_0 = value
local no, thing hello, world = _obj_0.hello, _obj_0.world
no, thing = world.yes, world[1] end
local d
do
local _obj_0 = yeah
a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d
end end
do do
local _obj_0 = one local no, thing
a = _obj_0[1] do
local _obj_0 = world
no, thing = _obj_0.yes, _obj_0[1]
end
local a, b, c, d
do
local _obj_0 = yeah
a, b, c, d = _obj_0.a, _obj_0.b, _obj_0.c, _obj_0.d
end
do
local _obj_0 = one
a = _obj_0[1]
end
local _ = two
do
local _obj_0 = one
b = _obj_0[1]
end
c = nil
do
local _obj_0 = one
d = _obj_0[1]
end
local e = two
local x = one
local y
do
local _obj_0 = two
y = _obj_0[1]
end
local xx, yy = 1, 2
do
local _obj_0 = {
xx,
yy
}
yy, xx = _obj_0[1], _obj_0[2]
end
local f, g
do
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]
end
end end
local _ = two
do do
local _obj_0 = one local futurists = {
b = _obj_0[1] sculptor = "Umberto Boccioni",
end painter = "Vladimir Burliuk",
c = nil poet = {
do name = "F.T. Marinetti",
local _obj_0 = one address = {
d = _obj_0[1] "Via Roma 42R",
end "Bellagio, Italy 22021"
local e = two }
local x = one
local y
do
local _obj_0 = two
y = _obj_0[1]
end
local xx, yy = 1, 2
do
local _obj_0 = {
xx,
yy
}
yy, xx = _obj_0[1], _obj_0[2]
end
local f, g
do
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]
end
local futurists = {
sculptor = "Umberto Boccioni",
painter = "Vladimir Burliuk",
poet = {
name = "F.T. Marinetti",
address = {
"Via Roma 42R",
"Bellagio, Italy 22021"
} }
} }
} 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] end
print(name, street, city) do
self.world = x[1] do
a.b, c.y, func().z = x[1], x[2], x[3] local _obj_0 = x
self.world = x.world self.world = _obj_0[1]
thing = { 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,
2
},
{
3,
4
}
}
local _list_0 = thing
for _index_0 = 1, #_list_0 do
local _des_0 = _list_0[_index_0]
local x, y
x, y = _des_0[1], _des_0[2]
print(x, y)
end
end
do
do
local _with_0 = thing
local a, b
a, b = _with_0[1], _with_0[2]
print(a, b)
end
end
do
local thing = nil
do
local _des_0 = thing
if _des_0 then
local a
a = _des_0[1]
print(a)
else
print("nothing")
end
end
local thang = {
1, 1,
2 2
},
{
3,
4
} }
} do
local _list_0 = thing local _des_0 = thang
for _index_0 = 1, #_list_0 do if _des_0 then
local _des_0 = _list_0[_index_0] local a, b
x, y = _des_0[1], _des_0[2] a, b = _des_0[1], _des_0[2]
print(x, y) print(a, b)
end end
do
local _with_0 = thing
a, b = _with_0[1], _with_0[2]
print(a, b)
end
thing = nil
do
local _des_0 = thing
if _des_0 then
a = _des_0[1]
print(a)
else
print("nothing")
end end
end do
local thang = { local _des_0 = thing
1, if _des_0 then
2 local a, b
} a, b = _des_0[1], _des_0[2]
do print(a, b)
local _des_0 = thang else
if _des_0 then do
a, b = _des_0[1], _des_0[2] local _des_1 = thang
print(a, b) if _des_1 then
end local c, d
end c, d = _des_1[1], _des_1[2]
do print(c, d)
local _des_0 = thing else
if _des_0 then print("NO")
a, b = _des_0[1], _des_0[2] end
print(a, b)
else
do
local _des_1 = thang
if _des_1 then
c, d = _des_1[1], _des_1[2]
print(c, d)
else
print("NO")
end 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