Skip to content

Commit

Permalink
Re-add the future keywords tests.
Browse files Browse the repository at this point in the history
The intent of them is *not* to express that an implementation might wish
to recognize these keywords.

The intent of them is precisely the same as the original intent -- to
allow an implementation to test itself for *not* recognizing new
keywords. Such an implementation should enable these tests, as it is
free to do so, and these tests will help ensure it does not accidentally
leak newer keywords backwards in time if it doesn't mean to.

All of the previous discussion was strictly centered on not putting
these in the required directory.

The reason is that all drafts *allow* implementations to add extra
keywords. So a compliant implementation may indeed decide it actively
*wants* to implement new keywords. Then this file would not help them,
and they wouldn't run it. They would presumably love a version of this
file that *did* contain all the future assertions as correct for future
drafts, and in the future we could provide one. But given no
implementations really do do this, at least as far as I'm aware, and
given that this version of the file is here and written and more common,
it would seem perfectly reasonable to have it and hope for the other
version if or when someone wants it.

Further discussion is in #383 and later #559.

This reverts commit f605fbf.
  • Loading branch information
Julian committed Jun 25, 2022
1 parent d3f5cd4 commit 3b4aa99
Show file tree
Hide file tree
Showing 4 changed files with 1,518 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/draft2019-09/optional/future-keywords.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
[
{
"description": "$dynamicRef without $dynamicAnchor works like $ref",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"properties": {
"foo": {"$dynamicRef": "#"}
},
"additionalProperties": false
},
"tests": [
{
"description": "match",
"data": {"foo": false},
"valid": true
},
{
"description": "recursive match",
"data": {"foo": {"foo": false}},
"valid": true
},
{
"description": "mismatch",
"data": {"bar": false},
"valid": false
},
{
"description": "recursive mismatch (but $dynamicRef is ignored)",
"data": {"foo": {"bar": false}},
"valid": true
}
]
},
{
"description": "prefixItems: an array of schemas for items",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"prefixItems": [
{"type": "integer"},
{"type": "string"}
]
},
"tests": [
{
"description": "correct types",
"data": [ 1, "foo" ],
"valid": true
},
{
"description": "wrong types",
"data": [ "foo", 1 ],
"valid": true
},
{
"description": "incomplete array of items",
"data": [ 1 ],
"valid": true
},
{
"description": "array with additional items",
"data": [ 1, "foo", true ],
"valid": true
},
{
"description": "empty array",
"data": [ ],
"valid": true
},
{
"description": "JavaScript pseudo-array is valid",
"data": {
"0": "invalid",
"1": "valid",
"length": 2
},
"valid": true
}
]
}
]
Loading

0 comments on commit 3b4aa99

Please sign in to comment.