diff options
author | 2022-11-27 19:37:14 -0800 | |
---|---|---|
committer | 2022-11-27 19:37:14 -0800 | |
commit | 002f4ecc9e0dfb19ea9e5032b812b9b976706995 (patch) | |
tree | 34fae197918c8064d456a855b987c0b8bd36dc03 /test/bun.js/inspect.test.js | |
parent | 495f25501f7bcfddec6e91cca7815cc6220fb53e (diff) | |
download | bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.tar.gz bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.tar.zst bun-002f4ecc9e0dfb19ea9e5032b812b9b976706995.zip |
Fix crash in console.log
Diffstat (limited to 'test/bun.js/inspect.test.js')
-rw-r--r-- | test/bun.js/inspect.test.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/bun.js/inspect.test.js b/test/bun.js/inspect.test.js index 3646b3706..5dc0bc645 100644 --- a/test/bun.js/inspect.test.js +++ b/test/bun.js/inspect.test.js @@ -273,3 +273,51 @@ describe("latin1 supplemental", () => { // }); } }); + +const fixture = [ + () => Bun.file("/tmp/log.txt").stream(), + () => Bun.file("/tmp/log.1.txt").stream().getReader(), + () => Bun.file("/tmp/log.2.txt").writer(), + () => + new WritableStream({ + write(chunk) {}, + }), + () => require("events"), + () => { + return new import.meta.require("events").EventEmitter(); + }, + async () => await import("node:assert"), + async () => await import("./empty.js"), + () => import.meta.require("./empty.js"), + () => new Proxy({ yolo: 1 }, {}), + () => + new Proxy( + { yolo: 1 }, + { + get(target, prop) { + return prop + "!"; + }, + has(target, prop) { + return true; + }, + ownKeys() { + return ["foo"]; + }, + }, + ), +]; + +describe("crash testing", () => { + for (let input of fixture) { + it(`inspecting "${input + .toString() + .slice(0, 20) + .replaceAll("\n", "\\n")}" doesn't crash`, async () => { + try { + Bun.inspect(await input()); + } catch (e) { + // this can throw its fine + } + }); + } +}); |