comparison spec/util_json_spec.lua @ 10591:d78c5c9b0cf6

util.json: Test util.array integration This is to expose how [] == json.null due to a change in Lua 5.3 with how the equality metamethod is chosen.
author Kim Alvefur <zash@zash.se>
date Wed, 15 Jan 2020 21:14:06 +0100
parents c9c4b8bc53b1
children
comparison
equal deleted inserted replaced
10590:257dc26e8e65 10591:d78c5c9b0cf6
1 1
2 local json = require "util.json"; 2 local json = require "util.json";
3 local array = require "util.array";
3 4
4 describe("util.json", function() 5 describe("util.json", function()
5 describe("#encode()", function() 6 describe("#encode()", function()
6 it("should work", function() 7 it("should work", function()
7 local function test(f, j, e) 8 local function test(f, j, e)
65 local parsed, err = json.decode(content); 66 local parsed, err = json.decode(content);
66 assert(not parsed, name..": "..tostring(err)); 67 assert(not parsed, name..": "..tostring(err));
67 end 68 end
68 end); 69 end);
69 end) 70 end)
71
72 describe("util.array integration", function ()
73 it("works", function ()
74 assert.equal("[]", json.encode(array()));
75 assert.equal("[1,2,3]", json.encode(array({1,2,3})));
76 assert.equal(getmetatable(array()), getmetatable(json.decode("[]")));
77 end);
78 end);
79
70 end); 80 end);