Skip to content

more multipleOf and overflow tests, consolidated into optional/ #538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
95 changes: 75 additions & 20 deletions tests/draft-next/multipleOf.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
[
{
"description": "by int",
"schema": {"multipleOf": 2},
"description": "by integer",
"schema": { "multipleOf": 2 },
"tests": [
{
"description": "int by int",
"description": "integer by integer",
"data": 10,
"valid": true
},
{
"description": "int by int fail",
"description": "integer by integer fail",
"data": 7,
"valid": false
},
{
"description": "integer by integer float",
"data": 4.0,
"valid": true
},
{
"description": "integer by number fail",
"data": 7.5,
"valid": false
},
{
"description": "integer by integer float fail",
"data": 7.0,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "foo",
Expand All @@ -21,23 +36,74 @@
]
},
{
"description": "by number",
"schema": {"multipleOf": 1.5},
"description": "by integer float",
"schema": { "multipleOf": 2.0 },
"tests": [
{
"description": "integer by integer",
"data": 10,
"valid": true
},
{
"description": "integer by integer fail",
"data": 7,
"valid": false
},
{
"description": "integer by integer float",
"data": 4.0,
"valid": true
},
{
"description": "integer by number fail",
"data": 7.5,
"valid": false
},
{
"description": "ignores non-numbers",
"data": "foo",
"valid": true
}
]
},
{
"description": "by non-integer number",
"schema": { "multipleOf": 1.5 },
"tests": [
{
"description": "zero is multiple of anything",
"data": 0,
"valid": true
},
{
"description": "4.5 is multiple of 1.5",
"data": 4.5,
"description": "float by integer",
"data": 6,
"valid": true
},
{
"description": "35 is not multiple of 1.5",
"description": "float by integer fail",
"data": 35,
"valid": false
},
{
"description": "float by float",
"data": 4.5,
"valid": true
},
{
"description": "float by float fail",
"data": 7.2,
"valid": false
},
{
"description": "float by integer float",
"data": 6.0,
"valid": true
},
{
"description": "float by integer float fail",
"data": 35.0,
"valid": false
}
]
},
Expand All @@ -56,16 +122,5 @@
"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
}
]
}
]
115 changes: 107 additions & 8 deletions tests/draft-next/optional/bignum.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
"description": "a negative bignum is an integer",
"data": -12345678910111213141516171819202122232425262728293031,
"valid": true
},
{
"description": "a bignum is an integer if it has a zero fractional component",
"data": 12345678910111213141516171819202122232425262728293031.0,
"valid": true
},
{
"description": "a negative bignum is an integer if it has a zero fractional component",
"data": -12345678910111213141516171819202122232425262728293031.0,
"valid": true
}
]
},
Expand All @@ -28,6 +38,16 @@
"description": "a negative bignum is a number",
"data": -98249283749234923498293171823948729348710298301928331,
"valid": true
},
{
"description": "a bignum with a zero fractional component is a number",
"data": 98249283749234923498293171823948729348710298301928331.0,
"valid": true
},
{
"description": "a negative bignum with a zero fractional component is a number",
"data": -98249283749234923498293171823948729348710298301928331.0,
"valid": true
}
]
},
Expand All @@ -39,41 +59,81 @@
"description": "a bignum is not a string",
"data": 98249283749234923498293171823948729348710298301928331,
"valid": false
},
{
"description": "a bignum with zero fractional component is not a string",
"data": 98249283749234923498293171823948729348710298301928331.0,
"valid": false
},
{
"description": "a float bignum is not a string",
"data": 98249283749234923498293171823948729348710298301928331.1,
"valid": false
}
]
},
{
"description": "integer comparison",
"description": "integer comparison, very large number",
"schema": { "maximum": 18446744073709551615 },
"tests": [
{
"description": "comparison works for high numbers",
"description": "comparison works for high integer numbers",
"data": 18446744073709551600,
"valid": true
},
{
"description": "comparison works for high integer floats",
"data": 18446744073709551600.0,
"valid": true
},
{
"description": "comparison works for high non-integer floats",
"data": 18446744073709551600.1,
"valid": true
}
]
},
{
"description": "float comparison with high precision",
"description": "float comparison with high precision on positive numbers",
"schema": {
"exclusiveMaximum": 972783798187987123879878123.18878137
},
"tests": [
{
"description": "comparison works for high numbers",
"description": "comparison works for high integers",
"data": 972783798187987123879878123,
"valid": false
},
{
"description": "comparison works for high float integers",
"data": 972783798187987123879878124.0,
"valid": false
},
{
"description": "comparison works for high non-integer numbers",
"data": 972783798187987123879878123.188781371,
"valid": false
}
]
},
{
"description": "integer comparison",
"description": "integer comparison, very low number",
"schema": { "minimum": -18446744073709551615 },
"tests": [
{
"description": "comparison works for very negative numbers",
"description": "comparison works for very negative integers",
"data": -18446744073709551600,
"valid": true
},
{
"description": "comparison works for very negative float integers",
"data": -18446744073709551600.0,
"valid": true
},
{
"description": "comparison works for very negative non-integer numbers",
"data": -18446744073709551600.1,
"valid": true
}
]
},
Expand All @@ -84,10 +144,49 @@
},
"tests": [
{
"description": "comparison works for very negative numbers",
"data": -972783798187987123879878123.188781371,
"description": "comparison works for very negative integers",
"data": -972783798187987123879878124,
"valid": false
},
{
"description": "comparison works for very negative float integers",
"data": -972783798187987123879878124.0,
"valid": false
},
{
"description": "comparison works for very negative float non-integers",
"data": -972783798187987123879878123.18878137,
"valid": false
}
]
},
{
"description": "multipleOf with a very large dividend",
"schema": {
"multipleOf": 0.123456789
},
"tests": [
{
"description": "true result",
"data": 1.23456789e+307,
"valid": true
},
{
"description": "false result",
"data": 1e308,
"valid": false
}
]
},
{
"description": "all integers are multiples of 0.5, if overflow is handled",
"schema": { "multipleOf": 0.5 },
"tests": [
{
"description": "valid if optional overflow handling is implemented",
"data": 1e308,
"valid": true
}
]
}
]
13 changes: 0 additions & 13 deletions tests/draft-next/optional/float-overflow.json

This file was deleted.

Loading