1/* 2 * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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:weaksetsymbolvalue 18 * @tc.desc:test WeakSet allow the use of most Symbols as values 19 * @tc.type: FUNC 20 * @tc.require: issueI7J2VN 21 */ 22print("weaksetsymbolvalue test start"); 23let ws = new WeakSet(); 24let sym1 = Symbol("symbol1"); 25ws.add(sym1); 26 27let sym2 = Symbol.for("symbol2"); 28try { 29 ws.add(sym2); 30} catch (err) { 31 print(err.name); 32} 33 34print("ws.has(sym1) " + ws.has(sym1)); 35print("ws.delete(sym1) " + ws.delete(sym1)); 36print("ws.has(sym1) " + ws.has(sym1)); 37 38print("ws.has(sym2) " + ws.has(sym2)); 39print("ws.delete(sym2) " + ws.delete(sym2)); 40 41[ 42 Symbol.asyncIterator, 43 Symbol.hasInstance, 44 Symbol.isConcatSpreadable, 45 Symbol.iterator, 46 Symbol.match, 47 Symbol.matchAll, 48 Symbol.replace, 49 Symbol.search, 50 Symbol.species, 51 Symbol.split, 52 Symbol.toPrimitive, 53 Symbol.toStringTag, 54 Symbol.unscopables 55].forEach(function (ctor, i) { 56 ws.add(ctor, i); 57}); 58 59print("ws.has(Symbol.match) " + ws.has(Symbol.match)); 60print("weaksetsymbolvalue test end");