mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
fix formatting of Set in Bun.inspect() (#16013)
This commit is contained in:
@@ -2728,10 +2728,6 @@ pub const Formatter = struct {
|
||||
this.quote_strings = true;
|
||||
defer this.quote_strings = prev_quote_strings;
|
||||
|
||||
if (!this.single_line) {
|
||||
this.writeIndent(Writer, writer_) catch {};
|
||||
}
|
||||
|
||||
const set_name = if (value.jsType() == .WeakSet) "WeakSet" else "Set";
|
||||
|
||||
if (length == 0) {
|
||||
@@ -2762,7 +2758,7 @@ pub const Formatter = struct {
|
||||
},
|
||||
}
|
||||
}
|
||||
if (this.single_line) {
|
||||
if (!this.single_line) {
|
||||
this.writeIndent(Writer, writer_) catch {};
|
||||
}
|
||||
writer.writeAll("}");
|
||||
|
||||
12
test/regression/issue/16007.test.ts
Normal file
12
test/regression/issue/16007.test.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { it, expect } from "bun:test";
|
||||
|
||||
it("Set is propperly formatted in Bun.inspect()", () => {
|
||||
const set = new Set(["foo", "bar"]);
|
||||
const formatted = Bun.inspect({ set });
|
||||
expect(formatted).toBe(`{
|
||||
set: Set(2) {
|
||||
"foo",
|
||||
"bar",
|
||||
},
|
||||
}`);
|
||||
});
|
||||
Reference in New Issue
Block a user