mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
console.table bugfix (#10876)
This commit is contained in:
@@ -359,12 +359,17 @@ const TablePrinter = struct {
|
||||
// find or create the column for the property
|
||||
const column: *Column = brk: {
|
||||
const col_str = String.init(col_key);
|
||||
|
||||
for (columns.items[1..]) |*col| {
|
||||
if (col.name.eql(col_str)) {
|
||||
break :brk col;
|
||||
}
|
||||
}
|
||||
|
||||
// Need to ref this string because JSPropertyIterator
|
||||
// uses `toString` instead of `toStringRef` for property names
|
||||
col_str.ref();
|
||||
|
||||
try columns.append(.{ .name = col_str });
|
||||
|
||||
break :brk &columns.items[columns.items.len - 1];
|
||||
|
||||
3
test/js/bun/console/console-table-repeat-50.ts
Normal file
3
test/js/bun/console/console-table-repeat-50.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
for (let i = 0; i < 50; i++) {
|
||||
console.table([{ n: 8 }]);
|
||||
}
|
||||
@@ -214,3 +214,21 @@ test.skip("console.table character widths", () => {
|
||||
|
||||
console.log(actualOutput);
|
||||
});
|
||||
|
||||
test("console.table repeat 50", () => {
|
||||
const expected = `┌───┬───┐
|
||||
│ │ n │
|
||||
├───┼───┤
|
||||
│ 0 │ 8 │
|
||||
└───┴───┘
|
||||
`;
|
||||
const { stdout, stderr } = spawnSync({
|
||||
cmd: [bunExe(), `${import.meta.dir}/console-table-repeat-50.ts`],
|
||||
stdout: "pipe",
|
||||
stderr: "pipe",
|
||||
env: bunEnv,
|
||||
});
|
||||
|
||||
expect(stdout.toString()).toBe(expected.repeat(50));
|
||||
expect(stderr.toString()).toBe("");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user