Test ipairs()

This commit is contained in:
David Capello 2018-09-12 18:45:23 -03:00
parent 2eaf56f359
commit b14c6fc831
5 changed files with 35 additions and 1 deletions

View File

@ -30,8 +30,14 @@ do
assert(cb[2] == b.cels[2])
assert(cb[3] == b.cels[3])
s:deleteCel(cb[2])
local i = 1
for k,v in ipairs(b.cels) do
assert(i == k)
assert(v == b.cels[k])
i = i+1
end
s:deleteCel(cb[2])
assert(cb[1] == b.cels[1])
assert(cb[3] == b.cels[2])
end

View File

@ -20,6 +20,13 @@ do
assert(a.frames[1].duration == 0.1)
assert(a.frames[2].duration == 0.2)
local i = 1
for k,v in ipairs(a.frames) do
assert(i == k)
assert(v == a.frames[k])
i = i+1
end
a:deleteFrame(1)
assert(a.frames[1].duration == 0.2)
end

View File

@ -16,6 +16,13 @@ do
assert(s.layers[2] == b)
assert(s.layers[3] == c)
local i = 1
for k,v in ipairs(s.layers) do
assert(i == k)
assert(v == s.layers[k])
i = i+1
end
s:deleteLayer(b)
assert(#s.layers == 2)
assert(s.layers[1] == a)

View File

@ -13,6 +13,13 @@ do
assert(b.bounds == Rectangle(0, 2, 8, 10))
assert(c.bounds == Rectangle(0, 0, 32, 32))
local i = 1
for k,v in ipairs(s.slices) do
assert(i == k)
assert(v == s.slices[k])
i = i+1
end
s:deleteSlice(b)
assert(a == s.slices[1])
assert(c == s.slices[2])

View File

@ -20,6 +20,13 @@ do
assert(b == s.tags[2])
assert(c == s.tags[3])
local i = 1
for k,v in ipairs(s.tags) do
assert(i == k)
assert(v == s.tags[k])
i = i+1
end
s:deleteTag(b)
assert(a == s.tags[1])
assert(c == s.tags[2])