1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/* 17 * @tc.name:async 18 * @tc.desc:test async function 19 * @tc.type: FUNC 20 * @tc.require: issueI5NO8G issueI8FBM3 21 */ 22var array = [,]; 23function map() { 24 return array.map(x => x + 1); 25} 26array.__proto__.push(5); 27var narr = map(); 28print(JSON.stringify(Object.getOwnPropertyDescriptor(narr, 0))); 29print(narr[0], 6); 30 31let arr=new Array(10); 32map=arr.map(()=>{}); 33print(map.at(9)); 34 35// Species constructor is used to create [] 36// So not should use ElementAccessor::Set (elements.length == 0) 37var instance = []; 38var Ctor = function() { 39 return instance; 40}; 41var a = [1, 2, 3, 4, 5]; 42a.constructor = {}; 43a.constructor[Symbol.species] = Ctor; 44var result = a.map(function() {}); 45print(result == instance); 46{ 47 const v1 = new BigInt64Array(); 48 const v2 = [65537,-1,4096,-9007199254740990,-268435456,6,-29705,128,-6]; 49 function f3() { 50 v2["pop"](); 51 return f3; 52 } 53 let a = v2.map(f3()); 54 print(a.length) 55} 56 57{ 58 const v0 = [0,1,2,3,4,5,6,7,8,9,10]; 59 const mapEd = v0.map(() =>{ 60 Object.defineProperty(Array.prototype, '8',{value: 42, writable :false }); 61 return 8; 62 }) 63 print(v0) 64} 65 66