• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/**
2 * Copyright (c) 2025 Huawei Device 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
16const etsVm = globalThis.gtest.etsVm;
17let getWeakMap = etsVm.getFunction('Lbuiltin_not_implement/ETSGLOBAL;', 'getWeakMap');
18let Foo = etsVm.getClass('Lbuiltin_not_implement/Foo;');
19
20const errorString = 'Error: Seamless conversion for class Lescompat/WeakMap; is not supported';
21
22function testThorw(func) {
23    let res = false;
24    try {
25        func();
26    } catch (err) {
27        res = err.toString() === errorString;
28    }
29    ASSERT_TRUE(res)
30}
31
32function testGetWeakMap() {
33    testThorw(getWeakMap);
34}
35
36function testGetterSetter() {
37    let foo = new Foo();
38    testThorw(()=> {
39        let val = foo.val;
40    });
41    testThorw(()=> {
42        foo.val = new WeakMap<string, string>();
43    });
44    testThorw(()=> {
45        let val = foo.mapVal;
46    });
47    testThorw(()=> {
48        foo.mapVal = new WeakMap<string, string>();
49    });
50}
51
52testGetWeakMap();
53testGetterSetter();
54