mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 02:31:17 -04:00
a539d889da
description:add operate and class test issue:https://gitee.com/openharmony/ark_js_runtime/issues/I5FD8M?from=project-issue Signed-off-by: wupengyong <wupengyong@huawei.com> Change-Id: I1c91e2acf0acfe0c1417297055b3688406482520
69 lines
1.3 KiB
JavaScript
69 lines
1.3 KiB
JavaScript
/*
|
|
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
class Parent {
|
|
constructor(x) {
|
|
this.x = x;
|
|
}
|
|
|
|
static toString() {
|
|
return 'parent';
|
|
}
|
|
}
|
|
|
|
class Child extends Parent {
|
|
constructor(x, y) {
|
|
super(x);
|
|
this.y = y;
|
|
}
|
|
|
|
value() {
|
|
return this.x * this.y;
|
|
}
|
|
|
|
static toString() {
|
|
return super.toString() + ' child';
|
|
}
|
|
}
|
|
|
|
var c = new Child(2, 3);
|
|
print(c.value());
|
|
print(Child.toString());
|
|
|
|
try {
|
|
class C {
|
|
a = 1;
|
|
}
|
|
class D extends C {
|
|
constructo() {
|
|
delete super.a;
|
|
}
|
|
}
|
|
d = new D();
|
|
} catch (err) {
|
|
print("PASS");
|
|
}
|
|
|
|
class A {
|
|
a = 10;
|
|
}
|
|
class B extends A {
|
|
constructor() {
|
|
let a = "a";
|
|
super[a] = 1;
|
|
}
|
|
}
|
|
var par = new A;
|
|
print(par.a); |