aboutsummaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorkwolekr <mirrorisim@gmail.com>2012-12-31 02:01:16 -0500
committerPerttu Ahola <celeron55@gmail.com>2013-01-21 21:41:37 +0200
commit45cf32afc5554d76f7f48268a8cab5a051638761 (patch)
treed367b56d06c1727197a3fc1f06108b421caf27d9 /src/inventory.cpp
parentcde3d38766a19ddbe001e70573eb521eaf62cc66 (diff)
downloadminetest-45cf32afc5554d76f7f48268a8cab5a051638761.tar.gz
minetest-45cf32afc5554d76f7f48268a8cab5a051638761.tar.bz2
minetest-45cf32afc5554d76f7f48268a8cab5a051638761.zip
Add Settings::getStruct and Settings::setStruct
Diffstat (limited to 'src/inventory.cpp')
0 files changed, 0 insertions, 0 deletions
uot;, speed=400}, dog={sound="woof"}} local test_out = core.deserialize(core.serialize(test_in)) assert.same(test_in, test_out) end) it("handles characters", function() local test_in = {escape_chars="\n\r\t\v\\\"\'", non_european="θשׁ٩∂"} local test_out = core.deserialize(core.serialize(test_in)) assert.same(test_in, test_out) end) it("handles precise numbers", function() local test_in = 0.2695949158945771 local test_out = core.deserialize(core.serialize(test_in)) assert.same(test_in, test_out) end) it("handles big integers", function() local test_in = 269594915894577 local test_out = core.deserialize(core.serialize(test_in)) assert.same(test_in, test_out) end) it("handles recursive structures", function() local test_in = { hello = "world" } test_in.foo = test_in local test_out = core.deserialize(core.serialize(test_in)) assert.same(test_in, test_out) end) it("strips functions in safe mode", function() local test_in = { func = function(a, b) error("test") end, foo = "bar" } local str = core.serialize(test_in) assert.not_nil(str:find("loadstring")) local test_out = core.deserialize(str, true) assert.is_nil(test_out.func) assert.equals(test_out.foo, "bar") end) it("vectors work", function() local v = vector.new(1, 2, 3) assert.same({{x = 1, y = 2, z = 3}}, core.deserialize(core.serialize({v}))) assert.same({x = 1, y = 2, z = 3}, core.deserialize(core.serialize(v))) -- abuse v = vector.new(1, 2, 3) v.a = "bla" assert.same({x = 1, y = 2, z = 3, a = "bla"}, core.deserialize(core.serialize(v))) end) end)