• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16/*
17 * @tc.name:throwerror
18 * @tc.desc:test throwerror
19 * @tc.type: FUNC
20 */
21function f1(a2, a3) {
22    g = 256;
23}
24try {
25    ([1,2]).filter(f1);
26    assert_unreachable();
27} catch (error) {
28    assert_equal(error instanceof ReferenceError, true);
29}
30
31function f0(a1) {
32    return a1 in "valueOf";
33}
34const v4 = [4294967297];
35try {
36    ([1,2]).reduce(f0, v4);
37    assert_unreachable();
38} catch (error) {
39    assert_equal(error instanceof TypeError, true);
40}
41
42function f2(a1) {
43    return f2;
44}
45class C2 extends f2 {
46}
47C2.__proto__ = [8069];
48try {
49    new C2();
50    assert_unreachable();
51} catch (error) {
52    assert_equal(error instanceof TypeError, true);
53}
54
55class C3 {
56    #a = "2F";
57}
58try {
59    C3(..."g2");
60    assert_unreachable();
61} catch (error) {
62    assert_equal(error instanceof TypeError, true);
63}
64
65try {
66    const v40 = [1, -3.0];
67    v40[1] = v40;
68    v40.flat(536870887);
69    assert_unreachable();
70} catch (e) {
71    assert_equal(e instanceof RangeError, true);
72}
73
74test_end();