| ... | ... | @@ -41,7 +41,8 @@ pub const backend_can_print = switch (builtin.zig_backend) { |
| 41 | 41 | else => true, |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | | fn failPrint(comptime fmt: []const u8, args: anytype) void { |
| 44 | /// Helper function for printing test failure information. |
| 45 | pub fn failPrint(comptime fmt: []const u8, args: anytype) void { |
| 45 | 46 | if (@inComptime()) { |
| 46 | 47 | @compileError(std.fmt.comptimePrint(fmt, args)); |
| 47 | 48 | } else if (backend_can_print) { |
| ... | ... | @@ -998,7 +999,8 @@ test "expectEqualDeep composite type" { |
| 998 | 999 | ); |
| 999 | 1000 | } |
| 1000 | 1001 | |
| 1001 | | fn failPrintIndicatorLine(source: []const u8, indicator_index: usize) void { |
| 1002 | /// Helper function for printing test failure information. |
| 1003 | pub fn failPrintIndicatorLine(source: []const u8, indicator_index: usize) void { |
| 1002 | 1004 | const line_begin_index = if (std.mem.findScalarLast(u8, source[0..indicator_index], '\n')) |line_begin| |
| 1003 | 1005 | line_begin + 1 |
| 1004 | 1006 | else |
| ... | ... | @@ -1017,7 +1019,8 @@ fn failPrintIndicatorLine(source: []const u8, indicator_index: usize) void { |
| 1017 | 1019 | failPrint("^ ('\\x{x:0>2}')\n", .{source[indicator_index]}); |
| 1018 | 1020 | } |
| 1019 | 1021 | |
| 1020 | | fn failPrintWithVisibleNewlines(source: []const u8) void { |
| 1022 | /// Helper function for printing test failure information. |
| 1023 | pub fn failPrintWithVisibleNewlines(source: []const u8) void { |
| 1021 | 1024 | var i: usize = 0; |
| 1022 | 1025 | while (std.mem.findScalar(u8, source[i..], '\n')) |nl| : (i += nl + 1) { |
| 1023 | 1026 | failPrintLine(source[i..][0..nl]); |
| ... | ... | @@ -1025,7 +1028,8 @@ fn failPrintWithVisibleNewlines(source: []const u8) void { |
| 1025 | 1028 | failPrint("{s}␃\n", .{source[i..]}); // End of Text symbol (ETX) |
| 1026 | 1029 | } |
| 1027 | 1030 | |
| 1028 | | fn failPrintLine(line: []const u8) void { |
| 1031 | /// Helper function for printing test failure information. |
| 1032 | pub fn failPrintLine(line: []const u8) void { |
| 1029 | 1033 | if (line.len != 0) switch (line[line.len - 1]) { |
| 1030 | 1034 | ' ', '\t' => return failPrint("{s}⏎\n", .{line}), // Return symbol |
| 1031 | 1035 | else => {}, |