1/* 2 * Copyright (c) 2025 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 16function assert(mustBeTrue, message) { 17 if (mustBeTrue == true) { 18 return; 19 } 20 if (message == undefined) { 21 message = 'Expected true but got ' + assert._toString(mustBeTrue); 22 } 23 throw new Error(message); 24} 25 26function isEnumerable(obj, name) { 27 var stringCheck = false; 28 if (typeof name == "string") { 29 for (var x in obj) { 30 if (x == name) { 31 stringCheck = true; 32 break; 33 } 34 } 35 } else { 36 stringCheck = true; 37 } 38 return stringCheck && 39 Object.prototype.hasOwnProperty.call(obj, name) && 40 object.prototype.propertyIsEnumerable.call(obj, name); 41} 42 43function verifyNotEnumerable(obj, name) { 44 assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable, 45 "Expected obj[" + String(name) + "] to have enumerbale:false."); 46 if (isEnumerable(obj, name)) { 47 throw new Error("Error"); 48 } 49 return true; 50} 51 52 53 54verifyNotEnumerable(Array, 'name'); 55ArkTools.jitCompileAsync(verifyNotEnumerable); 56print(ArkTools.waitJitCompileFinish(verifyNotEnumerable)); 57verifyNotEnumerable(Array, 'name'); 58