mirror of
https://github.com/tc39/test262.git
synced 2025-07-23 14:04:51 +02:00
Add coverage for species constructor returning typed array with same backing buffer
JSC doesn't handle this case correctly.
This commit is contained in:
parent
8081aa7365
commit
8744a9b02a
45
test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js
vendored
Normal file
45
test/built-ins/TypedArray/prototype/slice/speciesctor-return-same-buffer-with-offset.js
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2025 André Bargull. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-%typedarray%.prototype.slice
|
||||||
|
description: >
|
||||||
|
When species constructs a typed array using the same buffer but with a
|
||||||
|
different byte offset, slice output reflects element-by-element copying into
|
||||||
|
that buffer.
|
||||||
|
info: |
|
||||||
|
%TypedArray%.prototype.slice ( start, end )
|
||||||
|
|
||||||
|
...
|
||||||
|
14. If countBytes > 0, then
|
||||||
|
g. If srcType is targetType, then
|
||||||
|
ix. Repeat, while targetByteIndex < endByteIndex,
|
||||||
|
1. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, uint8, true, unordered).
|
||||||
|
2. Perform SetValueInBuffer(targetBuffer, targetByteIndex, uint8, value, true, unordered).
|
||||||
|
...
|
||||||
|
features: [TypedArray]
|
||||||
|
includes: [testTypedArray.js, compareArray.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
testWithTypedArrayConstructors(function(TA) {
|
||||||
|
var ta = new TA([
|
||||||
|
10,
|
||||||
|
20,
|
||||||
|
30,
|
||||||
|
40,
|
||||||
|
50,
|
||||||
|
60,
|
||||||
|
]);
|
||||||
|
|
||||||
|
ta.constructor = {
|
||||||
|
[Symbol.species]: function() {
|
||||||
|
return new TA(ta.buffer, 2 * TA.BYTES_PER_ELEMENT);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = ta.slice(1, 4);
|
||||||
|
|
||||||
|
assert.compareArray(result, [
|
||||||
|
20, 20, 20, 60,
|
||||||
|
]);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user