local bms = import_namespace("bms")
local world = bms.world
local type = world.get_type_by_name("test_utils::test_data::SimpleEnum")
local constructed = bms.construct(type, {
variant = "Struct",
foo = 123
})
assert(constructed:variant_name() == "Struct",
"Value was constructed incorrectly, expected constructed.variant to be Struct but got " .. constructed:variant_name())
local foo = constructed.foo assert(foo == 123,
"Value was constructed incorrectly, expected constructed.foo to be 123 but got " .. tostring(foo))
local constructed = bms.construct(type, {
variant = "TupleStruct",
["1"] = 123
})
assert(constructed:variant_name() == "TupleStruct",
"Value was constructed incorrectly, expected constructed.variant to be TupleStruct but got " ..
constructed:variant_name())
assert(constructed[1] == 123,
"Value was constructed incorrectly, expected constructed._1 to be 123 but got " .. constructed[1])
local constructed = bms.construct(type, {
variant = "Unit"
})
assert(constructed:variant_name() == "Unit",
"Value was constructed incorrectly, expected constructed.variant to be Unit but got " .. constructed:variant_name())