mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-11-22 15:33:00 +00:00
table_apply: write tests
This commit is contained in:
parent
da9f578e86
commit
dfb24e679b
1 changed files with 48 additions and 0 deletions
48
.tests/parse/table/table_apply.test.lua
Normal file
48
.tests/parse/table/table_apply.test.lua
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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)
|
Loading…
Reference in a new issue