1/* 2 * Copyright (c) 2023-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 16interface inter { 17 get alma (): int; 18 set alma(alma: int); 19 20 korte: Object; 21 22 readonly labda: double; 23 24 foo(): int {return -1;} 25 foo2(): Object {return new Object()} 26 foo3(): double {return 0.0;} 27} 28 29class A implements inter{ 30 alma_ = 6; 31 korte_ = new Object(); 32 labda_ = 1.0 33 34 get alma (): int {return this.alma_} 35 set alma(alma: int) { this.alma_ = alma} 36 37 get korte (): Object {return this.korte_} 38 set korte(korte: Object) { this.korte_ = korte} 39 40 get labda(): double {return this.labda_;} 41 42 override foo(): int {return this.alma_;} 43 override foo2(): Object {return this.korte_;} 44 override foo3(): double {return this.labda_;} 45} 46 47function main(){ 48 let a: inter = new A(); 49 assert (a.foo() == a.alma); 50 a.alma = 4; 51 assert (a.foo() == a.alma); 52 53 54 assert (a.foo2() === a.korte); 55 a.korte = new Object(); 56 assert (a.foo2() === a.korte); 57 58 assert(a.labda == a.foo3()) 59} 60