Minetest-WorldEditAdditions/.tests/parse/table/table_apply.test.lua

49 lines
956 B
Lua
Raw Normal View History

2022-09-24 19:47:13 +02:00
local apply = require("worldeditadditions_core.utils.table.table_apply")
describe("table.makeset", function()
it("should work", function()
local source = { apples = 4 }
local target = { oranges = 3 }
apply(source, target)
assert.are.same(
{ apples = 4, oranges = 3 },
target
)
end)
it("should overwrite values in target", function()
local source = { apples = 4 }
local target = { apples = 3 }
apply(source, target)
assert.are.same(
{ apples = 4 },
target
)
end)
it("should work with strings", function()
local source = { apples = "4" }
local target = { oranges = "3" }
apply(source, target)
assert.are.same(
{ apples = "4", oranges = "3" },
target
)
end)
it("should overwrite values in target with strings", function()
local source = { apples = "4" }
local target = { apples = "3" }
apply(source, target)
assert.are.same(
{ apples = "4" },
target
)
end)
end)