-
Notifications
You must be signed in to change notification settings - Fork 497
Add test case when countBytes in TA.p.slice is set to zero #4537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
`countBytes` can be set to zero in step 14.d when resizable array buffers are used.
This case isn't covered by existing tests. |
There was a problem hiding this 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)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
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:
ta.constructor = TargetTA; | |
Object.defineProperty(ta, "constructor", { value: TargetTA }); |
// Result typed array has the correct length with all elements set to zero. | ||
assert.compareArray(sliced, new TargetTA(N - startIndex)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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); |
countBytes
can be set to zero in step 14.d when resizable array buffers are used.