@@ -57,7 +57,7 @@ describe("equals", () => {
57
57
expect ( a . equals ( b ) ) . toStrictEqual ( true ) ;
58
58
} ) ;
59
59
test ( "take trailing zeroes into account" , ( ) => {
60
- expect ( a . equals ( b , { total : true } ) ) . toStrictEqual ( false ) ;
60
+ expect ( a . equals ( b , { normalize : true } ) ) . toStrictEqual ( false ) ;
61
61
} ) ;
62
62
test ( "mathematically distinct" , ( ) => {
63
63
expect ( a . equals ( c ) ) . toStrictEqual ( false ) ;
@@ -88,12 +88,12 @@ describe("many digits", () => {
88
88
} ) ;
89
89
describe ( "NaN" , ( ) => {
90
90
test ( "NaN equals NaN, even if total is false" , ( ) => {
91
- expect ( nan . equals ( nan ) ) . toStrictEqual ( true ) ;
91
+ expect ( nan . equals ( nan ) ) . toStrictEqual ( false ) ;
92
92
} ) ;
93
93
test ( "NaN does equal NaN, with total comparison" , ( ) => {
94
94
expect (
95
95
nan . equals ( nan , {
96
- total : true ,
96
+ normalize : true ,
97
97
} )
98
98
) . toStrictEqual ( true ) ;
99
99
} ) ;
@@ -103,7 +103,7 @@ describe("many digits", () => {
103
103
test ( "number equals NaN fails, with total comparison" , ( ) => {
104
104
expect (
105
105
one . equals ( nan , {
106
- total : true ,
106
+ normalize : true ,
107
107
} )
108
108
) . toStrictEqual ( false ) ;
109
109
} ) ;
@@ -113,7 +113,7 @@ describe("many digits", () => {
113
113
test ( "NaN equals number is false, with total comparison" , ( ) => {
114
114
expect (
115
115
nan . equals ( one , {
116
- total : true ,
116
+ normalize : true ,
117
117
} )
118
118
) . toStrictEqual ( false ) ;
119
119
} ) ;
@@ -170,10 +170,10 @@ describe("zero", () => {
170
170
expect ( negZero . equals ( zero ) ) . toStrictEqual ( true ) ;
171
171
} ) ;
172
172
test ( "negative zero vs zero, normalization disabled" , ( ) => {
173
- expect ( negZero . equals ( zero , { total : true } ) ) . toStrictEqual ( false ) ;
173
+ expect ( negZero . equals ( zero , { normalize : true } ) ) . toStrictEqual ( false ) ;
174
174
} ) ;
175
175
test ( "zero vs negative zero, normalization disabled" , ( ) => {
176
- expect ( zero . equals ( negZero , { total : true } ) ) . toStrictEqual ( false ) ;
176
+ expect ( zero . equals ( negZero , { normalize : true } ) ) . toStrictEqual ( false ) ;
177
177
} ) ;
178
178
} ) ;
179
179
@@ -191,16 +191,16 @@ describe("normalization", () => {
191
191
expect ( d1 . equals ( d3 ) ) . toStrictEqual ( true ) ;
192
192
} ) ;
193
193
test ( "compare non-normal (1)" , ( ) => {
194
- expect ( d1 . equals ( d2 , { total : true } ) ) . toStrictEqual ( false ) ;
194
+ expect ( d1 . equals ( d2 , { normalize : true } ) ) . toStrictEqual ( false ) ;
195
195
} ) ;
196
196
test ( "compare non-normal (2)" , ( ) => {
197
- expect ( d2 . equals ( d1 , { total : true } ) ) . toStrictEqual ( false ) ;
197
+ expect ( d2 . equals ( d1 , { normalize : true } ) ) . toStrictEqual ( false ) ;
198
198
} ) ;
199
199
test ( "compare two non-normal values" , ( ) => {
200
- expect ( d2 . equals ( d3 , { total : true } ) ) . toStrictEqual ( false ) ;
200
+ expect ( d2 . equals ( d3 , { normalize : true } ) ) . toStrictEqual ( false ) ;
201
201
} ) ;
202
202
test ( "compare two non-normal values" , ( ) => {
203
- expect ( d3 . equals ( d2 , { total : true } ) ) . toStrictEqual ( false ) ;
203
+ expect ( d3 . equals ( d2 , { normalize : true } ) ) . toStrictEqual ( false ) ;
204
204
} ) ;
205
205
} ) ;
206
206
@@ -241,99 +241,99 @@ describe("examples from the General Decimal Arithmetic specification", () => {
241
241
test ( "example one" , ( ) => {
242
242
expect (
243
243
new Decimal128 ( "12.73" ) . equals ( new Decimal128 ( "127.9" ) , {
244
- total : true ,
244
+ normalize : true ,
245
245
} )
246
246
) . toStrictEqual ( false ) ;
247
247
} ) ;
248
248
test ( "example two" , ( ) => {
249
249
expect (
250
250
new Decimal128 ( "-127" ) . equals ( new Decimal128 ( "12" ) , {
251
- total : true ,
251
+ normalize : true ,
252
252
} )
253
253
) . toStrictEqual ( false ) ;
254
254
} ) ;
255
255
test ( "example three" , ( ) => {
256
256
expect (
257
257
new Decimal128 ( "12.30" ) . equals ( new Decimal128 ( "12.3" ) , {
258
- total : true ,
258
+ normalize : true ,
259
259
} )
260
260
) . toStrictEqual ( false ) ;
261
261
} ) ;
262
262
test ( "example four" , ( ) => {
263
263
expect (
264
264
new Decimal128 ( "12.30" ) . equals ( new Decimal128 ( "12.30" ) , {
265
- total : true ,
265
+ normalize : true ,
266
266
} )
267
267
) . toStrictEqual ( true ) ;
268
268
} ) ;
269
269
test ( "example five" , ( ) => {
270
270
expect (
271
271
new Decimal128 ( "12.3" ) . equals ( new Decimal128 ( "12.300" ) , {
272
- total : true ,
272
+ normalize : true ,
273
273
} )
274
274
) . toStrictEqual ( false ) ;
275
275
} ) ;
276
276
test ( "example six" , ( ) => {
277
277
expect (
278
278
new Decimal128 ( "12.3" ) . equals ( new Decimal128 ( "NaN" ) , {
279
- total : true ,
279
+ normalize : true ,
280
280
} )
281
281
) . toStrictEqual ( false ) ;
282
282
} ) ;
283
283
describe ( "inline examples" , ( ) => {
284
284
test ( "example one" , ( ) => {
285
285
expect (
286
286
new Decimal128 ( "-Infinity" ) . equals ( new Decimal128 ( "-127" ) , {
287
- total : true ,
287
+ normalize : true ,
288
288
} )
289
289
) . toStrictEqual ( false ) ;
290
290
} ) ;
291
291
test ( "example two" , ( ) => {
292
292
expect (
293
293
new Decimal128 ( "-1.00" ) . equals ( new Decimal128 ( "-1" ) , {
294
- total : true ,
294
+ normalize : true ,
295
295
} )
296
296
) . toStrictEqual ( false ) ;
297
297
} ) ;
298
298
test ( "example three" , ( ) => {
299
299
expect (
300
300
new Decimal128 ( "-0.000" ) . equals ( negZero , {
301
- total : true ,
301
+ normalize : true ,
302
302
} )
303
303
) . toStrictEqual ( false ) ;
304
304
} ) ;
305
305
test ( "example four" , ( ) => {
306
306
expect (
307
307
negZero . equals ( zero , {
308
- total : true ,
308
+ normalize : true ,
309
309
} )
310
310
) . toStrictEqual ( false ) ;
311
311
} ) ;
312
312
test ( "example five" , ( ) => {
313
313
expect (
314
314
new Decimal128 ( "1.2300" ) . equals ( new Decimal128 ( "1.23" ) , {
315
- total : true ,
315
+ normalize : true ,
316
316
} )
317
317
) . toStrictEqual ( false ) ;
318
318
} ) ;
319
319
test ( "example six" , ( ) => {
320
320
expect (
321
321
new Decimal128 ( "1.23" ) . equals ( new Decimal128 ( "1E+9" ) , {
322
- total : true ,
322
+ normalize : true ,
323
323
} )
324
324
) . toStrictEqual ( false ) ;
325
325
} ) ;
326
326
test ( "example seven" , ( ) => {
327
327
expect (
328
328
new Decimal128 ( "1E+9" ) . equals ( new Decimal128 ( "Infinity" ) , {
329
- total : true ,
329
+ normalize : true ,
330
330
} )
331
331
) . toStrictEqual ( false ) ;
332
332
} ) ;
333
333
test ( "example eight" , ( ) => {
334
334
expect (
335
335
new Decimal128 ( "Infinity" ) . equals ( new Decimal128 ( "NaN" ) , {
336
- total : true ,
336
+ normalize : true ,
337
337
} )
338
338
) . toStrictEqual ( false ) ;
339
339
} ) ;
@@ -345,6 +345,6 @@ describe("examples from a presentation at TC39 plenary", () => {
345
345
test ( "NaN with a payload" , ( ) => {
346
346
expect (
347
347
new Decimal128 ( "NaN" ) . equals ( new Decimal128 ( "NaN123" ) )
348
- ) . toStrictEqual ( true ) ;
348
+ ) . toStrictEqual ( false ) ;
349
349
} ) ;
350
350
} ) ;
0 commit comments