Skip to content

fix(number): fix Infinity casing in Number.prototype.toExponential#5244

Draft
ParthMozarkar wants to merge 3 commits intoboa-dev:mainfrom
ParthMozarkar:fix-number-toexponential-infinity
Draft

fix(number): fix Infinity casing in Number.prototype.toExponential#5244
ParthMozarkar wants to merge 3 commits intoboa-dev:mainfrom
ParthMozarkar:fix-number-toexponential-infinity

Conversation

@ParthMozarkar
Copy link
Contributor

I noticed Number.prototype.toExponential was failing the test262
return-values.js test and dug into why.

Infinity.toExponential() was returning "infinity" instead of "Infinity"
(-Infinity).toExponential() was returning "-infinity" instead of "-Infinity"

The issue was that the non-finite check was using JsString::from(this_num)
which relies on Rust's default float formatting that produces lowercase
"infinity".

Fixed it by explicitly returning the correct strings "Infinity",
"-Infinity" and "NaN" for non-finite values, matching what the
ECMAScript spec requires.

All existing tests pass.

Fixes #5243

@github-actions github-actions bot added Waiting On Review Waiting on reviews from the maintainers C-Builtins PRs and Issues related to builtins/intrinsics and removed Waiting On Review Waiting on reviews from the maintainers labels Mar 23, 2026
@github-actions github-actions bot added this to the v1.0.0 milestone Mar 23, 2026
@github-actions github-actions bot added the Waiting On Review Waiting on reviews from the maintainers label Mar 23, 2026
@github-actions
Copy link

Test262 conformance changes

Test result main count PR count difference
Total 52,963 52,963 0
Passed 50,545 50,545 0
Ignored 1,426 1,426 0
Failed 992 992 0
Panics 2 2 0
Conformance 95.43% 95.43% 0.00%

Tested main commit: 5b0f62ad860a2f5e2a4631ac2f280642cf7e21ea
Tested PR commit: 715134de84a62f05c1755b5281d557fd720a962e
Compare commits: 5b0f62a...715134d

@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.80%. Comparing base (6ddc2b4) to head (715134d).
⚠️ Report is 917 commits behind head on main.

Files with missing lines Patch % Lines
core/engine/src/builtins/number/mod.rs 40.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #5244       +/-   ##
===========================================
+ Coverage   47.24%   59.80%   +12.56%     
===========================================
  Files         476      582      +106     
  Lines       46892    63463    +16571     
===========================================
+ Hits        22154    37956    +15802     
- Misses      24738    25507      +769     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-Builtins PRs and Issues related to builtins/intrinsics Waiting On Review Waiting on reviews from the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Number.prototype.toExponential returns wrong casing for Infinity and -Infinity

1 participant