diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json b/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json index bad3e77..ab5eb38 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/anyOf.json @@ -159,5 +159,31 @@ "valid": true } ] + }, + { + "description": "nested anyOf, to check validation semantics", + "schema": { + "anyOf": [ + { + "anyOf": [ + { + "type": "null" + } + ] + } + ] + }, + "tests": [ + { + "description": "null is valid", + "data": null, + "valid": true + }, + { + "description": "anything non-null is invalid", + "data": 123, + "valid": false + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/const.json b/test/JSON-Schema-Test-Suite/tests/draft7/const.json index 0fe00f2..c089625 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/const.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/const.json @@ -82,5 +82,89 @@ "valid": false } ] + }, + { + "description": "const with false does not match 0", + "schema": {"const": false}, + "tests": [ + { + "description": "false is valid", + "data": false, + "valid": true + }, + { + "description": "integer zero is invalid", + "data": 0, + "valid": false + }, + { + "description": "float zero is invalid", + "data": 0.0, + "valid": false + } + ] + }, + { + "description": "const with true does not match 1", + "schema": {"const": true}, + "tests": [ + { + "description": "true is valid", + "data": true, + "valid": true + }, + { + "description": "integer one is invalid", + "data": 1, + "valid": false + }, + { + "description": "float one is invalid", + "data": 1.0, + "valid": false + } + ] + }, + { + "description": "const with 0 does not match false", + "schema": {"const": 0}, + "tests": [ + { + "description": "false is invalid", + "data": false, + "valid": false + }, + { + "description": "integer zero is valid", + "data": 0, + "valid": true + }, + { + "description": "float zero is valid", + "data": 0.0, + "valid": true + } + ] + }, + { + "description": "const with 1 does not match true", + "schema": {"const": 1}, + "tests": [ + { + "description": "true is invalid", + "data": true, + "valid": false + }, + { + "description": "integer one is valid", + "data": 1, + "valid": true + }, + { + "description": "float one is valid", + "data": 1.0, + "valid": true + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/contains.json b/test/JSON-Schema-Test-Suite/tests/draft7/contains.json index b7ae5a2..67ecbd9 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/contains.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/contains.json @@ -89,6 +89,11 @@ "description": "empty array is invalid", "data": [], "valid": false + }, + { + "description": "non-arrays are valid", + "data": "contains does not apply to strings", + "valid": true } ] } diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/enum.json b/test/JSON-Schema-Test-Suite/tests/draft7/enum.json index 04a92a4..32d7902 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/enum.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/enum.json @@ -91,5 +91,89 @@ "valid": false } ] + }, + { + "description": "enum with false does not match 0", + "schema": {"enum": [false]}, + "tests": [ + { + "description": "false is valid", + "data": false, + "valid": true + }, + { + "description": "integer zero is invalid", + "data": 0, + "valid": false + }, + { + "description": "float zero is invalid", + "data": 0.0, + "valid": false + } + ] + }, + { + "description": "enum with true does not match 1", + "schema": {"enum": [true]}, + "tests": [ + { + "description": "true is valid", + "data": true, + "valid": true + }, + { + "description": "integer one is invalid", + "data": 1, + "valid": false + }, + { + "description": "float one is invalid", + "data": 1.0, + "valid": false + } + ] + }, + { + "description": "enum with 0 does not match false", + "schema": {"enum": [0]}, + "tests": [ + { + "description": "false is invalid", + "data": false, + "valid": false + }, + { + "description": "integer zero is valid", + "data": 0, + "valid": true + }, + { + "description": "float zero is valid", + "data": 0.0, + "valid": true + } + ] + }, + { + "description": "enum with 1 does not match true", + "schema": {"enum": [1]}, + "tests": [ + { + "description": "true is invalid", + "data": true, + "valid": false + }, + { + "description": "integer one is valid", + "data": 1, + "valid": true + }, + { + "description": "float one is valid", + "data": 1.0, + "valid": true + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json b/test/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json index 37a229c..be73281 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/if-then-else.json @@ -174,7 +174,7 @@ }, "tests": [ { - "description": "valid, but woud have been invalid through then", + "description": "valid, but would have been invalid through then", "data": -100, "valid": true }, diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json b/test/JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json index 08dc936..d82e0fe 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/optional/ecmascript-regex.json @@ -9,5 +9,205 @@ "valid": false } ] + }, + { + "description": "ECMA 262 regex $ does not match trailing newline", + "schema": { + "type": "string", + "pattern": "^abc$" + }, + "tests": [ + { + "description": "matches in Python, but should not in jsonschema", + "data": "abc\n", + "valid": false + }, + { + "description": "should match", + "data": "abc", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex converts \\a to ascii BEL", + "schema": { + "type": "string", + "pattern": "^\\a$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\a", + "valid": false + }, + { + "description": "matches", + "data": "\u0007", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and upper letter", + "schema": { + "type": "string", + "pattern": "^\\cC$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cC", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 regex escapes control codes with \\c and lower letter", + "schema": { + "type": "string", + "pattern": "^\\cc$" + }, + "tests": [ + { + "description": "does not match", + "data": "\\cc", + "valid": false + }, + { + "description": "matches", + "data": "\u0003", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\d matches ascii digits only", + "schema": { + "type": "string", + "pattern": "^\\d$" + }, + "tests": [ + { + "description": "ASCII zero matches", + "data": "0", + "valid": true + }, + { + "description": "NKO DIGIT ZERO does not match (unlike e.g. Python)", + "data": "߀", + "valid": false + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) does not match", + "data": "\u07c0", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\D matches everything but ascii digits", + "schema": { + "type": "string", + "pattern": "^\\D$" + }, + "tests": [ + { + "description": "ASCII zero does not match", + "data": "0", + "valid": false + }, + { + "description": "NKO DIGIT ZERO matches (unlike e.g. Python)", + "data": "߀", + "valid": true + }, + { + "description": "NKO DIGIT ZERO (as \\u escape) matches", + "data": "\u07c0", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\w matches ascii letters only", + "schema": { + "type": "string", + "pattern": "^\\w$" + }, + "tests": [ + { + "description": "ASCII 'a' matches", + "data": "a", + "valid": true + }, + { + "description": "latin-1 e-acute does not match (unlike e.g. Python)", + "data": "é", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\w matches everything but ascii letters", + "schema": { + "type": "string", + "pattern": "^\\W$" + }, + "tests": [ + { + "description": "ASCII 'a' does not match", + "data": "a", + "valid": false + }, + { + "description": "latin-1 e-acute matches (unlike e.g. Python)", + "data": "é", + "valid": true + } + ] + }, + { + "description": "ECMA 262 \\s matches ascii whitespace only", + "schema": { + "type": "string", + "pattern": "^\\s$" + }, + "tests": [ + { + "description": "ASCII space matches", + "data": " ", + "valid": true + }, + { + "description": "latin-1 non-breaking-space does not match (unlike e.g. Python)", + "data": "\u00a0", + "valid": false + } + ] + }, + { + "description": "ECMA 262 \\S matches everything but ascii whitespace", + "schema": { + "type": "string", + "pattern": "^\\S$" + }, + "tests": [ + { + "description": "ASCII space does not match", + "data": " ", + "valid": false + }, + { + "description": "latin-1 non-breaking-space matches (unlike e.g. Python)", + "data": "\u00a0", + "valid": true + } + ] } ] diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-template.json b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-template.json index d8396a5..33ab76e 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-template.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/optional/format/uri-template.json @@ -1,9 +1,7 @@ [ { "description": "format: uri-template", - "schema": { - "format": "uri-template" - }, + "schema": {"format": "uri-template"}, "tests": [ { "description": "a valid uri-template", diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/ref.json b/test/JSON-Schema-Test-Suite/tests/draft7/ref.json index fecfe7e..3651dac 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/ref.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/ref.json @@ -271,7 +271,7 @@ "tests": [ { "description": "valid tree", - "data": { + "data": { "meta": "root", "nodes": [ { @@ -300,7 +300,7 @@ }, { "description": "invalid tree", - "data": { + "data": { "meta": "root", "nodes": [ { @@ -333,7 +333,7 @@ "description": "refs with quote", "schema": { "properties": { - "foo\"bar": {"$ref": "#/definitions/foo\"bar"} + "foo\"bar": {"$ref": "#/definitions/foo%22bar"} }, "definitions": { "foo\"bar": {"type": "number"} diff --git a/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json b/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json index c1f4ab9..d0a94d8 100644 --- a/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json +++ b/test/JSON-Schema-Test-Suite/tests/draft7/uniqueItems.json @@ -18,6 +18,16 @@ "data": [1.0, 1.00, 1], "valid": false }, + { + "description": "false is not equal to zero", + "data": [0, false], + "valid": true + }, + { + "description": "true is not equal to one", + "data": [1, true], + "valid": true + }, { "description": "unique array of objects is valid", "data": [{"foo": "bar"}, {"foo": "baz"}], @@ -75,5 +85,89 @@ "valid": false } ] + }, + { + "description": "uniqueItems with an array of items", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": true + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is not valid", + "data": [false, false], + "valid": false + }, + { + "description": "[true, true] from items array is not valid", + "data": [true, true], + "valid": false + }, + { + "description": "unique array extended from [false, true] is valid", + "data": [false, true, "foo", "bar"], + "valid": true + }, + { + "description": "unique array extended from [true, false] is valid", + "data": [true, false, "foo", "bar"], + "valid": true + }, + { + "description": "non-unique array extended from [false, true] is not valid", + "data": [false, true, "foo", "foo"], + "valid": false + }, + { + "description": "non-unique array extended from [true, false] is not valid", + "data": [true, false, "foo", "foo"], + "valid": false + } + ] + }, + { + "description": "uniqueItems with an array of items and additionalItems=false", + "schema": { + "items": [{"type": "boolean"}, {"type": "boolean"}], + "uniqueItems": true, + "additionalItems": false + }, + "tests": [ + { + "description": "[false, true] from items array is valid", + "data": [false, true], + "valid": true + }, + { + "description": "[true, false] from items array is valid", + "data": [true, false], + "valid": true + }, + { + "description": "[false, false] from items array is not valid", + "data": [false, false], + "valid": false + }, + { + "description": "[true, true] from items array is not valid", + "data": [true, true], + "valid": false + }, + { + "description": "extra items are invalid even if unique", + "data": [false, true, null], + "valid": false + } + ] } ]