comparison spec/util_json_spec.lua @ 11200:bf8f2da84007

Merge 0.11->trunk
author Kim Alvefur <zash@zash.se>
date Thu, 05 Nov 2020 22:31:25 +0100
parents d78c5c9b0cf6
children
comparison
equal deleted inserted replaced
11199:6c7c50a4de32 11200:bf8f2da84007
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);