• 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:finalizationregistrywithsymbol
18 * @tc.desc:test FinalizationRegistry allow the use of most Symbols
19 * @tc.type: FUNC
20 * @tc.require: issueI7J2VN
21 */
22
23var fr = new FinalizationRegistry((value) => {
24    assert_equal(value + " destroyed","symbol 2 destroyed");
25})
26
27let s = Symbol("symbol");
28let ss = Symbol("symbol");
29fr.register(s, "symbol 1", Symbol.match);
30fr.register(ss, "symbol 2", Symbol.matchAll);
31
32try {
33    fr.register(Symbol.for("symbol2"), "symbol 2");
34} catch (err) {
35    assert_equal(err instanceof TypeError, true);
36}
37
38fr.unregister(Symbol.match);
39s = {};
40ss = {};
41ArkTools.forceFullGC();
42
43test_end();