| ... | ... | @@ -330,7 +330,7 @@ pub fn formatType( |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | switch (@typeInfo(T)) { |
| 333 | | .ComptimeInt, .Int, .Float => { |
| 333 | .ComptimeInt, .Int, .ComptimeFloat, .Float => { |
| 334 | 334 | return formatValue(value, fmt, options, out_stream); |
| 335 | 335 | }, |
| 336 | 336 | .Void => { |
| ... | ... | @@ -493,7 +493,7 @@ fn formatValue( |
| 493 | 493 | |
| 494 | 494 | const T = @TypeOf(value); |
| 495 | 495 | switch (@typeInfo(T)) { |
| 496 | | .Float => return formatFloatValue(value, fmt, options, out_stream), |
| 496 | .Float, .ComptimeFloat => return formatFloatValue(value, fmt, options, out_stream), |
| 497 | 497 | .Int, .ComptimeInt => return formatIntValue(value, fmt, options, out_stream), |
| 498 | 498 | .Bool => return formatBuf(if (value) "true" else "false", options, out_stream), |
| 499 | 499 | else => comptime unreachable, |
| ... | ... | @@ -1594,6 +1594,18 @@ test "formatIntValue with comptime_int" { |
| 1594 | 1594 | std.testing.expect(mem.eql(u8, fbs.getWritten(), "123456789123456789")); |
| 1595 | 1595 | } |
| 1596 | 1596 | |
| 1597 | test "formatFloatValue with comptime_float" { |
| 1598 | const value: comptime_float = 1.0; |
| 1599 | |
| 1600 | var buf: [20]u8 = undefined; |
| 1601 | var fbs = std.io.fixedBufferStream(&buf); |
| 1602 | try formatFloatValue(value, "", FormatOptions{}, fbs.outStream()); |
| 1603 | std.testing.expect(mem.eql(u8, fbs.getWritten(), "1.0e+00")); |
| 1604 | |
| 1605 | try testFmt("1.0e+00", "{}", .{value}); |
| 1606 | try testFmt("1.0e+00", "{}", .{1.0}); |
| 1607 | } |
| 1608 | |
| 1597 | 1609 | test "formatType max_depth" { |
| 1598 | 1610 | const Vec2 = struct { |
| 1599 | 1611 | const SelfType = @This(); |