Skip to content

Commit ea81e51

Browse files
committed
Add boundary cases for integers
1 parent f164982 commit ea81e51

File tree

7 files changed

+262
-7
lines changed

7 files changed

+262
-7
lines changed

tests/draft-next/type.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,48 @@
1111
"data": 1,
1212
"valid": true
1313
},
14+
{
15+
"description": "a negative integer is an integer",
16+
"data": -1,
17+
"valid": true
18+
},
19+
{
20+
"description": "zero is an integer",
21+
"data": 0,
22+
"valid": true
23+
},
24+
{
25+
"description": "negative zero is an integer",
26+
"data": -0,
27+
"valid": true
28+
},
1429
{
1530
"description": "a float with zero fractional part is an integer",
1631
"data": 1.0,
1732
"valid": true
1833
},
1934
{
20-
"description": "a float is not an integer",
35+
"description": "a float with an exponent and a zero fractional part is an integer",
36+
"data": 1e0,
37+
"valid": true
38+
},
39+
{
40+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
41+
"data": 1.00000000000001,
42+
"valid": true
43+
},
44+
{
45+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
46+
"data": 9007199254740991.5,
47+
"valid": true
48+
},
49+
{
50+
"description": "a number near the maximum representable value for a binary64 float is an integer",
51+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
52+
"valid": true
53+
},
54+
{
55+
"description": "a float with a non-zero fractional part is not an integer",
2156
"data": 1.1,
2257
"valid": false
2358
},

tests/draft2019-09/type.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,48 @@
1111
"data": 1,
1212
"valid": true
1313
},
14+
{
15+
"description": "a negative integer is an integer",
16+
"data": -1,
17+
"valid": true
18+
},
19+
{
20+
"description": "zero is an integer",
21+
"data": 0,
22+
"valid": true
23+
},
24+
{
25+
"description": "negative zero is an integer",
26+
"data": -0,
27+
"valid": true
28+
},
1429
{
1530
"description": "a float with zero fractional part is an integer",
1631
"data": 1.0,
1732
"valid": true
1833
},
1934
{
20-
"description": "a float is not an integer",
35+
"description": "a float with an exponent and a zero fractional part is an integer",
36+
"data": 1e0,
37+
"valid": true
38+
},
39+
{
40+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
41+
"data": 1.00000000000001,
42+
"valid": true
43+
},
44+
{
45+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
46+
"data": 9007199254740991.5,
47+
"valid": true
48+
},
49+
{
50+
"description": "a number near the maximum representable value for a binary64 float is an integer",
51+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
52+
"valid": true
53+
},
54+
{
55+
"description": "a float with a non-zero fractional part is not an integer",
2156
"data": 1.1,
2257
"valid": false
2358
},

tests/draft2020-12/type.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,48 @@
1111
"data": 1,
1212
"valid": true
1313
},
14+
{
15+
"description": "a negative integer is an integer",
16+
"data": -1,
17+
"valid": true
18+
},
19+
{
20+
"description": "zero is an integer",
21+
"data": 0,
22+
"valid": true
23+
},
24+
{
25+
"description": "negative zero is an integer",
26+
"data": -0,
27+
"valid": true
28+
},
1429
{
1530
"description": "a float with zero fractional part is an integer",
1631
"data": 1.0,
1732
"valid": true
1833
},
1934
{
20-
"description": "a float is not an integer",
35+
"description": "a float with an exponent and a zero fractional part is an integer",
36+
"data": 1e0,
37+
"valid": true
38+
},
39+
{
40+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
41+
"data": 1.00000000000001,
42+
"valid": true
43+
},
44+
{
45+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
46+
"data": 9007199254740991.5,
47+
"valid": true
48+
},
49+
{
50+
"description": "a number near the maximum representable value for a binary64 float is an integer",
51+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
52+
"valid": true
53+
},
54+
{
55+
"description": "a float with a non-zero fractional part is not an integer",
2156
"data": 1.1,
2257
"valid": false
2358
},

tests/draft3/type.json

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,47 @@
99
"valid": true
1010
},
1111
{
12-
"description": "a float is not an integer",
12+
"description": "a negative integer is an integer",
13+
"data": -1,
14+
"valid": true
15+
},
16+
{
17+
"description": "zero is an integer",
18+
"data": 0,
19+
"valid": true
20+
},
21+
{
22+
"description": "negative zero is an integer",
23+
"data": -0,
24+
"valid": true
25+
},
26+
{
27+
"description": "a float with zero fractional part is an integer",
28+
"data": 1.0,
29+
"valid": true
30+
},
31+
{
32+
"description": "a float with an exponent and a zero fractional part is an integer",
33+
"data": 1e0,
34+
"valid": true
35+
},
36+
{
37+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
38+
"data": 1.00000000000001,
39+
"valid": true
40+
},
41+
{
42+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
43+
"data": 9007199254740991.5,
44+
"valid": true
45+
},
46+
{
47+
"description": "a number near the maximum representable value for a binary64 float is an integer",
48+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
49+
"valid": true
50+
},
51+
{
52+
"description": "a float with a non-zero fractional part is not an integer",
1353
"data": 1.1,
1454
"valid": false
1555
},

tests/draft4/type.json

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,47 @@
99
"valid": true
1010
},
1111
{
12-
"description": "a float is not an integer",
12+
"description": "a negative integer is an integer",
13+
"data": -1,
14+
"valid": true
15+
},
16+
{
17+
"description": "zero is an integer",
18+
"data": 0,
19+
"valid": true
20+
},
21+
{
22+
"description": "negative zero is an integer",
23+
"data": -0,
24+
"valid": true
25+
},
26+
{
27+
"description": "a float with zero fractional part is an integer",
28+
"data": 1.0,
29+
"valid": true
30+
},
31+
{
32+
"description": "a float with an exponent and a zero fractional part is an integer",
33+
"data": 1e0,
34+
"valid": true
35+
},
36+
{
37+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
38+
"data": 1.00000000000001,
39+
"valid": true
40+
},
41+
{
42+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
43+
"data": 9007199254740991.5,
44+
"valid": true
45+
},
46+
{
47+
"description": "a number near the maximum representable value for a binary64 float is an integer",
48+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
49+
"valid": true
50+
},
51+
{
52+
"description": "a float with a non-zero fractional part is not an integer",
1353
"data": 1.1,
1454
"valid": false
1555
},

tests/draft6/type.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,48 @@
88
"data": 1,
99
"valid": true
1010
},
11+
{
12+
"description": "a negative integer is an integer",
13+
"data": -1,
14+
"valid": true
15+
},
16+
{
17+
"description": "zero is an integer",
18+
"data": 0,
19+
"valid": true
20+
},
21+
{
22+
"description": "negative zero is an integer",
23+
"data": -0,
24+
"valid": true
25+
},
1126
{
1227
"description": "a float with zero fractional part is an integer",
1328
"data": 1.0,
1429
"valid": true
1530
},
1631
{
17-
"description": "a float is not an integer",
32+
"description": "a float with an exponent and a zero fractional part is an integer",
33+
"data": 1e0,
34+
"valid": true
35+
},
36+
{
37+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
38+
"data": 1.00000000000001,
39+
"valid": true
40+
},
41+
{
42+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
43+
"data": 9007199254740991.5,
44+
"valid": true
45+
},
46+
{
47+
"description": "a number near the maximum representable value for a binary64 float is an integer",
48+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
49+
"valid": true
50+
},
51+
{
52+
"description": "a float with a non-zero fractional part is not an integer",
1853
"data": 1.1,
1954
"valid": false
2055
},

tests/draft7/type.json

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,48 @@
88
"data": 1,
99
"valid": true
1010
},
11+
{
12+
"description": "a negative integer is an integer",
13+
"data": -1,
14+
"valid": true
15+
},
16+
{
17+
"description": "zero is an integer",
18+
"data": 0,
19+
"valid": true
20+
},
21+
{
22+
"description": "negative zero is an integer",
23+
"data": -0,
24+
"valid": true
25+
},
1126
{
1227
"description": "a float with zero fractional part is an integer",
1328
"data": 1.0,
1429
"valid": true
1530
},
1631
{
17-
"description": "a float is not an integer",
32+
"description": "a float with an exponent and a zero fractional part is an integer",
33+
"data": 1e0,
34+
"valid": true
35+
},
36+
{
37+
"description": "a small float whose non-zero fractional part is truncated in a binary64 float is an integer",
38+
"data": 1.00000000000001,
39+
"valid": true
40+
},
41+
{
42+
"description": "a large float whose non-zero fractional part is truncated in a binary64 float is an integer",
43+
"data": 9007199254740991.5,
44+
"valid": true
45+
},
46+
{
47+
"description": "a number near the maximum representable value for a binary64 float is an integer",
48+
"data": 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368,
49+
"valid": true
50+
},
51+
{
52+
"description": "a float with a non-zero fractional part is not an integer",
1853
"data": 1.1,
1954
"valid": false
2055
},

0 commit comments

Comments
 (0)