Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion tests/draft2019-09/if-then-else.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,64 @@
"valid": false
}
]
}
},
{
"description": "then: false fails when condition matches",
"schema": {
"if": { "const": 1 },
"then": false
},
"tests": [
{
"description": "matches if → then=false → invalid",
"data": 1,
"valid": false
},
{
"description": "does not match if → then ignored → valid",
"data": 2,
"valid": true
}
]
},
{
"description": "else: false fails when condition does not match",
"schema": {
"if": { "const": 1 },
"else": false
},
"tests": [
{
"description": "matches if → else ignored → valid",
"data": 1,
"valid": true
},
{
"description": "does not match if → else executes → invalid",
"data": 2,
"valid": false
}
]
},
{
"description": "then and else both are false",
"schema":{
"if":{"type":"number"},
"then":false,
"else":false
},
"tests":[
{
"description": "matches if → then executes and else does not execute → invalid",
"data": 4,
"valid": false
},
{
"description": "does not match if → else executes → invalid",
"data": "foo",
"valid": false
}
]
}
]

60 changes: 59 additions & 1 deletion tests/draft2020-12/if-then-else.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,63 @@
"valid": false
}
]
}
},
{
"description": "then: false fails when condition matches",
"schema": {
"if": { "const": 1 },
"then": false
},
"tests": [
{
"description": "matches if → then=false → invalid",
"data": 1,
"valid": false
},
{
"description": "does not match if → then ignored → valid",
"data": 2,
"valid": true
}
]
},
{
"description": "else: false fails when condition does not match",
"schema": {
"if": { "const": 1 },
"else": false
},
"tests": [
{
"description": "matches if → else ignored → valid",
"data": 1,
"valid": true
},
{
"description": "does not match if → else executes → invalid",
"data": 2,
"valid": false
}
]
},
{
"description": "then and else both are false",
"schema":{
"if":{"type":"number"},
"then":false,
"else":false
},
"tests":[
{
"description": "matches if → then executes and else does not execute → invalid",
"data": 4,
"valid": false
},
{
"description": "does not match if → else executes → invalid",
"data": "foo",
"valid": false
}
]
}
]
60 changes: 59 additions & 1 deletion tests/draft7/if-then-else.json
Original file line number Diff line number Diff line change
Expand Up @@ -254,5 +254,63 @@
"valid": false
}
]
}
},
{
"description": "then: false fails when condition matches",
"schema": {
"if": { "const": 1 },
"then": false
},
"tests": [
{
"description": "matches if → then=false → invalid",
"data": 1,
"valid": false
},
{
"description": "does not match if → then ignored → valid",
"data": 2,
"valid": true
}
]
},
{
"description": "else: false fails when condition does not match",
"schema": {
"if": { "const": 1 },
"else": false
},
"tests": [
{
"description": "matches if → else ignored → valid",
"data": 1,
"valid": true
},
{
"description": "does not match if → else executes → invalid",
"data": 2,
"valid": false
}
]
},
{
"description": "then and else both are false",
"schema":{
"if":{"type":"number"},
"then":false,
"else":false
},
"tests":[
{
"description": "matches if → then executes and else does not execute → invalid",
"data": 4,
"valid": false
},
{
"description": "does not match if → else executes → invalid",
"data": "foo",
"valid": false
}
]
}
]
Loading