1// Copyright JS Foundation and other contributors, http://js.foundation
2//
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
15class A {
16  constructor() {
17    this.id = 50000;
18  }
19
20  getid(a) {
21    if (typeof a === 'number') {
22      this.id += a;
23    }
24    return this.id;
25  }
26}
27
28class B extends A {
29  constructor() {
30    super();
31    this.id = 100;
32  }
33
34  getid_A() {
35    return super.getid.call(this);
36  }
37
38  getid_B(a) {
39    return super.getid.call(this, a);
40  }
41  getid_C(a) {
42    var fn = super.getid.bind(this);
43    return fn(a);
44  }
45}
46
47var obj = new B();
48
49assert (obj.getid_A() === 100);
50assert (obj.getid_B(1) === 101);
51assert (obj.getid_C(1) === 102);
52assert (obj.id === 102);
53