mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
* feat: use trailing commas when printing multi-line objects * test: update console-log.expected.txt to include trailing commas * test: update a couple tests to match new object output with trailing commas * [autofix.ci] apply automated fixes --------- Co-authored-by: Alex See <alexsee@Alexs-MacBook-Air.local> Co-authored-by: dave caruso <me@paperdave.net> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
24 lines
842 B
TypeScript
24 lines
842 B
TypeScript
import { describe, it, expect } from "bun:test";
|
|
|
|
describe("Bun.inspect", () => {
|
|
it("depth < 0 throws", () => {
|
|
expect(() => Bun.inspect({}, { depth: -1 })).toThrow();
|
|
expect(() => Bun.inspect({}, { depth: -13210 })).toThrow();
|
|
});
|
|
it("depth = Infinity works", () => {
|
|
function createRecursiveObject(n: number): any {
|
|
if (n === 0) return { hi: true };
|
|
return { a: createRecursiveObject(n - 1) };
|
|
}
|
|
|
|
const obj = createRecursiveObject(1000);
|
|
|
|
expect(Bun.inspect(obj, { depth: Infinity })).toContain("hi");
|
|
// this gets converted to u16, which if just truncating, will turn into 0
|
|
expect(Bun.inspect(obj, { depth: 0x0fff0000 })).toContain("hi");
|
|
});
|
|
it("depth = 0", () => {
|
|
expect(Bun.inspect({ a: { b: { c: { d: 1 } } } }, { depth: 0 })).toEqual("{\n a: [Object ...],\n}");
|
|
});
|
|
});
|