Skip to content

Commit ddf325d

Browse files
add more bignum variations
an implementation might use a different internal representation for 1.0 vs 1, therefore we test both
1 parent 753061d commit ddf325d

File tree

6 files changed

+450
-30
lines changed

6 files changed

+450
-30
lines changed

Diff for: tests/draft-next/optional/bignum.json

+75-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
"description": "a negative bignum is an integer",
1313
"data": -12345678910111213141516171819202122232425262728293031,
1414
"valid": true
15+
},
16+
{
17+
"description": "a bignum is an integer if it has a zero fractional component",
18+
"data": 12345678910111213141516171819202122232425262728293031.0,
19+
"valid": true
20+
},
21+
{
22+
"description": "a negative bignum is an integer if it has a zero fractional component",
23+
"data": -12345678910111213141516171819202122232425262728293031.0,
24+
"valid": true
1525
}
1626
]
1727
},
@@ -28,6 +38,16 @@
2838
"description": "a negative bignum is a number",
2939
"data": -98249283749234923498293171823948729348710298301928331,
3040
"valid": true
41+
},
42+
{
43+
"description": "a bignum with a zero fractional component is a number",
44+
"data": 98249283749234923498293171823948729348710298301928331.0,
45+
"valid": true
46+
},
47+
{
48+
"description": "a negative bignum with a zero fractional component is a number",
49+
"data": -98249283749234923498293171823948729348710298301928331.0,
50+
"valid": true
3151
}
3252
]
3353
},
@@ -39,6 +59,16 @@
3959
"description": "a bignum is not a string",
4060
"data": 98249283749234923498293171823948729348710298301928331,
4161
"valid": false
62+
},
63+
{
64+
"description": "a bignum with zero fractional component is not a string",
65+
"data": 98249283749234923498293171823948729348710298301928331.0,
66+
"valid": false
67+
},
68+
{
69+
"description": "a float bignum is not a string",
70+
"data": 98249283749234923498293171823948729348710298301928331.1,
71+
"valid": false
4272
}
4373
]
4474
},
@@ -47,9 +77,19 @@
4777
"schema": { "maximum": 18446744073709551615 },
4878
"tests": [
4979
{
50-
"description": "comparison works for high numbers",
80+
"description": "comparison works for high integer numbers",
5181
"data": 18446744073709551600,
5282
"valid": true
83+
},
84+
{
85+
"description": "comparison works for high integer floats",
86+
"data": 18446744073709551600.0,
87+
"valid": true
88+
},
89+
{
90+
"description": "comparison works for high non-integer floats",
91+
"data": 18446744073709551600.1,
92+
"valid": true
5393
}
5494
]
5595
},
@@ -60,7 +100,17 @@
60100
},
61101
"tests": [
62102
{
63-
"description": "comparison works for high numbers",
103+
"description": "comparison works for high integers",
104+
"data": 972783798187987123879878123.188781371,
105+
"valid": false
106+
},
107+
{
108+
"description": "comparison works for high float integers",
109+
"data": 972783798187987123879878123.0,
110+
"valid": false
111+
},
112+
{
113+
"description": "comparison works for high non-integer numbers",
64114
"data": 972783798187987123879878123.188781371,
65115
"valid": false
66116
}
@@ -71,9 +121,19 @@
71121
"schema": { "minimum": -18446744073709551615 },
72122
"tests": [
73123
{
74-
"description": "comparison works for very negative numbers",
124+
"description": "comparison works for very negative integers",
75125
"data": -18446744073709551600,
76126
"valid": true
127+
},
128+
{
129+
"description": "comparison works for very negative float integers",
130+
"data": -18446744073709551600.0,
131+
"valid": true
132+
},
133+
{
134+
"description": "comparison works for very negative non-integer numbers",
135+
"data": -18446744073709551600.1,
136+
"valid": true
77137
}
78138
]
79139
},
@@ -84,8 +144,18 @@
84144
},
85145
"tests": [
86146
{
87-
"description": "comparison works for very negative numbers",
88-
"data": -972783798187987123879878123.188781371,
147+
"description": "comparison works for very negative integers",
148+
"data": -972783798187987123879878123,
149+
"valid": false
150+
},
151+
{
152+
"description": "comparison works for very negative float integers",
153+
"data": -972783798187987123879878123.0,
154+
"valid": false
155+
},
156+
{
157+
"description": "comparison works for very negative float non-integers",
158+
"data": -972783798187987123879878123.1234567,
89159
"valid": false
90160
}
91161
]

Diff for: tests/draft2019-09/optional/bignum.json

+75-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
"description": "a negative bignum is an integer",
1313
"data": -12345678910111213141516171819202122232425262728293031,
1414
"valid": true
15+
},
16+
{
17+
"description": "a bignum is an integer if it has a zero fractional component",
18+
"data": 12345678910111213141516171819202122232425262728293031.0,
19+
"valid": true
20+
},
21+
{
22+
"description": "a negative bignum is an integer if it has a zero fractional component",
23+
"data": -12345678910111213141516171819202122232425262728293031.0,
24+
"valid": true
1525
}
1626
]
1727
},
@@ -28,6 +38,16 @@
2838
"description": "a negative bignum is a number",
2939
"data": -98249283749234923498293171823948729348710298301928331,
3040
"valid": true
41+
},
42+
{
43+
"description": "a bignum with a zero fractional component is a number",
44+
"data": 98249283749234923498293171823948729348710298301928331.0,
45+
"valid": true
46+
},
47+
{
48+
"description": "a negative bignum with a zero fractional component is a number",
49+
"data": -98249283749234923498293171823948729348710298301928331.0,
50+
"valid": true
3151
}
3252
]
3353
},
@@ -39,6 +59,16 @@
3959
"description": "a bignum is not a string",
4060
"data": 98249283749234923498293171823948729348710298301928331,
4161
"valid": false
62+
},
63+
{
64+
"description": "a bignum with zero fractional component is not a string",
65+
"data": 98249283749234923498293171823948729348710298301928331.0,
66+
"valid": false
67+
},
68+
{
69+
"description": "a float bignum is not a string",
70+
"data": 98249283749234923498293171823948729348710298301928331.1,
71+
"valid": false
4272
}
4373
]
4474
},
@@ -47,9 +77,19 @@
4777
"schema": { "maximum": 18446744073709551615 },
4878
"tests": [
4979
{
50-
"description": "comparison works for high numbers",
80+
"description": "comparison works for high integer numbers",
5181
"data": 18446744073709551600,
5282
"valid": true
83+
},
84+
{
85+
"description": "comparison works for high integer floats",
86+
"data": 18446744073709551600.0,
87+
"valid": true
88+
},
89+
{
90+
"description": "comparison works for high non-integer floats",
91+
"data": 18446744073709551600.1,
92+
"valid": true
5393
}
5494
]
5595
},
@@ -60,7 +100,17 @@
60100
},
61101
"tests": [
62102
{
63-
"description": "comparison works for high numbers",
103+
"description": "comparison works for high integers",
104+
"data": 972783798187987123879878123.188781371,
105+
"valid": false
106+
},
107+
{
108+
"description": "comparison works for high float integers",
109+
"data": 972783798187987123879878123.0,
110+
"valid": false
111+
},
112+
{
113+
"description": "comparison works for high non-integer numbers",
64114
"data": 972783798187987123879878123.188781371,
65115
"valid": false
66116
}
@@ -71,9 +121,19 @@
71121
"schema": { "minimum": -18446744073709551615 },
72122
"tests": [
73123
{
74-
"description": "comparison works for very negative numbers",
124+
"description": "comparison works for very negative integers",
75125
"data": -18446744073709551600,
76126
"valid": true
127+
},
128+
{
129+
"description": "comparison works for very negative float integers",
130+
"data": -18446744073709551600.0,
131+
"valid": true
132+
},
133+
{
134+
"description": "comparison works for very negative non-integer numbers",
135+
"data": -18446744073709551600.1,
136+
"valid": true
77137
}
78138
]
79139
},
@@ -84,8 +144,18 @@
84144
},
85145
"tests": [
86146
{
87-
"description": "comparison works for very negative numbers",
88-
"data": -972783798187987123879878123.188781371,
147+
"description": "comparison works for very negative integers",
148+
"data": -972783798187987123879878123,
149+
"valid": false
150+
},
151+
{
152+
"description": "comparison works for very negative float integers",
153+
"data": -972783798187987123879878123.0,
154+
"valid": false
155+
},
156+
{
157+
"description": "comparison works for very negative float non-integers",
158+
"data": -972783798187987123879878123.1234567,
89159
"valid": false
90160
}
91161
]

Diff for: tests/draft2020-12/optional/bignum.json

+75-5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212
"description": "a negative bignum is an integer",
1313
"data": -12345678910111213141516171819202122232425262728293031,
1414
"valid": true
15+
},
16+
{
17+
"description": "a bignum is an integer if it has a zero fractional component",
18+
"data": 12345678910111213141516171819202122232425262728293031.0,
19+
"valid": true
20+
},
21+
{
22+
"description": "a negative bignum is an integer if it has a zero fractional component",
23+
"data": -12345678910111213141516171819202122232425262728293031.0,
24+
"valid": true
1525
}
1626
]
1727
},
@@ -28,6 +38,16 @@
2838
"description": "a negative bignum is a number",
2939
"data": -98249283749234923498293171823948729348710298301928331,
3040
"valid": true
41+
},
42+
{
43+
"description": "a bignum with a zero fractional component is a number",
44+
"data": 98249283749234923498293171823948729348710298301928331.0,
45+
"valid": true
46+
},
47+
{
48+
"description": "a negative bignum with a zero fractional component is a number",
49+
"data": -98249283749234923498293171823948729348710298301928331.0,
50+
"valid": true
3151
}
3252
]
3353
},
@@ -39,6 +59,16 @@
3959
"description": "a bignum is not a string",
4060
"data": 98249283749234923498293171823948729348710298301928331,
4161
"valid": false
62+
},
63+
{
64+
"description": "a bignum with zero fractional component is not a string",
65+
"data": 98249283749234923498293171823948729348710298301928331.0,
66+
"valid": false
67+
},
68+
{
69+
"description": "a float bignum is not a string",
70+
"data": 98249283749234923498293171823948729348710298301928331.1,
71+
"valid": false
4272
}
4373
]
4474
},
@@ -47,9 +77,19 @@
4777
"schema": { "maximum": 18446744073709551615 },
4878
"tests": [
4979
{
50-
"description": "comparison works for high numbers",
80+
"description": "comparison works for high integer numbers",
5181
"data": 18446744073709551600,
5282
"valid": true
83+
},
84+
{
85+
"description": "comparison works for high integer floats",
86+
"data": 18446744073709551600.0,
87+
"valid": true
88+
},
89+
{
90+
"description": "comparison works for high non-integer floats",
91+
"data": 18446744073709551600.1,
92+
"valid": true
5393
}
5494
]
5595
},
@@ -60,7 +100,17 @@
60100
},
61101
"tests": [
62102
{
63-
"description": "comparison works for high numbers",
103+
"description": "comparison works for high integers",
104+
"data": 972783798187987123879878123.188781371,
105+
"valid": false
106+
},
107+
{
108+
"description": "comparison works for high float integers",
109+
"data": 972783798187987123879878123.0,
110+
"valid": false
111+
},
112+
{
113+
"description": "comparison works for high non-integer numbers",
64114
"data": 972783798187987123879878123.188781371,
65115
"valid": false
66116
}
@@ -71,9 +121,19 @@
71121
"schema": { "minimum": -18446744073709551615 },
72122
"tests": [
73123
{
74-
"description": "comparison works for very negative numbers",
124+
"description": "comparison works for very negative integers",
75125
"data": -18446744073709551600,
76126
"valid": true
127+
},
128+
{
129+
"description": "comparison works for very negative float integers",
130+
"data": -18446744073709551600.0,
131+
"valid": true
132+
},
133+
{
134+
"description": "comparison works for very negative non-integer numbers",
135+
"data": -18446744073709551600.1,
136+
"valid": true
77137
}
78138
]
79139
},
@@ -84,8 +144,18 @@
84144
},
85145
"tests": [
86146
{
87-
"description": "comparison works for very negative numbers",
88-
"data": -972783798187987123879878123.188781371,
147+
"description": "comparison works for very negative integers",
148+
"data": -972783798187987123879878123,
149+
"valid": false
150+
},
151+
{
152+
"description": "comparison works for very negative float integers",
153+
"data": -972783798187987123879878123.0,
154+
"valid": false
155+
},
156+
{
157+
"description": "comparison works for very negative float non-integers",
158+
"data": -972783798187987123879878123.1234567,
89159
"valid": false
90160
}
91161
]

0 commit comments

Comments
 (0)