Updated tests to include trailing nil.

This commit is contained in:
Bruce Hill 2018-04-23 15:17:58 -07:00
parent 9144735dbb
commit c88d4a9dd6

View File

@ -254,39 +254,39 @@ end)
test("Testing tuple iteration", function()
local T = immutable()
local t = T(1,4,9,nil,16)
local checks = {1,4,9,nil,16}
local t = T(1,4,9,nil,16,nil)
local checks = {1,4,9,nil,16,nil}
local passed = 0
for i,v in ipairs(t) do
assert(checks[i] == v)
passed = passed + 1
end
assert(passed == 5)
assert(passed == 6)
passed = 0
for k,v in pairs(t) do
assert(checks[k] == v)
passed = passed + 1
end
assert(passed == 5)
assert(passed == 6)
end)
test("Testing table iteration", function()
local Foo = immutable({"x", "y", "z"})
local f = Foo(1,nil,2)
local checks = {1,nil,2}
local Foo = immutable({"x", "y", "z","w"})
local f = Foo(1,nil,2,nil)
local checks = {1,nil,2,nil}
local passed = 0
for i,v in ipairs(f) do
assert(checks[i] == v)
passed = passed + 1
end
assert(passed == 3)
assert(passed == 4)
passed = 0
checks = {x=1,y=nil,z=2}
checks = {x=1,y=nil,z=2,w=nil}
for k,v in pairs(f) do
assert(checks[k] == v)
passed = passed + 1
end
assert(passed == 3)
assert(passed == 4)
end)
test("Testing __new", function()