summaryrefslogtreecommitdiff
path: root/json/tests
diff options
context:
space:
mode:
Diffstat (limited to 'json/tests')
-rw-r--r--json/tests/draft2019-09/enum.json10
-rw-r--r--json/tests/draft2019-09/if-then-else.json30
-rw-r--r--json/tests/draft2019-09/multipleOf.json11
-rw-r--r--json/tests/draft2019-09/optional/ecmascript-regex.json11
-rw-r--r--json/tests/draft2019-09/optional/float-overflow.json13
-rw-r--r--json/tests/draft2019-09/unevaluatedItems.json30
-rw-r--r--json/tests/draft3/ref.json14
-rw-r--r--json/tests/draft4/enum.json10
-rw-r--r--json/tests/draft4/multipleOf.json11
-rw-r--r--json/tests/draft4/optional/ecmascript-regex.json11
-rw-r--r--json/tests/draft4/optional/float-overflow.json13
-rw-r--r--json/tests/draft4/ref.json14
-rw-r--r--json/tests/draft6/enum.json10
-rw-r--r--json/tests/draft6/multipleOf.json11
-rw-r--r--json/tests/draft6/optional/ecmascript-regex.json11
-rw-r--r--json/tests/draft6/optional/float-overflow.json13
-rw-r--r--json/tests/draft6/ref.json14
-rw-r--r--json/tests/draft7/enum.json10
-rw-r--r--json/tests/draft7/if-then-else.json30
-rw-r--r--json/tests/draft7/multipleOf.json11
-rw-r--r--json/tests/draft7/optional/ecmascript-regex.json11
-rw-r--r--json/tests/draft7/optional/float-overflow.json13
-rw-r--r--json/tests/draft7/ref.json14
23 files changed, 243 insertions, 83 deletions
diff --git a/json/tests/draft2019-09/enum.json b/json/tests/draft2019-09/enum.json
index 6844578..f085097 100644
--- a/json/tests/draft2019-09/enum.json
+++ b/json/tests/draft2019-09/enum.json
@@ -33,6 +33,16 @@
"description": "objects are deep compared",
"data": {"foo": false},
"valid": false
+ },
+ {
+ "description": "valid object matches",
+ "data": {"foo": 12},
+ "valid": true
+ },
+ {
+ "description": "extra properties in object is invalid",
+ "data": {"foo": 12, "boo": 42},
+ "valid": false
}
]
},
diff --git a/json/tests/draft2019-09/if-then-else.json b/json/tests/draft2019-09/if-then-else.json
index e0b873e..284e919 100644
--- a/json/tests/draft2019-09/if-then-else.json
+++ b/json/tests/draft2019-09/if-then-else.json
@@ -224,5 +224,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "if appears at the end when serialized (keyword processing sequence)",
+ "schema": {
+ "then": { "const": "yes" },
+ "else": { "const": "other" },
+ "if": { "maxLength": 4 }
+ },
+ "tests": [
+ {
+ "description": "yes redirects to then and passes",
+ "data": "yes",
+ "valid": true
+ },
+ {
+ "description": "other redirects to else and passes",
+ "data": "other",
+ "valid": true
+ },
+ {
+ "description": "no redirects to then and fails",
+ "data": "no",
+ "valid": false
+ },
+ {
+ "description": "invalid redirects to else and fails",
+ "data": "invalid",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/multipleOf.json b/json/tests/draft2019-09/multipleOf.json
index ca3b761..faa87cf 100644
--- a/json/tests/draft2019-09/multipleOf.json
+++ b/json/tests/draft2019-09/multipleOf.json
@@ -56,5 +56,16 @@
"valid": false
}
]
+ },
+ {
+ "description": "invalid instance should not raise error when float division = inf",
+ "schema": {"type": "integer", "multipleOf": 0.123456789},
+ "tests": [
+ {
+ "description": "always invalid, but naive implementations may raise an overflow error",
+ "data": 1e308,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft2019-09/optional/ecmascript-regex.json b/json/tests/draft2019-09/optional/ecmascript-regex.json
index b9412e0..6ed6cbe 100644
--- a/json/tests/draft2019-09/optional/ecmascript-regex.json
+++ b/json/tests/draft2019-09/optional/ecmascript-regex.json
@@ -1,16 +1,5 @@
[
{
- "description": "ECMA 262 regex non-compliance",
- "schema": { "format": "regex" },
- "tests": [
- {
- "description": "ECMA 262 has no support for \\Z anchor from .NET",
- "data": "^\\S(|(.|\\n)*\\S)\\Z",
- "valid": false
- }
- ]
- },
- {
"description": "ECMA 262 regex $ does not match trailing newline",
"schema": {
"type": "string",
diff --git a/json/tests/draft2019-09/optional/float-overflow.json b/json/tests/draft2019-09/optional/float-overflow.json
new file mode 100644
index 0000000..52ff982
--- /dev/null
+++ b/json/tests/draft2019-09/optional/float-overflow.json
@@ -0,0 +1,13 @@
+[
+ {
+ "description": "all integers are multiples of 0.5, if overflow is handled",
+ "schema": {"type": "integer", "multipleOf": 0.5},
+ "tests": [
+ {
+ "description": "valid if optional overflow handling is implemented",
+ "data": 1e308,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft2019-09/unevaluatedItems.json b/json/tests/draft2019-09/unevaluatedItems.json
index 01c07be..32f13f8 100644
--- a/json/tests/draft2019-09/unevaluatedItems.json
+++ b/json/tests/draft2019-09/unevaluatedItems.json
@@ -87,12 +87,12 @@
},
"tests": [
{
- "description": "with no unevaluted items",
+ "description": "with no unevaluated items",
"data": ["foo"],
"valid": true
},
{
- "description": "with unevaluted items",
+ "description": "with unevaluated items",
"data": ["foo", "bar"],
"valid": false
}
@@ -135,12 +135,12 @@
},
"tests": [
{
- "description": "with no unevaluted items",
+ "description": "with no unevaluated items",
"data": ["foo", 42],
"valid": true
},
{
- "description": "with unevaluted items",
+ "description": "with unevaluated items",
"data": ["foo", 42, true],
"valid": false
}
@@ -228,22 +228,22 @@
},
"tests": [
{
- "description": "when one schema matches and has no unevaluted items",
+ "description": "when one schema matches and has no unevaluated items",
"data": ["foo", "bar"],
"valid": true
},
{
- "description": "when one schema matches and has unevaluted items",
+ "description": "when one schema matches and has unevaluated items",
"data": ["foo", "bar", 42],
"valid": false
},
{
- "description": "when two schemas match and has no unevaluted items",
+ "description": "when two schemas match and has no unevaluated items",
"data": ["foo", "bar", "baz"],
"valid": true
},
{
- "description": "when two schemas match and has unevaluted items",
+ "description": "when two schemas match and has unevaluated items",
"data": ["foo", "bar", "baz", 42],
"valid": false
}
@@ -274,12 +274,12 @@
},
"tests": [
{
- "description": "with no unevaluted items",
+ "description": "with no unevaluated items",
"data": ["foo", "bar"],
"valid": true
},
{
- "description": "with unevaluted items",
+ "description": "with unevaluated items",
"data": ["foo", "bar", 42],
"valid": false
}
@@ -304,7 +304,7 @@
},
"tests": [
{
- "description": "with unevaluted items",
+ "description": "with unevaluated items",
"data": ["foo", "bar"],
"valid": false
}
@@ -342,22 +342,22 @@
},
"tests": [
{
- "description": "when if matches and it has no unevaluted items",
+ "description": "when if matches and it has no unevaluated items",
"data": ["foo", "bar", "then"],
"valid": true
},
{
- "description": "when if matches and it has unevaluted items",
+ "description": "when if matches and it has unevaluated items",
"data": ["foo", "bar", "then", "else"],
"valid": false
},
{
- "description": "when if doesn't match and it has no unevaluted items",
+ "description": "when if doesn't match and it has no unevaluated items",
"data": ["foo", 42, 42, "else"],
"valid": true
},
{
- "description": "when if doesn't match and it has unevaluted items",
+ "description": "when if doesn't match and it has unevaluated items",
"data": ["foo", 42, 42, "else", 42],
"valid": false
}
diff --git a/json/tests/draft3/ref.json b/json/tests/draft3/ref.json
index 74e963c..77b2947 100644
--- a/json/tests/draft3/ref.json
+++ b/json/tests/draft3/ref.json
@@ -75,13 +75,15 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilde~field": {"type": "integer"},
- "slash/field": {"type": "integer"},
- "percent%field": {"type": "integer"},
+ "definitions": {
+ "tilde~field": {"type": "integer"},
+ "slash/field": {"type": "integer"},
+ "percent%field": {"type": "integer"}
+ },
"properties": {
- "tilde": {"$ref": "#/tilde~0field"},
- "slash": {"$ref": "#/slash~1field"},
- "percent": {"$ref": "#/percent%25field"}
+ "tilde": {"$ref": "#/definitions/tilde~0field"},
+ "slash": {"$ref": "#/definitions/slash~1field"},
+ "percent": {"$ref": "#/definitions/percent%25field"}
}
},
"tests": [
diff --git a/json/tests/draft4/enum.json b/json/tests/draft4/enum.json
index 6844578..f085097 100644
--- a/json/tests/draft4/enum.json
+++ b/json/tests/draft4/enum.json
@@ -33,6 +33,16 @@
"description": "objects are deep compared",
"data": {"foo": false},
"valid": false
+ },
+ {
+ "description": "valid object matches",
+ "data": {"foo": 12},
+ "valid": true
+ },
+ {
+ "description": "extra properties in object is invalid",
+ "data": {"foo": 12, "boo": 42},
+ "valid": false
}
]
},
diff --git a/json/tests/draft4/multipleOf.json b/json/tests/draft4/multipleOf.json
index ca3b761..faa87cf 100644
--- a/json/tests/draft4/multipleOf.json
+++ b/json/tests/draft4/multipleOf.json
@@ -56,5 +56,16 @@
"valid": false
}
]
+ },
+ {
+ "description": "invalid instance should not raise error when float division = inf",
+ "schema": {"type": "integer", "multipleOf": 0.123456789},
+ "tests": [
+ {
+ "description": "always invalid, but naive implementations may raise an overflow error",
+ "data": 1e308,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft4/optional/ecmascript-regex.json b/json/tests/draft4/optional/ecmascript-regex.json
index b9412e0..6ed6cbe 100644
--- a/json/tests/draft4/optional/ecmascript-regex.json
+++ b/json/tests/draft4/optional/ecmascript-regex.json
@@ -1,16 +1,5 @@
[
{
- "description": "ECMA 262 regex non-compliance",
- "schema": { "format": "regex" },
- "tests": [
- {
- "description": "ECMA 262 has no support for \\Z anchor from .NET",
- "data": "^\\S(|(.|\\n)*\\S)\\Z",
- "valid": false
- }
- ]
- },
- {
"description": "ECMA 262 regex $ does not match trailing newline",
"schema": {
"type": "string",
diff --git a/json/tests/draft4/optional/float-overflow.json b/json/tests/draft4/optional/float-overflow.json
new file mode 100644
index 0000000..52ff982
--- /dev/null
+++ b/json/tests/draft4/optional/float-overflow.json
@@ -0,0 +1,13 @@
+[
+ {
+ "description": "all integers are multiples of 0.5, if overflow is handled",
+ "schema": {"type": "integer", "multipleOf": 0.5},
+ "tests": [
+ {
+ "description": "valid if optional overflow handling is implemented",
+ "data": 1e308,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft4/ref.json b/json/tests/draft4/ref.json
index fc3e94b..f88e963 100644
--- a/json/tests/draft4/ref.json
+++ b/json/tests/draft4/ref.json
@@ -75,13 +75,15 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilde~field": {"type": "integer"},
- "slash/field": {"type": "integer"},
- "percent%field": {"type": "integer"},
+ "definitions": {
+ "tilde~field": {"type": "integer"},
+ "slash/field": {"type": "integer"},
+ "percent%field": {"type": "integer"}
+ },
"properties": {
- "tilde": {"$ref": "#/tilde~0field"},
- "slash": {"$ref": "#/slash~1field"},
- "percent": {"$ref": "#/percent%25field"}
+ "tilde": {"$ref": "#/definitions/tilde~0field"},
+ "slash": {"$ref": "#/definitions/slash~1field"},
+ "percent": {"$ref": "#/definitions/percent%25field"}
}
},
"tests": [
diff --git a/json/tests/draft6/enum.json b/json/tests/draft6/enum.json
index 6844578..f085097 100644
--- a/json/tests/draft6/enum.json
+++ b/json/tests/draft6/enum.json
@@ -33,6 +33,16 @@
"description": "objects are deep compared",
"data": {"foo": false},
"valid": false
+ },
+ {
+ "description": "valid object matches",
+ "data": {"foo": 12},
+ "valid": true
+ },
+ {
+ "description": "extra properties in object is invalid",
+ "data": {"foo": 12, "boo": 42},
+ "valid": false
}
]
},
diff --git a/json/tests/draft6/multipleOf.json b/json/tests/draft6/multipleOf.json
index ca3b761..faa87cf 100644
--- a/json/tests/draft6/multipleOf.json
+++ b/json/tests/draft6/multipleOf.json
@@ -56,5 +56,16 @@
"valid": false
}
]
+ },
+ {
+ "description": "invalid instance should not raise error when float division = inf",
+ "schema": {"type": "integer", "multipleOf": 0.123456789},
+ "tests": [
+ {
+ "description": "always invalid, but naive implementations may raise an overflow error",
+ "data": 1e308,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft6/optional/ecmascript-regex.json b/json/tests/draft6/optional/ecmascript-regex.json
index b9412e0..6ed6cbe 100644
--- a/json/tests/draft6/optional/ecmascript-regex.json
+++ b/json/tests/draft6/optional/ecmascript-regex.json
@@ -1,16 +1,5 @@
[
{
- "description": "ECMA 262 regex non-compliance",
- "schema": { "format": "regex" },
- "tests": [
- {
- "description": "ECMA 262 has no support for \\Z anchor from .NET",
- "data": "^\\S(|(.|\\n)*\\S)\\Z",
- "valid": false
- }
- ]
- },
- {
"description": "ECMA 262 regex $ does not match trailing newline",
"schema": {
"type": "string",
diff --git a/json/tests/draft6/optional/float-overflow.json b/json/tests/draft6/optional/float-overflow.json
new file mode 100644
index 0000000..52ff982
--- /dev/null
+++ b/json/tests/draft6/optional/float-overflow.json
@@ -0,0 +1,13 @@
+[
+ {
+ "description": "all integers are multiples of 0.5, if overflow is handled",
+ "schema": {"type": "integer", "multipleOf": 0.5},
+ "tests": [
+ {
+ "description": "valid if optional overflow handling is implemented",
+ "data": 1e308,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft6/ref.json b/json/tests/draft6/ref.json
index 8eaba56..0138382 100644
--- a/json/tests/draft6/ref.json
+++ b/json/tests/draft6/ref.json
@@ -75,13 +75,15 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilde~field": {"type": "integer"},
- "slash/field": {"type": "integer"},
- "percent%field": {"type": "integer"},
+ "definitions": {
+ "tilde~field": {"type": "integer"},
+ "slash/field": {"type": "integer"},
+ "percent%field": {"type": "integer"}
+ },
"properties": {
- "tilde": {"$ref": "#/tilde~0field"},
- "slash": {"$ref": "#/slash~1field"},
- "percent": {"$ref": "#/percent%25field"}
+ "tilde": {"$ref": "#/definitions/tilde~0field"},
+ "slash": {"$ref": "#/definitions/slash~1field"},
+ "percent": {"$ref": "#/definitions/percent%25field"}
}
},
"tests": [
diff --git a/json/tests/draft7/enum.json b/json/tests/draft7/enum.json
index 6844578..f085097 100644
--- a/json/tests/draft7/enum.json
+++ b/json/tests/draft7/enum.json
@@ -33,6 +33,16 @@
"description": "objects are deep compared",
"data": {"foo": false},
"valid": false
+ },
+ {
+ "description": "valid object matches",
+ "data": {"foo": 12},
+ "valid": true
+ },
+ {
+ "description": "extra properties in object is invalid",
+ "data": {"foo": 12, "boo": 42},
+ "valid": false
}
]
},
diff --git a/json/tests/draft7/if-then-else.json b/json/tests/draft7/if-then-else.json
index e0b873e..284e919 100644
--- a/json/tests/draft7/if-then-else.json
+++ b/json/tests/draft7/if-then-else.json
@@ -224,5 +224,35 @@
"valid": true
}
]
+ },
+ {
+ "description": "if appears at the end when serialized (keyword processing sequence)",
+ "schema": {
+ "then": { "const": "yes" },
+ "else": { "const": "other" },
+ "if": { "maxLength": 4 }
+ },
+ "tests": [
+ {
+ "description": "yes redirects to then and passes",
+ "data": "yes",
+ "valid": true
+ },
+ {
+ "description": "other redirects to else and passes",
+ "data": "other",
+ "valid": true
+ },
+ {
+ "description": "no redirects to then and fails",
+ "data": "no",
+ "valid": false
+ },
+ {
+ "description": "invalid redirects to else and fails",
+ "data": "invalid",
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/multipleOf.json b/json/tests/draft7/multipleOf.json
index ca3b761..faa87cf 100644
--- a/json/tests/draft7/multipleOf.json
+++ b/json/tests/draft7/multipleOf.json
@@ -56,5 +56,16 @@
"valid": false
}
]
+ },
+ {
+ "description": "invalid instance should not raise error when float division = inf",
+ "schema": {"type": "integer", "multipleOf": 0.123456789},
+ "tests": [
+ {
+ "description": "always invalid, but naive implementations may raise an overflow error",
+ "data": 1e308,
+ "valid": false
+ }
+ ]
}
]
diff --git a/json/tests/draft7/optional/ecmascript-regex.json b/json/tests/draft7/optional/ecmascript-regex.json
index b9412e0..6ed6cbe 100644
--- a/json/tests/draft7/optional/ecmascript-regex.json
+++ b/json/tests/draft7/optional/ecmascript-regex.json
@@ -1,16 +1,5 @@
[
{
- "description": "ECMA 262 regex non-compliance",
- "schema": { "format": "regex" },
- "tests": [
- {
- "description": "ECMA 262 has no support for \\Z anchor from .NET",
- "data": "^\\S(|(.|\\n)*\\S)\\Z",
- "valid": false
- }
- ]
- },
- {
"description": "ECMA 262 regex $ does not match trailing newline",
"schema": {
"type": "string",
diff --git a/json/tests/draft7/optional/float-overflow.json b/json/tests/draft7/optional/float-overflow.json
new file mode 100644
index 0000000..52ff982
--- /dev/null
+++ b/json/tests/draft7/optional/float-overflow.json
@@ -0,0 +1,13 @@
+[
+ {
+ "description": "all integers are multiples of 0.5, if overflow is handled",
+ "schema": {"type": "integer", "multipleOf": 0.5},
+ "tests": [
+ {
+ "description": "valid if optional overflow handling is implemented",
+ "data": 1e308,
+ "valid": true
+ }
+ ]
+ }
+]
diff --git a/json/tests/draft7/ref.json b/json/tests/draft7/ref.json
index 5a8602e..01ba9fa 100644
--- a/json/tests/draft7/ref.json
+++ b/json/tests/draft7/ref.json
@@ -75,13 +75,15 @@
{
"description": "escaped pointer ref",
"schema": {
- "tilde~field": {"type": "integer"},
- "slash/field": {"type": "integer"},
- "percent%field": {"type": "integer"},
+ "definitions": {
+ "tilde~field": {"type": "integer"},
+ "slash/field": {"type": "integer"},
+ "percent%field": {"type": "integer"}
+ },
"properties": {
- "tilde": {"$ref": "#/tilde~0field"},
- "slash": {"$ref": "#/slash~1field"},
- "percent": {"$ref": "#/percent%25field"}
+ "tilde": {"$ref": "#/definitions/tilde~0field"},
+ "slash": {"$ref": "#/definitions/slash~1field"},
+ "percent": {"$ref": "#/definitions/percent%25field"}
}
},
"tests": [