mirror of
https://github.com/littensy/charm.git
synced 2026-10-20 17:51:37 +00:00
23 lines
719 B
Text
23 lines
719 B
Text
local Charm = require("../../Charm")
|
|
local suite = require("../../../../test/suite")
|
|
local utils = require("../utils")
|
|
|
|
local test = suite.test
|
|
|
|
test("should flatten functions", function()
|
|
local input = {
|
|
a = Charm.atom(0),
|
|
b = { c = Charm.atom(0) },
|
|
d = { e = { f = utils.signalToAtom(Charm.signal(0)) } },
|
|
}
|
|
local result = utils.flatten(input)
|
|
|
|
assert(result.a == input.a, "should flatten the first level")
|
|
assert(result["b/c"] == input.b.c, "should flatten the second level")
|
|
assert(result["d/e/f"] == input.d.e.f, "should flatten the third level")
|
|
|
|
assert(result.b == nil, "should remove the original nested tables")
|
|
assert(result.d == nil, "should remove the original nested tables")
|
|
end)
|
|
|
|
return {}
|