diff options
author | 2023-02-22 19:25:17 -0800 | |
---|---|---|
committer | 2023-02-22 19:25:17 -0800 | |
commit | 9c5f02e120bbfe76b45d036db3544cf47cf1354f (patch) | |
tree | d9bb7d8da8531b46ae042dcdda5993a118823230 /src | |
parent | 2a1558e4d6fc2e7abbb9a6f4abc3cc4bb2d49c59 (diff) | |
download | bun-9c5f02e120bbfe76b45d036db3544cf47cf1354f.tar.gz bun-9c5f02e120bbfe76b45d036db3544cf47cf1354f.tar.zst bun-9c5f02e120bbfe76b45d036db3544cf47cf1354f.zip |
newlines for array diff
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/bindings/exports.zig | 6 | ||||
-rw-r--r-- | src/bun.js/test/jest.zig | 28 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/bun.js/bindings/exports.zig b/src/bun.js/bindings/exports.zig index 15ee53176..f17d7e221 100644 --- a/src/bun.js/bindings/exports.zig +++ b/src/bun.js/bindings/exports.zig @@ -2035,7 +2035,7 @@ pub const ZigConsoleClient = struct { was_good_time = was_good_time or !tag.tag.isPrimitive() or this.goodTimeForANewLine(); - if (was_good_time) { + if (this.ordered_properties or was_good_time) { this.resetLine(); writer.writeAll("["); writer.writeAll("\n"); @@ -2057,7 +2057,7 @@ pub const ZigConsoleClient = struct { var i: u32 = 1; while (i < len) : (i += 1) { this.printComma(Writer, writer_, enable_ansi_colors) catch unreachable; - if (this.goodTimeForANewLine()) { + if (this.ordered_properties or this.goodTimeForANewLine()) { writer.writeAll("\n"); this.writeIndent(Writer, writer_) catch unreachable; } else { @@ -2077,7 +2077,7 @@ pub const ZigConsoleClient = struct { } } - if (was_good_time or this.goodTimeForANewLine()) { + if (this.ordered_properties or was_good_time or this.goodTimeForANewLine()) { this.resetLine(); writer.writeAll("\n"); this.writeIndent(Writer, writer_) catch {}; diff --git a/src/bun.js/test/jest.zig b/src/bun.js/test/jest.zig index 2a8ccf3f4..f98e560f4 100644 --- a/src/bun.js/test/jest.zig +++ b/src/bun.js/test/jest.zig @@ -84,6 +84,13 @@ pub const DiffFormatter = struct { var buf_writer = buffered_writer.writer(); const Writer = @TypeOf(buf_writer); + const fmt_options = JSC.ZigConsoleClient.FormatOptions{ + .enable_colors = false, + .add_newline = true, + .flush = false, + .ordered_properties = true, + .quote_strings = true, + }; JSC.ZigConsoleClient.format( .Debug, this.globalObject, @@ -92,13 +99,7 @@ pub const DiffFormatter = struct { Writer, Writer, buf_writer, - .{ - .enable_colors = false, - .add_newline = false, - .flush = false, - .ordered_properties = true, - .quote_strings = true, - }, + fmt_options, ); buffered_writer.flush() catch unreachable; @@ -112,13 +113,7 @@ pub const DiffFormatter = struct { Writer, Writer, buf_writer, - .{ - .enable_colors = false, - .add_newline = false, - .flush = false, - .ordered_properties = true, - .quote_strings = true, - }, + fmt_options, ); buffered_writer.flush() catch unreachable; } @@ -266,14 +261,15 @@ pub const DiffFormatter = struct { } }, } + if (df.text[df.text.len - 1] != '\n') try writer.writeAll("\n"); } if (Output.enable_ansi_colors) { - try writer.print(Output.prettyFmt("\n\n<green>- Expected - {d}<r>\n", true), .{insert_count}); + try writer.print(Output.prettyFmt("\n<green>- Expected - {d}<r>\n", true), .{insert_count}); try writer.print(Output.prettyFmt("<red>+ Received + {d}<r>", true), .{delete_count}); return; } - try writer.print("\n\n- Expected - {d}\n", .{insert_count}); + try writer.print("\n- Expected - {d}\n", .{insert_count}); try writer.print("+ Received + {d}", .{delete_count}); return; }, |