Skip to content

test: migrate math/base/special/falling-factorial to ULP-based assertions - #13927

Merged
kgryte merged 3 commits into
developfrom
claude/gallant-bardeen-pb7p3k
Aug 5, 2026
Merged

test: migrate math/base/special/falling-factorial to ULP-based assertions#13927
kgryte merged 3 commits into
developfrom
claude/gallant-bardeen-pb7p3k

Conversation

@kgryte

@kgryte kgryte commented Aug 5, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for math/base/special/falling-factorial from relative tolerance testing (delta <= tol, where tol = C * EPS * abs( expected[ i ] )) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • applies the migration to both test/test.js and test/test.native.js.
  • removes the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires from both test files.

Each of the three fixture-based test bodies declares a single named ulps constant, and each assertion uses the t.strictEqual( isAlmostSameValue( y, expected[ i ], ulps ), true, 'returns expected value' ) shape.

The ULP bounds are the measured minimum over each full fixture set (1000 cases per fixture):

Test body Fixture Previous tolerance ULP bound
evaluates the falling factorial for large x fixtures/cpp/large.json 80.0 * EPS 116
evaluates the falling factorial for small x fixtures/cpp/small.json 80.0 * EPS 117
evaluates the falling factorial for negative x fixtures/cpp/negative.json 100.0 * EPS 150

Notes on how the bounds were determined:

  • The minimum required ULP difference was computed for every fixture value by bisection against isAlmostSameValue, taking the per-fixture maximum.
  • The bounds were measured independently for the JavaScript implementation (lib/main.js) and the native implementation (lib/native.js, built via make install-node-addons). Both implementations yield identical maxima, so test.js and test.native.js use the same values.
  • Tightness was confirmed by re-running the suite with each bound decremented by one, which produces exactly one failure per test body.
  • The suite was run twice at the final bounds to confirm determinism; test.js reports 3014/3014 passing and test.native.js reports 3011/3011 passing on both runs.

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.

Only the two test files are changed; no package.json or source changes were required.

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 authored by Claude Code running as an unattended scheduled task. It studied the migration idiom from previously merged conversions, applied the migration, measured the minimum ULP bounds for both the JavaScript and native implementations, and verified tightness and determinism locally.


@stdlib-js/reviewers


Generated by Claude Code

…rtions

Replaces the computed relative-tolerance assertions in the fixture loops
with `@stdlib/assert/is-almost-same-value`. The ULP bounds correspond to
the measured minimum ULP difference over each full fixture set for both
the JavaScript and native implementations.

Ref: #11352

---
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 Aug 5, 2026
@stdlib-bot

stdlib-bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
math/base/special/falling-factorial $\\color{red}298/322$
$\\color{green}+0.00\\%$
$\\color{red}30/35$
$\\color{green}+0.00\\%$
$\\color{green}3/3$
$\\color{green}+0.00\\%$
$\\color{red}298/322$
$\\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 5, 2026
@kgryte
kgryte marked this pull request as ready for review August 5, 2026 06:45
@kgryte
kgryte requested a review from a team August 5, 2026 06:45
kgryte added 2 commits August 4, 2026 23:46
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 5, 2026
@kgryte kgryte removed the Needs Review A pull request which needs code review. label Aug 5, 2026
@kgryte
kgryte merged commit c7df993 into develop Aug 5, 2026
30 checks passed
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.

3 participants