Skip to content

test: migrate math/base/special/roundnf to ULP-based assertions - #15357

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/ulp-roundnf
Draft

Planeshifter wants to merge 1 commit into
developfrom
philipp/ulp-roundnf

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • Migrates math/base/special/roundnf from manual ULP-difference tolerance checks to the canonical isAlmostSameValue-based assertion pattern described in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • In test/test.js and test/test.native.js, replaces var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); plus manual delta/t.ok( delta <= N, ... ) checks with var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' ); and t.strictEqual( isAlmostSameValue( actual, expected, N ), true, 'returns expected value' );.
  • Where the measured ULP delta was always 0 (i.e., the values were exactly equal), uses a plain t.strictEqual( actual, expected, 'returns expected value' ) instead, mirroring the existing convention used in other converted packages (e.g., sqrtf, atan2f).
  • Tightened each ULP bound to the minimum integer that still passes the full fixture set:
    • "rounding a numeric value to a desired number of decimals": 0 ULP (exact) for all cases.
    • "rounding a numeric value ... can result in unexpected behavior": 0 ULP (exact).
    • "rounding a numeric value to a desired number of digits": 1 ULP for the two non-exact comparisons.
    • "rounding very small numbers (including subnormals)": 1 ULP (previously allowed up to 2 ULP).
  • Also fixed a pre-existing, unrelated stdlib/doctest-marker ESLint violation on the touched comment line in test/test.js (// =>// returns), since it was blocking lint on a file this PR already modifies.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

  • test/test.native.js mirrors the same ULP bounds as test/test.js, following the pattern used in other converted packages (e.g., atan2f, sqrtf). The native addon could not be built/tested in this environment, so native-side bounds were not independently measured; they were kept identical to the JS-side measured bounds since no environment-specific divergence is expected for this simple rounding routine.
  • Ran the full test suite for this package twice at the final ULP bounds to confirm determinism (340/340 passing both times).

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

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

  • Yes
  • No

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

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was written by Claude Code, which discovered the candidate package, studied prior-art conversions (e.g., PR #11297, #14178, #12776), determined the minimum required ULP bound per assertion empirically by running the test suite, and applied the migration.


@stdlib-js/reviewers


🤖 Generated with Claude Code

https://claude.ai/code/session_01QQpKhCrYKm4SBFZgyCSduQ


Generated by Claude Code

Replaces manual ULP-difference tolerance checks in `test/test.js` and
`test/test.native.js` with `@stdlib/number/float32/base/assert/is-almost-same-value`,
tightening each bound to the minimum ULP value observed across the
fixture set.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QQpKhCrYKm4SBFZgyCSduQ

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@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 Sep 19, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/roundnf $\\color{red}271/273$
$\\color{green}+99.27\\%$
$\\color{red}22/23$
$\\color{green}+95.65\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{red}271/273$
$\\color{green}+99.27\\%$

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants