| ... | @@ -1123,8 +1123,8 @@ pub fn printValue( | ... | @@ -1123,8 +1123,8 @@ pub fn printValue( |
| 1123 | else => invalidFmtError(fmt, value), | 1123 | else => invalidFmtError(fmt, value), |
| 1124 | }, | 1124 | }, |
| 1125 | 't' => switch (@typeInfo(T)) { | 1125 | 't' => switch (@typeInfo(T)) { |
| 1126 | .error_set => return w.writeAll(@errorName(value)), | 1126 | .error_set => return w.alignBufferOptions(@errorName(value), options), |
| 1127 | .@"enum", .@"union" => return w.writeAll(@tagName(value)), | 1127 | .@"enum", .@"union" => return w.alignBufferOptions(@tagName(value), options), |
| 1128 | else => invalidFmtError(fmt, value), | 1128 | else => invalidFmtError(fmt, value), |
| 1129 | }, | 1129 | }, |
| 1130 | else => {}, | 1130 | else => {}, |
| ... | @@ -2134,6 +2134,14 @@ test "bytes.hex" { | ... | @@ -2134,6 +2134,14 @@ test "bytes.hex" { |
| 2134 | try testing.expectFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros}); | 2134 | try testing.expectFmt("lowercase: 000ebabe\n", "lowercase: {x}\n", .{bytes_with_zeros}); |
| 2135 | } | 2135 | } |
| 2136 | | 2136 | |
| | 2137 | test "padding" { |
| | 2138 | const foo: enum { foo } = .foo; |
| | 2139 | try testing.expectFmt("tag: |foo |\n", "tag: |{t:<4}|\n", .{foo}); |
| | 2140 | |
| | 2141 | const bar: error{bar} = error.bar; |
| | 2142 | try testing.expectFmt("error: |bar |\n", "error: |{t:<4}|\n", .{bar}); |
| | 2143 | } |
| | 2144 | |
| 2137 | test fixed { | 2145 | test fixed { |
| 2138 | { | 2146 | { |
| 2139 | var buf: [255]u8 = undefined; | 2147 | var buf: [255]u8 = undefined; |