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 */ 22let ws = new WeakSet(); 23let sym1 = Symbol("symbol1"); 24ws.add(sym1); 25 26let sym2 = Symbol.for("symbol2"); 27try { 28 ws.add(sym2); 29} catch (err) { 30 assert_equal(err instanceof TypeError, true); 31} 32 33assert_equal(ws.has(sym1),true); 34assert_equal(ws.delete(sym1),true); 35assert_equal(ws.has(sym1),false); 36 37assert_equal(ws.has(sym2),false); 38assert_equal(ws.delete(sym2),false); 39 40const symbolFuncsValue = [ 41 Symbol.asyncIterator, 42 Symbol.hasInstance, 43 Symbol.isConcatSpreadable, 44 Symbol.iterator, 45 Symbol.match, 46 Symbol.matchAll, 47 Symbol.replace, 48 Symbol.search, 49 Symbol.species, 50 Symbol.split, 51 Symbol.toPrimitive, 52 Symbol.toStringTag, 53 Symbol.unscopables 54]; 55 56symbolFuncsValue.forEach(function (ctor, i) { 57 ws.add(ctor, i); 58}); 59 60assert_equal(ws.has(Symbol.match),true); 61 62test_end();