Skip to content

Commit 06464c9

Browse files
committed
improve json
1 parent a770fb3 commit 06464c9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/tools/runner/config.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import * as url from 'url';
99

1010
import {
1111
type AuthMechanism,
12+
Double,
1213
HostAddress,
1314
Long,
1415
MongoClient,
@@ -475,8 +476,13 @@ export class TestConfiguration {
475476
if (types.isMap(value)) return { Map: Array.from(value.entries()) };
476477
if (types.isSet(value)) return { Set: Array.from(value.values()) };
477478
if (types.isNativeError(value)) return { [value.name]: util.inspect(value) };
478-
if (typeof value === 'bigint') return new Long(value).toExtendedJSON();
479+
if (typeof value === 'bigint') return { bigint: new Long(value).toExtendedJSON() };
479480
if (typeof value === 'symbol') return `Symbol(${value.description})`;
481+
if (typeof value === 'number') {
482+
if (Number.isNaN(value) || !Number.isFinite(value) || Object.is(value, -0))
483+
// @ts-expect-error: toExtendedJSON internal on double but not on long
484+
return { number: new Double(value).toExtendedJSON() };
485+
}
480486
if (Buffer.isBuffer(value))
481487
return { [value.constructor.name]: Buffer.prototype.base64Slice.call(value) };
482488
if (value === undefined) return { undefined: 'key was set but equal to undefined' };

0 commit comments

Comments
 (0)