Mercurial > prosody-hg
view spec/util_jsonpointer_spec.lua @ 14172:94172bbf9074 13.0
util.jsonschema: Always accept 0 for multipleOf properties
Per the JSON schema test suite, 0 is considered "a multiple of anything" and
should never be rejected by the multipleOf test. The previous behaviour was to
always reject 0.
0 is *not* a valid value for multipleOf itself (which must be >0), but
util.jsonschema does not seem to do much/any validation of the provided schema
so I haven't added a check for that. I assume there are JSON schema schemas?
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 25 May 2026 11:32:33 +0100 |
| parents | 4d5549de27e6 |
| children |
line wrap: on
line source
describe("util.jsonpointer", function() local json, jp; setup(function() json = require "util.json"; jp = require "util.jsonpointer"; end) describe("resolve()", function() local example; setup(function() example = json.decode([[{ "foo": ["bar", "baz"], "": 0, "a/b": 1, "c%d": 2, "e^f": 3, "g|h": 4, "i\\j": 5, "k\"l": 6, " ": 7, "m~n": 8 }]]) end) it("works", function() assert.is_nil(jp.resolve("string", "/string")) assert.same(example, jp.resolve(example, "")); assert.same({ "bar", "baz" }, jp.resolve(example, "/foo")); assert.same("bar", jp.resolve(example, "/foo/0")); assert.same(nil, jp.resolve(example, "/foo/-")); assert.same(0, jp.resolve(example, "/")); assert.same(1, jp.resolve(example, "/a~1b")); assert.same(2, jp.resolve(example, "/c%d")); assert.same(3, jp.resolve(example, "/e^f")); assert.same(4, jp.resolve(example, "/g|h")); assert.same(5, jp.resolve(example, "/i\\j")); assert.same(6, jp.resolve(example, "/k\"l")); assert.same(7, jp.resolve(example, "/ ")); assert.same(8, jp.resolve(example, "/m~0n")); end) end) end)
