Skip to content

fix(reporter): pad fractional part to two digits in number formatting - #23

Merged
paveg merged 1 commit into
mainfrom
fix/reporter-number-formatting
Jul 18, 2026
Merged

paveg merged 1 commit into
mainfrom
fix/reporter-number-formatting

Conversation

@paveg

@paveg paveg commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Fix a leading-zero display bug shared by four formatters in src/lib/reporter/format.mbt.
Each built its output by interpolating an unpadded 0–99 fraction,
so any fraction below 10 lost a digit:
80µs rendered as "0.8ms" instead of "0.08ms",
making percentile tables look non-monotonic (e.g. p90 "0.8ms" next to p95 "0.11ms").

Affected functions and examples (before → after):

  • format_us_as_ms: 80µs "0.8ms" → "0.08ms"
  • format_percentage: 33.05% "33.5%" → "33.05%"
  • format_rps: 8.05 "8.5" → "8.05"
  • format_time: 61.05s "61.5s" → "61.05s"

The fix pads the fraction to two digits, mirroring the pattern format_double already used.
Rounding/truncation behavior is unchanged.

Verification

  • TDD: 7 new boundary tests written first and confirmed failing for the expected reason, then the fix applied
  • moon test --target native 264/264, moon test (wasm-gc) 195/195
  • All updated expectations are single zero-insertions into fractions; no assertion was weakened

🤖 Generated with Claude Code

format_us_as_ms, format_percentage, format_rps, and format_time built
"whole.frac" strings from an unpadded 0-99 fraction, so values below 10
rendered wrong (e.g. 80us -> "0.8ms" instead of "0.08ms", 61.05s ->
"61.5s"), making percentile tables look non-monotonic. Apply the same
zero-padding format_double already used.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7936063

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.79%. Comparing base (8fbb433) to head (7936063).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   63.59%   63.79%   +0.19%     
==========================================
  Files          16       16              
  Lines         739      743       +4     
==========================================
+ Hits          470      474       +4     
  Misses        269      269              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@paveg
paveg merged commit e489f8f into main Jul 18, 2026
4 checks passed
@paveg
paveg deleted the fix/reporter-number-formatting branch July 18, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants