diff --git a/lib/fmt/fmttest.ww b/lib/fmt/fmttest.ww index a07b5734..bb1621f5 100644 --- a/lib/fmt/fmttest.ww +++ b/lib/fmt/fmttest.ww @@ -519,24 +519,11 @@ fn closedstream(s: *io.stream) void = { match (c) { case void => {}; case io.closed => fail(); }; }; -// Negative-valued f64 rendered through fmt. PENDING task #40 (cstage -// variant-widen drops payload on N_UNARY-of-N_FLOATLIT, residual of -// #30): the literal-arg form below renders as "0" on cstage today — -// -// fmt.fprintf(&s, "{}", -2.5) // ✗ cstage: "0" -// // ✓ wwstage: "-2.5" -// -// Workaround until #40 lands: bind to a typed local so the widen -// hits the post-#30 N_IDENT path. Matches the cast form -// (`-2.5: f64`), which also works on both stages. Realistic caller -// shape (negatives usually arrive through a variable, not as a -// literal printf arg). Probe: .ai/probe_f64_unary_neg.ww. @test fn fprintf_f64_neg() void = { let mem: memio.state; let s: io.stream; memio.dynamic(&mem, &s); - let nv: f64 = -2.5; - let r: (i32 | io.closed) = fmt.fprintf(&s, "{}", nv); + let r: (i32 | io.closed) = fmt.fprintf(&s, "{}", -2.5); match (r) { case let n: i32 => { if (n != 4) { fail(); }; }; case io.closed => fail(); @@ -591,15 +578,12 @@ fn closedstream(s: *io.stream) void = { }; // Sign-mod fold: '+' on positive, '-' still wins on negative (the -// natural '-' from strconv is peeled and signof reapplies). Negative -// routed through a typed local — same task #40 workaround as -// fprintf_f64_neg above. +// natural '-' from strconv is peeled and signof reapplies). @test fn fprintf_f64_sign_plus() void = { let mem: memio.state; let s: io.stream; memio.dynamic(&mem, &s); - let nv: f64 = -1.5; - let r: (i32 | io.closed) = fmt.fprintf(&s, "{:+} {:+}", 1.5, nv); + let r: (i32 | io.closed) = fmt.fprintf(&s, "{:+} {:+}", 1.5, -1.5); match (r) { case let n: i32 => { if (n != 9) { fail(); }; }; // "+1.5 -1.5" case io.closed => fail(); @@ -677,11 +661,9 @@ fn closedstream(s: *io.stream) void = { }; }; -// Heap sink + both signs. Negative through typed local per task #40 -// workaround (see fprintf_f64_neg comment). +// Heap sink + both signs. @test fn asprintf_f64() void = { - let nv: f64 = -2.5; - let r: str = fmt.asprintf("{} {}", 1.5, nv); + let r: str = fmt.asprintf("{} {}", 1.5, -2.5); if (!streq(r, "1.5 -2.5")) { fail(); }; os.free(r.ptr: *void, r.len: u64); };