Files
wupengyong a539d889da reason:need tests to test bytecode
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
2022-07-04 14:55:36 +08:00

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);