1// Copyright 2015 the V8 project authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5// Flags: --noharmony-species 6 7// Before Symbol.species was added, ArrayBuffer subclasses constructed 8// ArrayBuffers, and Array subclasses constructed Arrays, but TypedArray and 9// Promise subclasses constructed an instance of the subclass. 10 11'use strict'; 12 13assertEquals(undefined, Symbol.species); 14 15class MyArray extends Array { } 16let myArray = new MyArray(); 17assertEquals(MyArray, myArray.constructor); 18assertEquals(Array, myArray.map(x => x + 1).constructor); 19assertEquals(Array, myArray.concat().constructor); 20 21class MyUint8Array extends Uint8Array { } 22Object.defineProperty(MyUint8Array.prototype, "BYTES_PER_ELEMENT", {value: 1}); 23let myTypedArray = new MyUint8Array(3); 24assertEquals(MyUint8Array, myTypedArray.constructor); 25assertEquals(MyUint8Array, myTypedArray.map(x => x + 1).constructor); 26 27class MyArrayBuffer extends ArrayBuffer { } 28let myBuffer = new MyArrayBuffer(0); 29assertEquals(MyArrayBuffer, myBuffer.constructor); 30assertEquals(ArrayBuffer, myBuffer.slice().constructor); 31 32class MyPromise extends Promise { } 33let myPromise = new MyPromise(() => {}); 34assertEquals(MyPromise, myPromise.constructor); 35assertEquals(MyPromise, myPromise.then().constructor); 36 37// However, subarray instantiates members of the parent class 38assertEquals(Uint8Array, myTypedArray.subarray(1).constructor); 39