Lua: fix key deletion in tables
This commit is contained in:
@@ -126,6 +126,13 @@ assert(table.includes(t, "three"))
|
||||
assert(table.includes(t, true))
|
||||
assert(not table.includes(t, "missing"))
|
||||
|
||||
-- Test using table as set
|
||||
local s = {}
|
||||
s["something"] = true
|
||||
assertEqual(#table.keys(s), 1)
|
||||
-- Remove from the map
|
||||
s["something"] = nil
|
||||
assertEqual(#table.keys(s), 0)
|
||||
|
||||
-- Error cases
|
||||
local success, error = pcall(function()
|
||||
@@ -147,4 +154,4 @@ local t = { 0, 1, 2, 3 }
|
||||
local idx, two = table.find(t, function(v) return v == 2 end)
|
||||
assertEqual(idx, 3)
|
||||
assertEqual(two, 2)
|
||||
assertEqual(table.find(t, function(v) return v == 4 end), nil)
|
||||
assertEqual(table.find(t, function(v) return v == 4 end), nil)
|
||||
|
||||
Reference in New Issue
Block a user