Skip to content

test: migrate math/base/special/roundn to ULP-based assertions - #13857

Merged
kgryte merged 2 commits into
developfrom
philipp/ulp-roundn
Aug 2, 2026
Merged

test: migrate math/base/special/roundn to ULP-based assertions#13857
kgryte merged 2 commits into
developfrom
philipp/ulp-roundn

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

This pull request:

  • Migrates the tests in @stdlib/math/base/special/roundn from relative tolerance testing to ULP-based difference testing, utilizing @stdlib/assert/is-almost-same-value.

Only one test block (rounding very small/subnormal numbers) used the old delta <= tol idiom; it has been replaced with isAlmostSameValue( v, expected[ i ], ULP ) using a named ULP constant, mirroring the conventions used in the already-merged math/base/special/truncn (#13784) and math/base/special/floorb (#12786) migrations, which are the closest sibling packages (same rounding-family test structure).

Measured minimum ULP bound: ULP = 1 (tightened from an initial high value; ULP = 0 fails 5 of the 17 subnormal-rounding cases). The full test suite (350 assertions) was run twice at ULP = 1 to confirm deterministic behavior.

Only the test files were changed; no new external dependency was introduced (@stdlib/assert/is-almost-same-value is a monorepo-internal package resolved the same way as in the prior-art PRs, so no package.json change was needed).

Related Issues

This pull request has the following related issues:

Questions

No.

Other

No.

Checklist

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

This PR was written by Claude Code (Anthropic), running as an unattended scheduled agent. It searched the repository for the relative-tolerance testing idiom described in #11352, checked for existing open/merged conversion PRs to avoid duplicating work, studied the prior-art commits for truncn and floorb, converted the tests, ran the suite locally to find the tightest ULP bound, and ran ESLint against the changed files.


@stdlib-js/reviewers


Generated by Claude Code

Resolves a part of #11352.

Replaces the manual `delta <= tol` relative-tolerance check in the
subnormal-rounding test with `@stdlib/assert/is-almost-same-value`
using a ULP budget of 1, mirroring the migrations already merged for
the sibling `truncn` and `floorb` packages.
@stdlib-bot stdlib-bot added Math Issue or pull request specific to math functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 2, 2026
@stdlib-bot

stdlib-bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/roundn $\\color{green}279/279$
$\\color{green}+0.00\\%$
$\\color{green}23/23$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}279/279$
$\\color{green}+0.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 2, 2026
Comment thread lib/node_modules/@stdlib/math/base/special/roundn/test/test.js Outdated
Comment thread lib/node_modules/@stdlib/math/base/special/roundn/test/test.js Outdated
Comment thread lib/node_modules/@stdlib/math/base/special/roundn/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/math/base/special/roundn/test/test.native.js Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte
kgryte marked this pull request as ready for review August 2, 2026 10:03
@kgryte
kgryte requested a review from a team August 2, 2026 10:03
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 2, 2026
@kgryte
kgryte merged commit ca056ba into develop Aug 2, 2026
31 checks passed
@kgryte
kgryte deleted the philipp/ulp-roundn branch August 2, 2026 10:50
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Math Issue or pull request specific to math functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants