update to latest JSON Schema Test suite (except for the ref-test)

This commit is contained in:
Patrick Boettcher 2019-10-22 16:20:18 +02:00
parent f0e4421a50
commit 247c2edbee
9 changed files with 498 additions and 7 deletions

View File

@ -159,5 +159,31 @@
"valid": true "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
}
]
} }
] ]

View File

@ -82,5 +82,89 @@
"valid": false "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
}
]
} }
] ]

View File

@ -89,6 +89,11 @@
"description": "empty array is invalid", "description": "empty array is invalid",
"data": [], "data": [],
"valid": false "valid": false
},
{
"description": "non-arrays are valid",
"data": "contains does not apply to strings",
"valid": true
} }
] ]
} }

View File

@ -91,5 +91,89 @@
"valid": false "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
}
]
} }
] ]

View File

@ -174,7 +174,7 @@
}, },
"tests": [ "tests": [
{ {
"description": "valid, but woud have been invalid through then", "description": "valid, but would have been invalid through then",
"data": -100, "data": -100,
"valid": true "valid": true
}, },

View File

@ -9,5 +9,205 @@
"valid": false "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
}
]
} }
] ]

View File

@ -1,9 +1,7 @@
[ [
{ {
"description": "format: uri-template", "description": "format: uri-template",
"schema": { "schema": {"format": "uri-template"},
"format": "uri-template"
},
"tests": [ "tests": [
{ {
"description": "a valid uri-template", "description": "a valid uri-template",

View File

@ -333,7 +333,7 @@
"description": "refs with quote", "description": "refs with quote",
"schema": { "schema": {
"properties": { "properties": {
"foo\"bar": {"$ref": "#/definitions/foo\"bar"} "foo\"bar": {"$ref": "#/definitions/foo%22bar"}
}, },
"definitions": { "definitions": {
"foo\"bar": {"type": "number"} "foo\"bar": {"type": "number"}

View File

@ -18,6 +18,16 @@
"data": [1.0, 1.00, 1], "data": [1.0, 1.00, 1],
"valid": false "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", "description": "unique array of objects is valid",
"data": [{"foo": "bar"}, {"foo": "baz"}], "data": [{"foo": "bar"}, {"foo": "baz"}],
@ -75,5 +85,89 @@
"valid": false "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
}
]
} }
] ]