test,doc: cover and document multi-byte offset/size in randomFill - #64834
Open
kyungrae2002 wants to merge 1 commit into
Open
test,doc: cover and document multi-byte offset/size in randomFill#64834kyungrae2002 wants to merge 1 commit into
kyungrae2002 wants to merge 1 commit into
Conversation
Signed-off-by: kyungrae <kyungrae2002@gmail.com>
Collaborator
|
Review requested:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
randomFill() / randomFillSync() interpret offset and size in elements
for a TypedArray (converted to bytes internally via BYTES_PER_ELEMENT) and in
bytes for an ArrayBuffer or DataView. This PR documents contract and
adds regression tests for the previously uncovered case. No runtime behavior
changes.
Docs
The size default was documented only as buffer.length - offset, which is
meaningless for ArrayBuffer / DataView (they have no .length), and the
element-vs-byte unit distinction was undocumented. The parameter descriptions of
both randomFill() and randomFillSync() now state the unit and default per type.
Tests
Existing offset/size assertions only cover Buffer /Uint8Array
(BYTES_PER_ELEMENT === 1), so the element-to-byte conversion was never verified
for multi-byte typed arrays. The added tests fill a single element of a
Uint16Array / Uint32Array at a non-zero offset and assert the neighboring
elements are untouched, which fails if the conversion is off.