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(function StoreToSuper () {
16  "use strict";
17  class A {
18    s() {
19      super.bla = 10;
20    }
21  };
22
23  let a = new A();
24  (new A).s.call(a);
25  print(10 == a.bla);
26
27  try {
28    (new A).s.call(undefined);
29  } catch (error) {
30    print(error instanceof TypeError);
31  }
32
33  try {
34    (new A).s.call(42);
35  } catch (error) {
36    print(error instanceof TypeError);
37  }
38
39  try {
40    (new A).s.call(null);
41  } catch (error) {
42    print(error instanceof TypeError);
43  }
44
45  try {
46    (new A).s.call("abc");
47  } catch (error) {
48    print(error instanceof TypeError);
49  }
50
51})();
52
53
54(function LoadFromSuper () {
55  "use strict";
56  class A {
57    s() {
58      return super.bla;
59    }
60  };
61
62  let a = new A();
63  print(undefined == (new A).s.call(a));
64  print(undefined == (new A).s.call(undefined));
65  print(undefined == (new A).s.call(42));
66  print(undefined == (new A).s.call(null));
67  print(undefined == (new A).s.call("abc"));
68})();
69
70class TestA {
71  constructor() {
72      print("TestA", this.constructor.name, new.target.name);
73  }
74}
75class TestB extends TestA {
76  constructor() {
77      super();
78      print("TestB", this.constructor.name, new.target.name);
79      this.test();
80  }
81}
82class TestC {
83  constructor() {
84      print("TestC", this.constructor.name, new.target.name);
85  }
86  test() {
87      print("TestC");
88  }
89}
90let c1 = Reflect.construct(TestB, [], TestC.prototype.constructor);
91let c2 = Reflect.construct(TestB, [], c1.constructor);
92