Skip to content

test: add tests for @stdlib/ndarray/base/descriptor#12111

Closed
Planeshifter wants to merge 3 commits into
developfrom
claude/vibrant-brahmagupta-IvGi5
Closed

test: add tests for @stdlib/ndarray/base/descriptor#12111
Planeshifter wants to merge 3 commits into
developfrom
claude/vibrant-brahmagupta-IvGi5

Conversation

@Planeshifter
Copy link
Copy Markdown
Member

@Planeshifter Planeshifter commented May 13, 2026

Resolves https://github.com/stdlib-js/todo/issues/2768.

Description

What is the purpose of this pull request?

This pull request:

  • adds tests for @stdlib/ndarray/base/descriptor
  • fixes an offset type annotation in docs/repl.txt from integer to NonNegativeInteger (consistent with the JSDoc annotation in lib/main.js)

Specifically, this PR expands the test suite from 2 tests (8 assertions) to 15 tests (81 assertions), adding coverage for:

  • column-major array order (generic buffer)
  • row-major and column-major with Float64Array typed buffer
  • row-major with Float32Array typed buffer
  • row-major with Int32Array typed buffer
  • row-major with Complex128Array accessor buffer (exercises the accessor buffer path documented in the REPL)
  • 1D array (shape [n])
  • 0D array (empty shape [], strides [0])
  • negative strides with non-zero offset (reversed array)
  • 3D array (shape [2,3,4])
  • verification that returned value is a plain object (correct prototype chain)
  • verification that returned object property insertion order is dtype, data, shape, strides, offset, order — the V8 hidden-class guarantee documented in the package README
  • verification that a new object is returned on each invocation while input array references (data, shape, strides) are shared

Additionally, all existing deepEqual assertions for shape and strides were changed to strictEqual to verify that the function stores the original array references rather than copies, which is the intended behavior per the performance motivation documented in the README.

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.

No.

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 primarily by Claude Code.


@stdlib-js/reviewers

@stdlib-bot
Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
ndarray/base/descriptor $\color{green}102/102$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}102/102$
$\color{green}+100.00%$

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

- add Complex128Array accessor buffer test
- add reference sharing assertions in new-object-per-invocation test
- remove redundant instanceof check in plain-object test
- fix `offset` type annotation in REPL docs from `integer` to `NonNegativeInteger`

https://claude.ai/code/session_01GTF5Fd7tpLA6P9wL4DwWcY
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.

3 participants