[immutable-arraybuffer] Coverage for read-only TypedArray methods#4547
Open
[immutable-arraybuffer] Coverage for read-only TypedArray methods#4547
Conversation
67 tasks
504e309 to
97ab546
Compare
With `sedi` being a portable `sed -i`, e.g. `sed -i '' "$@"` on BSD and `sed -i "$@"` on Linux: ```sh git grep -l 'testWith[A-Za-z]*TypedArrayConstructors[(].*, N.*' test/built-ins/ | \ xargs sedi -E 's#(testWith[A-Za-z]*TypedArrayConstructors[(].*), N([^a-zA-Z].*)#\1\2#' ```
With `sedi` being a portable `sed -i`, e.g. `sed -i '' "$@"` on BSD and `sed -i "$@"` on Linux: ```sh git grep -l 'testBigIntTypedArray[.]js' | \ xargs sedi 's#testBigIntTypedArray[.]js#testTypedArray.js#' ```
… a TA constructor and an argument factory
…uctors
With `sedi` being a portable `sed -i`, e.g. `sed -i '' "$@"` on BSD and
`sed -i "$@"` on Linux:
```sh
git grep -l 'testWith[A-Za-z]*TypedArrayConstructors[(]' test/built-ins/ | \
while read f; do
grep -qF detachArrayBuffer.js "$f" && continue
grep -qF '.resize(' "$f" && continue
taCtorAliases="$(sed -nE \
's#testWith[A-Za-z]*TypedArrayConstructors[(] *(function[^(]*[(] *|[^a-zA-Z0-9_]*)([a-zA-Z0-9_]+).*#\2#p' \
"$f")"
sedi -E '
s#(testWith[A-Za-z]*TypedArrayConstructors[(] *(function[^(]*[(] *|[(] *)[a-zA-Z0-9_]+)#\1, makeCtorArg#; t;
s#(testWith[A-Za-z]*TypedArrayConstructors[(] *)([a-zA-Z0-9_]+)#\1(\2, makeCtorArg)#; t;
'"$(printf '%s' "$taCtorAliases" | sed -E 's/(.*)/s#\\b\1[(]([0-9.]+n?|[[][^]]*[]])[)]#\1(makeCtorArg(\\1))#/')" \
"$f"
done
git diff --numstat -- test/built-ins/ | \
awk '{ print $NF }' | \
xargs grep -c '\bmakeCtorArg\b' | \
sed -n 's/:1$//p' | \
xargs sedi -E '
/makeCtorArg/,$ { s#^[}][)]#}, null, ["passthrough"])#; }
/makeCtorArg/ { s#, makeCtorArg##; s#[(]([a-zA-Z0-9_]+)[)] =>#\1 =>#; }
'
git diff --numstat -- test/built-ins/ | \
awk '{ print $NF }' | \
xargs grep -l '\bdefineProperty\b' | \
xargs sedi -E \
'/testWith[A-Za-z]*TypedArrayConstructors[(]/,$s#^[}][)]#}, null, ["passthrough"])#'
```
…rray method tests
…e contents
With `sedi` being a portable `sed -i`, e.g. `sed -i '' "$@"` on BSD and
`sed -i "$@"` on Linux:
```sh
git grep -l 'testWith[A-Za-z]*TypedArrayConstructors[(]' \
test/built-ins/TypedArray/prototype/{copyWithin,fill,reverse,set,sort} | \
xargs sedi -E \
'/testWith[A-Za-z]*TypedArrayConstructors[(]/,$s#^[}][)]#}, null, null, ["immutable"])#'
git grep -l 'testWith[A-Za-z]*TypedArrayConstructors[(]' \
test/built-ins/TypedArray/prototype | \
grep -E 'set-value-during-|predicate-call-changes-value|values-are-not-cached' | \
xargs sedi -E \
'/testWith[A-Za-z]*TypedArrayConstructors[(]/,$s#^[}][)]#}, null, null, ["immutable"])#'
```
…acked by an immutable ArrayBuffer
97ab546 to
b283db3
Compare
iamstolis
reviewed
Oct 8, 2025
| var iab = (new TA(["3", "4"])).buffer.transferToImmutable(); | ||
| var result = new TA(iab); | ||
| calls.push("construct result"); | ||
| return result; |
Contributor
There was a problem hiding this comment.
I wondered why this test passes even without implementing the relevant changes in %TypedArray%.prototype.filter. The root of the problem is here. This Symbol.species getter doesn't return constructor (it returns a typed array). Not returning a constructor results in the expected TypeError (before we have any chance to get to the IsImmutableBuffer() that's supposed to be checked by this test).
In other words, the getter should not return result but a function that returns result.
The same problem is in the slice and map versions of this test.
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.
Includes #4545
Ref #4509