@@ -43,37 +43,37 @@ describe("constructor", () => {
43
43
} ) ;
44
44
test ( "five as last digit past limit: tie to even unchanged" , ( ) => {
45
45
expect (
46
- new Decimal128 ( "1234567890123456789012345678901234.5" ) . toString (
47
- { format : "decimal" }
48
- )
46
+ new Decimal128 (
47
+ "1234567890123456789012345678901234.5"
48
+ ) . toString ( )
49
49
) . toStrictEqual ( "1234567890123456789012345678901234" ) ;
50
50
} ) ;
51
51
test ( "five as last digit past limit: tie to even round up" , ( ) => {
52
52
expect (
53
- new Decimal128 ( "1234567890123456789012345678901235.5" ) . toString (
54
- { format : "decimal" }
55
- )
53
+ new Decimal128 (
54
+ "1234567890123456789012345678901235.5"
55
+ ) . toString ( )
56
56
) . toStrictEqual ( "1234567890123456789012345678901236" ) ;
57
57
} ) ;
58
58
test ( "five as last digit past limit: tie to even round up, penultimate digit is 9" , ( ) => {
59
59
expect (
60
- new Decimal128 ( "1234567890123456789012345678901239.5" ) . toString (
61
- { format : "decimal" }
62
- )
60
+ new Decimal128 (
61
+ "1234567890123456789012345678901239.5"
62
+ ) . toString ( )
63
63
) . toStrictEqual ( "1234567890123456789012345678901240" ) ;
64
64
} ) ;
65
65
test ( "five as last digit past limit: tie to even round up, penultimate digit is 9 (negative)" , ( ) => {
66
66
expect (
67
67
new Decimal128 (
68
68
"-1234567890123456789012345678901239.5"
69
- ) . toString ( { format : "decimal" } )
69
+ ) . toString ( )
70
70
) . toStrictEqual ( "-1234567890123456789012345678901240" ) ;
71
71
} ) ;
72
72
test ( "round up decimal digit is not nine" , ( ) => {
73
73
expect (
74
- new Decimal128 ( "1234567890123456789012345678901239.8" ) . toString (
75
- { format : "decimal" }
76
- )
74
+ new Decimal128 (
75
+ "1234567890123456789012345678901239.8"
76
+ ) . toString ( )
77
77
) . toStrictEqual ( "1234567890123456789012345678901240" ) ;
78
78
} ) ;
79
79
test ( "empty string not OK" , ( ) => {
@@ -110,35 +110,29 @@ describe("constructor", () => {
110
110
expect (
111
111
new Decimal128 (
112
112
"0.3666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666667"
113
- ) . toString ( { format : "decimal" } )
113
+ ) . toString ( )
114
114
) . toStrictEqual ( "0.3666666666666666666666666666666667" ) ;
115
115
} ) ;
116
116
test ( "close to one, too many digits, gets rounded to 1.000..." , ( ) => {
117
117
expect (
118
- new Decimal128 ( "0." + "9" . repeat ( 100 ) ) . toString ( {
119
- format : "decimal" ,
120
- } )
118
+ new Decimal128 ( "0." + "9" . repeat ( 100 ) ) . toString ( )
121
119
) . toStrictEqual ( "1" ) ;
122
120
} ) ;
123
121
test ( "lots of digits gets rounded to minus 1" , ( ) => {
124
122
expect (
125
- new Decimal128 ( "-0." + "9" . repeat ( 100 ) ) . toString ( {
126
- format : "decimal" ,
127
- } )
123
+ new Decimal128 ( "-0." + "9" . repeat ( 100 ) ) . toString ( )
128
124
) . toStrictEqual ( "-1" ) ;
129
125
} ) ;
130
126
test ( "lots of digits gets rounded to 10" , ( ) => {
131
127
expect (
132
- new Decimal128 ( "9." + "9" . repeat ( 100 ) ) . toString ( {
133
- format : "decimal" ,
134
- } )
128
+ new Decimal128 ( "9." + "9" . repeat ( 100 ) ) . toString ( )
135
129
) . toStrictEqual ( "10" ) ;
136
130
} ) ;
137
131
test ( "rounding at the limit of significant digits" , ( ) => {
138
132
expect (
139
133
new Decimal128 (
140
134
"0." + "1" . repeat ( MAX_SIGNIFICANT_DIGITS ) + "9"
141
- ) . toString ( { format : "decimal" } )
135
+ ) . toString ( )
142
136
) . toStrictEqual (
143
137
"0." + "1" . repeat ( MAX_SIGNIFICANT_DIGITS - 1 ) + "2"
144
138
) ;
@@ -147,46 +141,32 @@ describe("constructor", () => {
147
141
expect (
148
142
new Decimal128 (
149
143
"0." + "1" . repeat ( MAX_SIGNIFICANT_DIGITS + 100 ) + "9"
150
- ) . toString ( { format : "decimal" } )
144
+ ) . toString ( )
151
145
) . toStrictEqual ( "0." + "1" . repeat ( MAX_SIGNIFICANT_DIGITS ) ) ;
152
146
} ) ;
153
147
test ( "minus zero" , ( ) => {
154
148
let minusZero = new Decimal128 ( "-0" ) ;
155
- expect ( minusZero . toString ( { format : "decimal" } ) ) . toStrictEqual (
156
- "-0"
157
- ) ;
149
+ expect ( minusZero . toString ( ) ) . toStrictEqual ( "-0" ) ;
158
150
expect ( minusZero . isNegative ( ) ) . toStrictEqual ( true ) ;
159
151
} ) ;
160
152
describe ( "zeros" , ( ) => {
161
153
test ( "leading zeros get stripped" , ( ) => {
162
- expect (
163
- new Decimal128 ( "00" ) . toString ( { format : "decimal" } )
164
- ) . toStrictEqual ( "0" ) ;
154
+ expect ( new Decimal128 ( "00" ) . toString ( ) ) . toStrictEqual ( "0" ) ;
165
155
} ) ;
166
156
test ( "leading zeros get stripped (negative)" , ( ) => {
167
- expect (
168
- new Decimal128 ( "-00" ) . toString ( { format : "decimal" } )
169
- ) . toStrictEqual ( "-0" ) ;
157
+ expect ( new Decimal128 ( "-00" ) . toString ( ) ) . toStrictEqual ( "-0" ) ;
170
158
} ) ;
171
159
test ( "zero point zero" , ( ) => {
172
- expect (
173
- new Decimal128 ( "0.0" ) . toString ( { format : "decimal" } )
174
- ) . toStrictEqual ( "0" ) ;
160
+ expect ( new Decimal128 ( "0.0" ) . toString ( ) ) . toStrictEqual ( "0" ) ;
175
161
} ) ;
176
162
test ( "minus zero point zero" , ( ) => {
177
- expect (
178
- new Decimal128 ( "-0.0" ) . toString ( { format : "decimal" } )
179
- ) . toStrictEqual ( "-0" ) ;
163
+ expect ( new Decimal128 ( "-0.0" ) . toString ( ) ) . toStrictEqual ( "-0" ) ;
180
164
} ) ;
181
165
test ( "multiple trailing zeros" , ( ) => {
182
- expect (
183
- new Decimal128 ( "0.000" ) . toString ( { format : "decimal" } )
184
- ) . toStrictEqual ( "0" ) ;
166
+ expect ( new Decimal128 ( "0.000" ) . toString ( ) ) . toStrictEqual ( "0" ) ;
185
167
} ) ;
186
168
test ( "multiple trailing zeros (negative)" , ( ) => {
187
- expect (
188
- new Decimal128 ( "-0.000" ) . toString ( { format : "decimal" } )
189
- ) . toStrictEqual ( "-0" ) ;
169
+ expect ( new Decimal128 ( "-0.000" ) . toString ( ) ) . toStrictEqual ( "-0" ) ;
190
170
} ) ;
191
171
} ) ;
192
172
} ) ;
@@ -285,44 +265,30 @@ describe("infinity", () => {
285
265
describe ( "General Decimal Arithmetic specification" , ( ) => {
286
266
describe ( "decimal syntax" , ( ) => {
287
267
test ( "0" , ( ) => {
288
- expect (
289
- new Decimal128 ( "0" ) . toString ( { format : "decimal" } )
290
- ) . toStrictEqual ( "0" ) ;
268
+ expect ( new Decimal128 ( "0" ) . toString ( ) ) . toStrictEqual ( "0" ) ;
291
269
} ) ;
292
270
test ( "12" , ( ) => {
293
- expect (
294
- new Decimal128 ( "12" ) . toString ( { format : "decimal" } )
295
- ) . toStrictEqual ( "12" ) ;
271
+ expect ( new Decimal128 ( "12" ) . toString ( ) ) . toStrictEqual ( "12" ) ;
296
272
} ) ;
297
273
test ( "-76" , ( ) => {
298
- expect (
299
- new Decimal128 ( "-76" ) . toString ( { format : "decimal" } )
300
- ) . toStrictEqual ( "-76" ) ;
274
+ expect ( new Decimal128 ( "-76" ) . toString ( ) ) . toStrictEqual ( "-76" ) ;
301
275
} ) ;
302
276
test ( "12.70" , ( ) => {
303
- expect (
304
- new Decimal128 ( "12.70" ) . toString ( { format : "decimal" } )
305
- ) . toStrictEqual ( "12.7" ) ;
277
+ expect ( new Decimal128 ( "12.70" ) . toString ( ) ) . toStrictEqual ( "12.7" ) ;
306
278
} ) ;
307
279
test ( "+0.003" , ( ) => {
308
- expect (
309
- new Decimal128 ( "+0.003" ) . toString ( { format : "decimal" } )
310
- ) . toStrictEqual ( "0.003" ) ;
280
+ expect ( new Decimal128 ( "+0.003" ) . toString ( ) ) . toStrictEqual ( "0.003" ) ;
311
281
} ) ;
312
282
test ( "017." , ( ) => {
313
- expect (
314
- new Decimal128 ( "017." ) . toString ( { format : "decimal" } )
315
- ) . toStrictEqual ( "17" ) ;
283
+ expect ( new Decimal128 ( "017." ) . toString ( ) ) . toStrictEqual ( "17" ) ;
316
284
} ) ;
317
285
test ( ".5" , ( ) => {
318
- expect (
319
- new Decimal128 ( ".5" ) . toString ( { format : "decimal" } )
320
- ) . toStrictEqual ( "0.5" ) ;
286
+ expect ( new Decimal128 ( ".5" ) . toString ( ) ) . toStrictEqual ( "0.5" ) ;
321
287
} ) ;
322
288
test ( "4E+9" , ( ) => {
323
- expect (
324
- new Decimal128 ( "4E+9" ) . toString ( { format : "decimal" } )
325
- ) . toStrictEqual ( "4000000000" ) ;
289
+ expect ( new Decimal128 ( "4E+9" ) . toString ( ) ) . toStrictEqual (
290
+ "4000000000"
291
+ ) ;
326
292
} ) ;
327
293
test ( "Inf" , ( ) => {
328
294
expect ( ( ) => new Decimal128 ( "Inf" ) ) . toThrow ( SyntaxError ) ;
@@ -331,9 +297,7 @@ describe("General Decimal Arithmetic specification", () => {
331
297
expect ( ( ) => new Decimal128 ( "-infinity" ) ) . toThrow ( SyntaxError ) ;
332
298
} ) ;
333
299
test ( "NaN" , ( ) => {
334
- expect (
335
- new Decimal128 ( "NaN" ) . toString ( { format : "decimal" } )
336
- ) . toStrictEqual ( "NaN" ) ;
300
+ expect ( new Decimal128 ( "NaN" ) . toString ( ) ) . toStrictEqual ( "NaN" ) ;
337
301
} ) ;
338
302
test ( "NaN8275 (diagnostic information discarded)" , ( ) => {
339
303
expect ( ( ) => new Decimal128 ( "NaN8275" ) ) . toThrow ( SyntaxError ) ;
@@ -358,39 +322,27 @@ describe("General Decimal Arithmetic specification", () => {
358
322
359
323
describe ( "number arguments" , ( ) => {
360
324
test ( "integer" , ( ) => {
361
- expect (
362
- new Decimal128 ( 42 ) . toString ( { format : "decimal" } )
363
- ) . toStrictEqual ( "42" ) ;
325
+ expect ( new Decimal128 ( 42 ) . toString ( ) ) . toStrictEqual ( "42" ) ;
364
326
} ) ;
365
327
test ( "non-integer number" , ( ) => {
366
- expect (
367
- new Decimal128 ( 42.5 ) . toString ( { format : "decimal" } )
368
- ) . toStrictEqual ( "42.5" ) ;
328
+ expect ( new Decimal128 ( 42.5 ) . toString ( ) ) . toStrictEqual ( "42.5" ) ;
369
329
} ) ;
370
330
test ( "NaN" , ( ) => {
371
- expect (
372
- new Decimal128 ( NaN ) . toString ( { format : "decimal" } )
373
- ) . toStrictEqual ( "NaN" ) ;
331
+ expect ( new Decimal128 ( NaN ) . toString ( ) ) . toStrictEqual ( "NaN" ) ;
374
332
} ) ;
375
333
test ( "minus zero" , ( ) => {
376
- expect (
377
- new Decimal128 ( - 0 ) . toString ( { format : "decimal" } )
378
- ) . toStrictEqual ( "-0" ) ;
334
+ expect ( new Decimal128 ( - 0 ) . toString ( ) ) . toStrictEqual ( "-0" ) ;
379
335
} ) ;
380
336
test ( "very large value gets approximated" , ( ) => {
381
337
expect (
382
- new Decimal128 ( 123456789012345678901234567890123456789 ) . toString ( {
383
- format : "decimal" ,
384
- } )
338
+ new Decimal128 ( 123456789012345678901234567890123456789 ) . toString ( )
385
339
) . toStrictEqual ( "123456789012345680000000000000000000000" ) ;
386
340
} ) ;
387
341
} ) ;
388
342
389
343
describe ( "bigint" , ( ) => {
390
344
test ( "simple" , ( ) => {
391
- expect (
392
- new Decimal128 ( 42n ) . toString ( { format : "decimal" } )
393
- ) . toStrictEqual ( "42" ) ;
345
+ expect ( new Decimal128 ( 42n ) . toString ( ) ) . toStrictEqual ( "42" ) ;
394
346
} ) ;
395
347
test ( "too big" , ( ) => {
396
348
expect (
0 commit comments