aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/inspect.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/bun.js/inspect.test.js')
-rw-r--r--test/bun.js/inspect.test.js48
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
+ }
+ });
+ }
+});