diff options
author | 2023-08-18 19:59:03 -0700 | |
---|---|---|
committer | 2023-08-18 19:59:03 -0700 | |
commit | 26036a390b71e079e31694d2dcf64572e30db74f (patch) | |
tree | 615d509d8253c2bc3418b93b61531cfee83ca71e /test | |
parent | 943a6642243cbc8a180ab7108279dd7110ab1eaf (diff) | |
download | bun-26036a390b71e079e31694d2dcf64572e30db74f.tar.gz bun-26036a390b71e079e31694d2dcf64572e30db74f.tar.zst bun-26036a390b71e079e31694d2dcf64572e30db74f.zip |
Implement BigIntStats (#4208)
* Implement BigIntStats
* changes
* rename test
* comment
* test changes?
Diffstat (limited to 'test')
-rw-r--r-- | test/js/node/fs/fs.test.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/js/node/fs/fs.test.ts b/test/js/node/fs/fs.test.ts index 064336865..58fb455fc 100644 --- a/test/js/node/fs/fs.test.ts +++ b/test/js/node/fs/fs.test.ts @@ -1833,3 +1833,38 @@ it("new Stats", () => { expect(stats.ctime).toEqual(new Date(13)); expect(stats.birthtime).toEqual(new Date(14)); }); + +it("BigIntStats", () => { + const withoutBigInt = statSync(__filename, { bigint: false }); + const withBigInt = statSync(__filename, { bigint: true }); + + expect(withoutBigInt.isFile() === withBigInt.isFile()).toBe(true); + expect(withoutBigInt.isDirectory() === withBigInt.isDirectory()).toBe(true); + expect(withoutBigInt.isBlockDevice() === withBigInt.isBlockDevice()).toBe(true); + expect(withoutBigInt.isCharacterDevice() === withBigInt.isCharacterDevice()).toBe(true); + expect(withoutBigInt.isSymbolicLink() === withBigInt.isSymbolicLink()).toBe(true); + expect(withoutBigInt.isFIFO() === withBigInt.isFIFO()).toBe(true); + expect(withoutBigInt.isSocket() === withBigInt.isSocket()).toBe(true); + + const expectclose = (a: bigint, b: bigint) => expect(Math.abs(Number(a - b))).toBeLessThan(1000); + + expectclose(BigInt(withoutBigInt.dev), withBigInt.dev); + expectclose(BigInt(withoutBigInt.ino), withBigInt.ino); + expectclose(BigInt(withoutBigInt.mode), withBigInt.mode); + expectclose(BigInt(withoutBigInt.nlink), withBigInt.nlink); + expectclose(BigInt(withoutBigInt.uid), withBigInt.uid); + expectclose(BigInt(withoutBigInt.gid), withBigInt.gid); + expectclose(BigInt(withoutBigInt.rdev), withBigInt.rdev); + expectclose(BigInt(withoutBigInt.size), withBigInt.size); + expectclose(BigInt(withoutBigInt.blksize), withBigInt.blksize); + expectclose(BigInt(withoutBigInt.blocks), withBigInt.blocks); + expectclose(BigInt(Math.floor(withoutBigInt.atimeMs)), withBigInt.atimeMs); + expectclose(BigInt(Math.floor(withoutBigInt.mtimeMs)), withBigInt.mtimeMs); + expectclose(BigInt(Math.floor(withoutBigInt.ctimeMs)), withBigInt.ctimeMs); + expectclose(BigInt(Math.floor(withoutBigInt.birthtimeMs)), withBigInt.birthtimeMs); + + expect(withBigInt.atime.getTime()).toEqual(withoutBigInt.atime.getTime()); + expect(withBigInt.mtime.getTime()).toEqual(withoutBigInt.mtime.getTime()); + expect(withBigInt.ctime.getTime()).toEqual(withoutBigInt.ctime.getTime()); + expect(withBigInt.birthtime.getTime()).toEqual(withoutBigInt.birthtime.getTime()); +}); |