From 1e74554e20b1bf234da4a3caa8a0d090b43166d4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 9 Oct 2022 14:58:07 +0200 Subject: util.jsonschema: Sort test cases to skip Piped trough `sort -g` --- spec/util_jsonschema_spec.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/util_jsonschema_spec.lua b/spec/util_jsonschema_spec.lua index 74da2c07..28a1a2fc 100644 --- a/spec/util_jsonschema_spec.lua +++ b/spec/util_jsonschema_spec.lua @@ -8,10 +8,6 @@ if lfs.attributes(test_suite_dir, "mode") ~= "directory" then return end -- Tests to skip and short reason why (NYI = not yet implemented) local skip = { - ["ref.json:0:3"] = "NYI additionalProperties"; - ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", - ["ref.json:6:1"] = "NYI", - ["required.json:0:2"] = "distinguishing objects from arrays", ["additionalProperties.json:0:2"] = "distinguishing objects from arrays", ["additionalProperties.json:0:5"] = "NYI", ["additionalProperties.json:1:0"] = "NYI", @@ -40,16 +36,20 @@ local skip = { ["patternProperties.json"] = "NYI", ["properties.json:1:2"] = "NYI", ["properties.json:1:3"] = "NYI", + ["ref.json:0:3"] = "NYI additionalProperties", + ["ref.json:11"] = "NYI", + ["ref.json:12:1"] = "FIXME", + ["ref.json:13"] = "NYI", ["ref.json:14"] = "NYI", ["ref.json:15"] = "NYI", ["ref.json:16"] = "NYI", ["ref.json:17"] = "NYI", ["ref.json:18"] = "NYI", - ["ref.json:13"] = "NYI", ["ref.json:19"] = "NYI", - ["ref.json:11"] = "NYI", - ["ref.json:12:1"] = "FIXME", + ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", + ["ref.json:6:1"] = "NYI", ["refRemote.json"] = "DEFINITELY NYI", + ["required.json:0:2"] = "distinguishing objects from arrays", ["type.json:3:4"] = "distinguishing objects from arrays", ["type.json:3:6"] = "null is weird", ["type.json:4:3"] = "distinguishing objects from arrays", -- cgit v1.2.3 From 8f850047e33349eb569648c002ee08b9699435b5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 9 Oct 2022 15:24:26 +0200 Subject: util.jsonschema: Ignore some further test cases for URI references Full-URI references are not implemented --- spec/util_jsonschema_spec.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spec/util_jsonschema_spec.lua b/spec/util_jsonschema_spec.lua index 28a1a2fc..3c2e5f40 100644 --- a/spec/util_jsonschema_spec.lua +++ b/spec/util_jsonschema_spec.lua @@ -46,8 +46,13 @@ local skip = { ["ref.json:17"] = "NYI", ["ref.json:18"] = "NYI", ["ref.json:19"] = "NYI", + ["ref.json:26"] = "NYI", + ["ref.json:27"] = "NYI", + ["ref.json:28"] = "NYI", ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", ["ref.json:6:1"] = "NYI", + ["ref.json:20"] = "NYI", + ["ref.json:25"] = "NYI", ["refRemote.json"] = "DEFINITELY NYI", ["required.json:0:2"] = "distinguishing objects from arrays", ["type.json:3:4"] = "distinguishing objects from arrays", -- cgit v1.2.3 From c617f27a547610da1ac328a161f177f482b158a6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 9 Oct 2022 15:24:30 +0200 Subject: util.jsonschema: Ignore test case for JavaScript specific detail Also touching on how arrays are indistinguishable from tables in Lua --- spec/util_jsonschema_spec.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/util_jsonschema_spec.lua b/spec/util_jsonschema_spec.lua index 3c2e5f40..968acaf1 100644 --- a/spec/util_jsonschema_spec.lua +++ b/spec/util_jsonschema_spec.lua @@ -50,6 +50,7 @@ local skip = { ["ref.json:27"] = "NYI", ["ref.json:28"] = "NYI", ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", + ["required.json:4"] = "JavaScript specific and distinguishing objects from arrays", ["ref.json:6:1"] = "NYI", ["ref.json:20"] = "NYI", ["ref.json:25"] = "NYI", -- cgit v1.2.3 From 060dc120131931876b4bc8a6f312177051ad174b Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 9 Oct 2022 15:38:36 +0200 Subject: util.jsonschema: Fix Lua 5.2 integer compat math.type() is unavailable before Lua 5.3 so this should use the compat function added at the top --- util/jsonschema.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/jsonschema.lua b/util/jsonschema.lua index 48a3351f..e24fc8be 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -81,7 +81,7 @@ function complex_validate(schema, data, root) if type(data) == "table" then for i in pairs(data) do - if not (math.type(i) == "integer") then + if not (m_type(i) == "integer") then return false end end -- cgit v1.2.3 From bca11bfc73a7ca44daec5854f3c883911bb617ea Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 9 Oct 2022 15:42:25 +0200 Subject: util.jsonschema: Use same integer/float logic on Lua 5.2 and 5.3 Fixes test case type.json:0:1 covering treatment of 1.0 as an integer according to the JSON definition --- util/jsonschema.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/jsonschema.lua b/util/jsonschema.lua index e24fc8be..eafa8b7c 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -1,7 +1,7 @@ -- This file is generated from teal-src/util/jsonschema.lua -local m_type = math.type or function (n) - return n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; +local m_type = function(n) + return type(n) == "number" and n % 1 == 0 and n <= 9007199254740992 and n >= -9007199254740992 and "integer" or "float"; end; local json = require("util.json") local null = json.null; -- cgit v1.2.3