• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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
16class A {
17    ind: string = '';
18    val: number;
19
20    protected $_set(i: string, v: number) {
21        this.ind = i;
22        this.val = v;
23    }
24
25    protected $_get(i: string): number {
26        return i == this.ind ? this.val : Number.NaN;
27    }
28}
29
30class B extends A {
31    push(ind: string, val: number) {
32       super[ind] = val;
33    }
34
35    pull(ind: string): number {
36        return super[ind];
37    }
38
39}
40
41function main(): int {
42    let b = new B;
43    b.push('a', 11.0);
44    assert b.pull('a') == 11.0;
45    return 0;
46}