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 */
22print("finalizationregistrywithsymbol test start");
23
24var fr = new FinalizationRegistry((value) => {
25    print(value + " destroyed");
26})
27
28let s = Symbol("symbol");
29let ss = Symbol("symbol");
30fr.register(s, "symbol 1", Symbol.match);
31fr.register(ss, "symbol 2", Symbol.matchAll);
32
33try {
34    fr.register(Symbol.for("symbol2"), "symbol 2");
35} catch (err) {
36    print(err.name);
37}
38
39fr.unregister(Symbol.match);
40s = {};
41ss = {};
42ArkTools.forceFullGC();
43print("finalizationregistrywithsymbol test end");