diff --git a/tests/draft-next/multipleOf.json b/tests/draft-next/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft-next/multipleOf.json +++ b/tests/draft-next/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft-next/optional/bignum.json b/tests/draft-next/optional/bignum.json index 3f49226a..a0210747 100644 --- a/tests/draft-next/optional/bignum.json +++ b/tests/draft-next/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -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 } ] }, @@ -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 + } + ] } ] diff --git a/tests/draft-next/optional/float-overflow.json b/tests/draft-next/optional/float-overflow.json deleted file mode 100644 index 52ff9827..00000000 --- a/tests/draft-next/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "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/tests/draft2019-09/multipleOf.json b/tests/draft2019-09/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft2019-09/multipleOf.json +++ b/tests/draft2019-09/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft2019-09/optional/bignum.json b/tests/draft2019-09/optional/bignum.json index 3f49226a..a0210747 100644 --- a/tests/draft2019-09/optional/bignum.json +++ b/tests/draft2019-09/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -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 } ] }, @@ -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 + } + ] } ] diff --git a/tests/draft2019-09/optional/float-overflow.json b/tests/draft2019-09/optional/float-overflow.json deleted file mode 100644 index 52ff9827..00000000 --- a/tests/draft2019-09/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "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/tests/draft2020-12/multipleOf.json b/tests/draft2020-12/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft2020-12/multipleOf.json +++ b/tests/draft2020-12/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft2020-12/optional/bignum.json b/tests/draft2020-12/optional/bignum.json index 3f49226a..a0210747 100644 --- a/tests/draft2020-12/optional/bignum.json +++ b/tests/draft2020-12/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -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 } ] }, @@ -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 + } + ] } ] diff --git a/tests/draft2020-12/optional/float-overflow.json b/tests/draft2020-12/optional/float-overflow.json deleted file mode 100644 index 52ff9827..00000000 --- a/tests/draft2020-12/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "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/tests/draft4/multipleOf.json b/tests/draft4/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft4/multipleOf.json +++ b/tests/draft4/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft4/optional/bignum.json b/tests/draft4/optional/bignum.json index 7a622de8..8055fe86 100644 --- a/tests/draft4/optional/bignum.json +++ b/tests/draft4/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -39,42 +59,82 @@ "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": { "maximum": 972783798187987123879878123.18878137, "exclusiveMaximum": true }, "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 } ] }, @@ -86,10 +146,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 + } + ] } ] diff --git a/tests/draft4/optional/float-overflow.json b/tests/draft4/optional/float-overflow.json deleted file mode 100644 index 47fd5baa..00000000 --- a/tests/draft4/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "description": "all integers are multiples of 0.5, if overflow is handled", - "schema": {"type": "number", "multipleOf": 0.5}, - "tests": [ - { - "description": "valid if optional overflow handling is implemented", - "data": 1e308, - "valid": true - } - ] - } -] diff --git a/tests/draft6/multipleOf.json b/tests/draft6/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft6/multipleOf.json +++ b/tests/draft6/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft6/optional/bignum.json b/tests/draft6/optional/bignum.json index 3f49226a..a0210747 100644 --- a/tests/draft6/optional/bignum.json +++ b/tests/draft6/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -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 } ] }, @@ -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 + } + ] } ] diff --git a/tests/draft6/optional/float-overflow.json b/tests/draft6/optional/float-overflow.json deleted file mode 100644 index 52ff9827..00000000 --- a/tests/draft6/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "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/tests/draft7/multipleOf.json b/tests/draft7/multipleOf.json index faa87cff..4a3410ef 100644 --- a/tests/draft7/multipleOf.json +++ b/tests/draft7/multipleOf.json @@ -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", @@ -21,8 +36,39 @@ ] }, { - "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", @@ -30,14 +76,34 @@ "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 } ] }, @@ -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 - } - ] } ] diff --git a/tests/draft7/optional/bignum.json b/tests/draft7/optional/bignum.json index 3f49226a..a0210747 100644 --- a/tests/draft7/optional/bignum.json +++ b/tests/draft7/optional/bignum.json @@ -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 } ] }, @@ -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 } ] }, @@ -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 } ] }, @@ -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 + } + ] } ] diff --git a/tests/draft7/optional/float-overflow.json b/tests/draft7/optional/float-overflow.json deleted file mode 100644 index 52ff9827..00000000 --- a/tests/draft7/optional/float-overflow.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "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 - } - ] - } -]