blob: 6bab6b6c36dfe33b18c0e2479f32aaef01535fa1 [file] [log] [blame]
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-%typedarray%.prototype.slice
description: >
Custom @@species constructor throws if it returns an instance with a detached
buffer
info: |
22.2.3.24 %TypedArray%.prototype.slice ( start, end )
...
9. Let A be ? TypedArraySpeciesCreate(O, « count »).
...
22.2.4.7 TypedArraySpeciesCreate ( exemplar, argumentList )
...
3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor).
4. Return ? TypedArrayCreate(constructor, argumentList).
22.2.4.6 TypedArrayCreate ( constructor, argumentList )
1. Let newTypedArray be ? Construct(constructor, argumentList).
2. Perform ? ValidateTypedArray(newTypedArray).
...
includes: [testTypedArray.js, detachArrayBuffer.js]
features: [Symbol.species, TypedArray]
---*/
testWithTypedArrayConstructors(function(TA) {
var sample = new TA();
sample.constructor = {};
sample.constructor[Symbol.species] = function(count) {
var other = new TA(count);
$DETACHBUFFER(other.buffer);
return other;
};
assert.throws(TypeError, function() {
sample.slice();
});
});