diff options
Diffstat (limited to 'test/bun.js/fs.test.js')
-rw-r--r-- | test/bun.js/fs.test.js | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/test/bun.js/fs.test.js b/test/bun.js/fs.test.js index ac2357143..058a40828 100644 --- a/test/bun.js/fs.test.js +++ b/test/bun.js/fs.test.js @@ -548,7 +548,9 @@ describe("fs/promises", () => { const { readFile, stat, writeFile } = promises; it("should not segfault on exception", async () => { - stat("foo/bar"); + try { + await stat("foo/bar"); + } catch (e) {} }); it("readFile", async () => { @@ -561,4 +563,30 @@ describe("fs/promises", () => { await writeFile(path, "File written successfully"); expect(readFileSync(path, "utf8")).toBe("File written successfully"); }); + + it("readdir()", async () => { + const files = await promises.readdir(import.meta.dir); + expect(files.length).toBeGreaterThan(0); + }); + + it("readdir() no args doesnt segfault", async () => { + const fizz = [ + [], + [Symbol("ok")], + [Symbol("ok"), Symbol("ok")], + [Symbol("ok"), Symbol("ok"), Symbol("ok")], + [Infinity, -NaN, -Infinity], + "\0\0\0\0", + "\r\n", + ]; + for (const args of fizz) { + try { + // check it doens't segfault when called with invalid arguments + await promises.readdir(...args); + } catch (e) { + // check that producing the error doesn't cause any crashes + Bun.inspect(e); + } + } + }); }); |