[immutable-arraybuffer] ArrayBuffer.prototype.sliceToImmutable#4553
[immutable-arraybuffer] ArrayBuffer.prototype.sliceToImmutable#4553
Conversation
51629c7 to
f9ed2c1
Compare
ptomato
left a comment
There was a problem hiding this comment.
Minor comments, feel free to merge when resolved
| ---*/ | ||
|
|
||
| var fn = ArrayBuffer.prototype.sliceToImmutable; | ||
| assert.sameValue(typeof fn, "function", "Method must exist."); |
There was a problem hiding this comment.
| assert.sameValue(typeof fn, "function", "Method must exist."); |
I think this is sufficiently implied by the immutable-arraybuffer feature flag.
| ---*/ | ||
|
|
||
| var fn = ArrayBuffer.prototype.sliceToImmutable; | ||
| assert.sameValue(typeof fn, "function", "Method must exist."); |
| var label = badReceivers[i][0]; | ||
| var value = badReceivers[i][1]; |
There was a problem hiding this comment.
This will break on implementations without Symbol or BigInt, I think you probably want if (!badReceivers[i]) continue;
| ---*/ | ||
|
|
||
| var fn = ArrayBuffer.prototype.sliceToImmutable; | ||
| assert.sameValue(typeof fn, "function", "Method must exist."); |
There was a problem hiding this comment.
Already implied by feature flag.
| "sliceToImmutable(" + repr(rawStart) + ", " + repr(rawEnd) + ")"); | ||
| assert.compareArray(new Uint8Array(dest), expectContents, | ||
| "sliceToImmutable(" + repr(rawStart) + ", " + repr(rawEnd) + ")"); | ||
| assert.sameValue(dest.immutable, true, | ||
| "sliceToImmutable(" + repr(rawStart) + ", " + repr(rawEnd) + ")"); |
There was a problem hiding this comment.
Minor suggestion, add something to these assertion messages to distinguish which assertion is failing (byte length, contents, or immutability) (Same for below)
| var view = new Uint8Array(source); | ||
| for (var i = 0; i < 8; i++) view[i] = i + 1; | ||
|
|
||
| var dest = new ArrayBuffer.sliceToImmutable(); |
There was a problem hiding this comment.
new ArrayBuffer.sliceToImmutable() makes no sense. I guess it should be something like source.sliceToImmutable().
| return String(value); | ||
| } | ||
|
|
||
| var make32ByteArrayBuffer() { |
There was a problem hiding this comment.
Typo? var make32ByteArrayBuffer() -> function make32ByteArrayBuffer()
| for (var j = 0; j < goodInputs.length; j++) { | ||
| var rawEnd = goodInputs[j][0]; | ||
| var intEnd = goodInputs[j][1]; | ||
| var intLength = intEnd - intStart; |
There was a problem hiding this comment.
This is not a correct calculation of the length of the slice. It does not work when intStart or intEnd is negative or when intStart > intEnd. Note that there is the same problem on lines 151 and 170.
| calls, | ||
| ["start[Symbol.toPrimitive](number)", "end[Symbol.toPrimitive](number)"], | ||
| "sliceToImmutable" + reprArgs("[Symbol.toPrimitive]", "[Symbol.toPrimitive]")); | ||
| ); |
There was a problem hiding this comment.
SyntaxError, duplicate ); (here and on the previous line). There is the same problem on lines 316 and 324.
| [-1, RangeError], | ||
| [9007199254740992, RangeError], // Math.pow(2, 53) = 9007199254740992 | ||
| [Infinity, RangeError], | ||
| [-Infinity, RangeError], |
There was a problem hiding this comment.
I don't see why would these out of range numbers caused RangeErrors.
Ref #4509