Skip to content

Conversation

anba
Copy link
Contributor

@anba anba commented Jul 16, 2025

countBytes can be set to zero in step 14.d when resizable array buffers are used.

`countBytes` can be set to zero in step 14.d when resizable array
buffers are used.
@anba anba requested a review from a team as a code owner July 16, 2025 12:50
@anba
Copy link
Contributor Author

anba commented Jul 16, 2025

This case isn't covered by existing tests.

Copy link
Contributor

@gibson042 gibson042 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; just a few suggestions.

var sliced = ta.slice(start);

// Result typed array has the correct length with all elements set to zero.
assert.compareArray(sliced, new TA(N - startIndex));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.compareArray(sliced, new TA(N - startIndex));
assert.compareArray(sliced, new TA(N - startIndex), TA.name + ", start index " + startIndex);

var ta = new SourceTA(buffer);

// Create own "constructor" property to create a different result typed array.
ta.constructor = TargetTA;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For not breaking in a hardened environment:

Suggested change
ta.constructor = TargetTA;
Object.defineProperty(ta, "constructor", { value: TargetTA });

Comment on lines +77 to +78
// Result typed array has the correct length with all elements set to zero.
assert.compareArray(sliced, new TargetTA(N - startIndex));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Result typed array has the correct length with all elements set to zero.
assert.compareArray(sliced, new TargetTA(N - startIndex));
// Result typed array has the correct type and length with all elements set to zero.
var label = SourceTA.name + " to " + TargetTA.name;
assert.sameValue(sliced.constructor, TargetTA, label);
assert.compareArray(sliced, new TargetTA(N - startIndex),
label + ", start index " + startIndex);

@Ms2ger
Copy link
Contributor

Ms2ger commented Aug 26, 2025

@anba would you mind addressing the comments above?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants