• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:weakrefforsymbol
18 * @tc.desc:test WeakRef allow the use of most Symbols as targets
19 * @tc.type: FUNC
20 * @tc.require: issueI7J2VN
21 */
22print("weakrefforsymbol test start");
23
24let target1 = Symbol("symbol1");
25let wr1 = new WeakRef(target1);
26
27let target2 = Symbol.for("symbol2");
28try {
29    let wr2 = new WeakRef(target2);
30} catch (err) {
31    print(err.name);
32}
33
34print("wr1.deref() == target1 " + (wr1.deref() == target1));
35
36[
37    Symbol.asyncIterator,
38    Symbol.hasInstance,
39    Symbol.isConcatSpreadable,
40    Symbol.iterator,
41    Symbol.match,
42    Symbol.matchAll,
43    Symbol.replace,
44    Symbol.search,
45    Symbol.species,
46    Symbol.split,
47    Symbol.toPrimitive,
48    Symbol.toStringTag,
49    Symbol.unscopables
50].forEach(function (ctor, i) {
51    let wr = new WeakRef(ctor);
52    print(i + " wr.deref() == ctor " + (wr.deref() == ctor));
53});
54
55print("weakrefforsymbol test end");