!3681 AOT VTable Part4: Add Test Cases

Merge pull request !3681 from dingding/vtable_test
This commit is contained in:
openharmony_ci 2023-03-17 11:24:34 +00:00 committed by Gitee
commit 3d50c3a497
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
47 changed files with 1453 additions and 0 deletions

View File

@ -198,5 +198,6 @@ group("ark_aot_test") {
"aot_compatibility_test:aot_compatibility_test",
"aot_multi_constantpool_test:aot_multi_constantpool_test",
"aot_type_test:aot_type_test",
"vtable:vtable_test",
]
}

View File

@ -0,0 +1,37 @@
# Copyright (c) 2023 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.
group("base_hole_test") {
testonly = true
test_list = [
"base",
"hole",
"special_object",
"forin",
]
deps = []
foreach(test, test_list) {
deps += [ "${test}:${test}AotAction" ]
}
}
group("vtable_test") {
testonly = true
deps = [
":base_hole_test",
"break_inherit_info:break_inherit_info_test",
"maintain_inherit_info:maintain_inherit_info_test",
"not_inherit_info:not_inherit_info_test",
]
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("base") {
deps = []
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2023 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.
*/
declare function print(a0:any, a1?:any):string;
class A {
x:number;
y:number;
constructor(x:number, y:number) {
this.x = x;
this.y = y;
}
foo() {
print("A foo");
}
bar() {
print("A bar");
}
get t():string {
return this.constructor.name;
}
set t(str:string) {
print(str);
}
}
class B extends A {
z:string;
constructor(x:number, y:number, z:string) {
super(x, y);
this.z = z;
}
foo() {
print("B foo");
}
}
function testVtable(o:A) {
print(o.x);
print(o.y);
o.foo();
o.bar();
print("constructor.name:", o.t);
o.t = "setter";
}
let a = new A(1, 2);
testVtable(a);
let b = new B(3, 4, "BBBB");
testVtable(b);
print(b.z);

View File

@ -0,0 +1,26 @@
# Copyright (c) 2023 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.
1
2
A foo
A bar
constructor.name: A
setter
3
4
B foo
A bar
constructor.name: B
setter
BBBB

View File

@ -0,0 +1,25 @@
# Copyright (c) 2023 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.
group("break_inherit_info_test") {
testonly = true
test_list = [
"break_inherit_info_on_object",
"break_inherit_info_on_prototype",
]
deps = []
foreach(test, test_list) {
deps += [ "${test}:${test}AotAction" ]
}
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("break_inherit_info_on_object") {
deps = []
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 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.
*/
declare function print(a0:any, a1?:any):string;
declare class ArkTools {
static isTSHClass(o:object):boolean;
static hasTSSubtyping(o:object):boolean;
}
class A {
x:number;
y:number;
foo() {
print("A foo");
}
}
class B extends A {
z:string;
}
function testVTable(o:A) {
o.foo();
}
let b = new B();
print("Before breaking, B's ihclass is TS:", ArkTools.isTSHClass(b));
print("Before breaking, B's ihclass has TS inherit info:", ArkTools.hasTSSubtyping(b));
testVTable(b);
// break TS Chain on object
b.foo = function () {
print("b foo");
}
print("After breaking, b's hclass is TS:", ArkTools.isTSHClass(b));
print("After breaking, b's hclass has TS inherit info:", ArkTools.hasTSSubtyping(b));
testVTable(b); // occur deopt

View File

@ -0,0 +1,19 @@
# Copyright (c) 2023 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.
Before breaking, B's ihclass is TS: true
Before breaking, B's ihclass has TS inherit info: true
A foo
After breaking, b's hclass is TS: false
After breaking, b's hclass has TS inherit info: false
b foo

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("break_inherit_info_on_prototype") {
deps = []
}

View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2023 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.
*/
declare function print(a0:any, a1?:any):string;
declare class ArkTools {
static hasTSSubtyping(o:object):boolean;
}
class A {
x:number;
y:number;
foo() {
print("A foo");
}
}
class B extends A {
z:string;
}
function testVTable(o:A) {
o.foo();
}
let b = new B();
print("Before breaking, B's ihclass has TS inherit info:", ArkTools.hasTSSubtyping(b));
testVTable(b);
// break TS Chain on prototype and notify through chain
Object.defineProperty(B.prototype, "foo", { value: function() {
print("B foo");
}
})
print("After breaking, B's ihclass has TS inherit info:", ArkTools.hasTSSubtyping(b));
testVTable(b); // occur deopt

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 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.
Before breaking, B's ihclass has TS inherit info: true
A foo
After breaking, B's ihclass has TS inherit info: false
B foo

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("forin") {
deps = []
}

View File

@ -0,0 +1,22 @@
# Copyright (c) 2023 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.
y 3
z 5
y 3
z 5
z 5
z 5
m 6
z 5
m 6

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
declare function print(a0:any, a1?:any):string;
class A {
x:number;
y:number;
z:number;
constructor() {
this.y = 3;
this.z = 5;
}
}
let a = new A();
for (let key in a) {
print(key, a[key]);
}
// delete local property (hole)
delete a.x;
for (let key in a) {
print(key, a[key]);
}
// delete local property (no hole)
delete a.y;
for (let key in a) {
print(key, a[key]);
}
// add property
a.m = 6;
for (let key in a) {
print(key, a[key]);
}
// change prototype
Object.defineProperty(A.prototype, "foo", { value: function() {}})
for (let key in a) {
print(key, a[key]);
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("hole") {
deps = []
}

View File

@ -0,0 +1,15 @@
# Copyright (c) 2023 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.
undefined
2

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 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.
*/
declare function print(a0:any, a1?:any):string;
class A {
x:number;
y:number;
}
let a = new A();
print(a.x);
A.prototype.x = 2;
print(a.x);

View File

@ -0,0 +1,26 @@
# Copyright (c) 2023 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.
group("maintain_inherit_info_test") {
testonly = true
test_list = [
"add_property",
"delete_property",
"transition_after_delete",
]
deps = []
foreach(test, test_list) {
deps += [ "${test}:${test}AotAction" ]
}
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("add_property") {
deps = []
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
declare function print(a0:any, a1?:any):string;
declare class ArkTools {
static hasTSSubtyping(o:object):boolean;
}
class A {
x:number;
y:number;
constructor() {
this.x = 1;
this.y = 2;
}
}
class B extends A {
z:string;
constructor() {
super();
this.z = "z";
}
}
let b = new B();
b.z1 = 123;
b.z2 = 456;
print(ArkTools.hasTSSubtyping(b));
print(b.x);
print(b.y);
print(b.z);
print(b.z1);
print(b.z2);
A.prototype.t = 789; // break inherit info
let b1 = new B();
b1.z1 = 321; // transion success, has cleared inherit info
print(ArkTools.hasTSSubtyping(b1));
print(b1.x); // occur depot
print(b1.y);
print(b1.z);

View File

@ -0,0 +1,23 @@
# Copyright (c) 2023 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.
true
1
2
z
123
456
false
1
2
z

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("delete_property") {
deps = []
}

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 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.
*/
declare function print(a0:any, a1?:any):string;
declare class ArkTools {
static hasTSSubtyping(o:object):boolean;
}
class A {
x:number;
y:number;
constructor() {
this.x = 1;
this.y = 2;
}
}
class B extends A {
z:string;
constructor() {
super();
this.z = "z";
}
}
let b = new B();
delete b.y;
Reflect.deleteProperty(b, "z");
print(ArkTools.hasTSSubtyping(b));
print(b.x);
print(b.y);
print(b.z);

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 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.
true
1
undefined
undefined

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("transition_after_delete") {
deps = []
}

View File

@ -0,0 +1,14 @@
# Copyright (c) 2023 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.
y

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
declare function print(str:any):string;
class A {
x:number;
y:number;
constructor() {
this.x = 1;
this.y = 2;
}
}
let a = new A();
delete a.x;
Object.defineProperty(a, "y", { get() {
return 123;
}
});
print(Reflect.ownKeys(a));

View File

@ -0,0 +1,28 @@
# Copyright (c) 2023 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.
group("not_inherit_info_test") {
testonly = true
test_list = [
"not_meet_rule1",
"not_meet_rule2",
"not_meet_rule3",
"not_meet_rule4",
"not_meet_rule5",
]
deps = []
foreach(test, test_list) {
deps += [ "${test}:${test}AotAction" ]
}
}

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("not_meet_rule1") {
deps = []
}

View File

@ -0,0 +1,15 @@
# Copyright (c) 2023 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.
false
1

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
// rule-1 check
/*
* Chain Rules:
* 1: local_N(B) vtable_N(B) =
* 2: local(A) local(B)
* 3: vtable_NT(A) vtable_NT(B)
* 4: local_N(A) vtable_N(B) =
* 5: vtable_N(A) local_N(B) =
*/
declare function print(arg:any):string;
class B {
x:number;
get x() {
return 1;
}
}
let b = new B();
print(ArkTools.hasTSSubtyping(b));
print(b.x);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("not_meet_rule2") {
deps = []
}

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 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.
true
1
false
123

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
// rule-2 check
/*
* Chain Rules:
* 1: local_N(B) vtable_N(B) =
* 2: local(A) local(B)
* 3: vtable_NT(A) vtable_NT(B)
* 4: local_N(A) vtable_N(B) =
* 5: vtable_N(A) local_N(B) =
*/
declare function print(arg:any):string;
class A {
x:number;
constructor() {
this.x = 1;
}
}
class B extends A {
x:string;
constructor() {
super();
this.x = "123";
}
}
let a = new A();
print(ArkTools.hasTSSubtyping(a));
print(a.x);
let b = new B();
print(ArkTools.hasTSSubtyping(b));
print(b.x);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("not_meet_rule3") {
deps = []
}

View File

@ -0,0 +1,29 @@
# Copyright (c) 2023 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.
true
1
false
1
false
1
false
2
false
3
false
4
false
5
false
6

View File

@ -0,0 +1,118 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
// rule-3 check
/*
* Chain Rules:
* 1: local_N(B) vtable_N(B) =
* 2: local(A) local(B)
* 3: vtable_NT(A) vtable_NT(B)
* 4: local_N(A) vtable_N(B) =
* 5: vtable_N(A) local_N(B) =
*/
declare function print(arg:any):string;
class A {
x:number;
constructor() {
this.x = 1;
}
foo() {
return this.x;
}
}
class B extends A {
constructor() {
super();
}
get foo() {
return this.x;
}
}
let a = new A();
print(ArkTools.hasTSSubtyping(a)); // true
print(a.foo()); // typedpath ---> 1
let b = new B();
print(ArkTools.hasTSSubtyping(b)); // false
print(b.foo); // slowpath ---> 1
// Base class and Object check
class C {
get hasOwnProperty() {
return 1;
}
}
let c = new C();
print(ArkTools.hasTSSubtyping(c)); // false
print(c.hasOwnProperty);
class C2 {
get isPrototypeOf() {
return 2;
}
}
let c2 = new C2();
print(ArkTools.hasTSSubtyping(c2)); // false
print(c2.isPrototypeOf);
class C3 {
get propertyIsEnumerable() {
return 3;
}
}
let c3 = new C3();
print(ArkTools.hasTSSubtyping(c3)); // false
print(c3.propertyIsEnumerable);
class C4 {
get toLocaleString() {
return 4;
}
}
let c4 = new C4();
print(ArkTools.hasTSSubtyping(c4)); // false
print(c4.toLocaleString);
class C5 {
get toString() {
return 5;
}
}
let c5 = new C5();
print(ArkTools.hasTSSubtyping(c5)); // false
print(c5.toString);
class C6 {
get valueOf() {
return 6;
}
}
let c6 = new C6();
print(ArkTools.hasTSSubtyping(c6)); // false
print(c6.valueOf);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("not_meet_rule4") {
deps = []
}

View File

@ -0,0 +1,17 @@
# Copyright (c) 2023 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.
true
undefined
false
x

View File

@ -0,0 +1,47 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
// rule-4 check
/*
* Chain Rules:
* 1: local_N(B) vtable_N(B) =
* 2: local(A) local(B)
* 3: vtable_NT(A) vtable_NT(B)
* 4: local_N(A) vtable_N(B) =
* 5: vtable_N(A) local_N(B) =
*/
declare function print(arg:any):string;
class A {
x:number;
}
class B extends A {
x() {
return "x";
}
}
let a = new A();
print(ArkTools.hasTSSubtyping(a));
print(a.x);
let b = new B();
print(ArkTools.hasTSSubtyping(b));
print(b.x());

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("not_meet_rule5") {
deps = []
}

View File

@ -0,0 +1,29 @@
# Copyright (c) 2023 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.
true
x
false
1
false
1
false
2
false
3
false
4
false
5
false
6

View File

@ -0,0 +1,114 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
// rule-5 check
/*
* Chain Rules:
* 1: local_N(B) vtable_N(B) =
* 2: local(A) local(B)
* 3: vtable_NT(A) vtable_NT(B)
* 4: local_N(A) vtable_N(B) =
* 5: vtable_N(A) local_N(B) =
*/
declare function print(arg:any):string;
class A {
x() {
return "x";
}
}
class B extends A {
x:number = 1;
}
let a = new A();
print(ArkTools.hasTSSubtyping(a));
print(a.x());
let b = new B();
print(ArkTools.hasTSSubtyping(b));
print(b.x);
// Base class and Object check
class C {
hasOwnProperty:number;
constructor() {
this.hasOwnProperty = 1;
}
}
let c = new C();
print(ArkTools.hasTSSubtyping(c)); // false
print(c.hasOwnProperty);
class C2 {
isPrototypeOf:number;
constructor() {
this.isPrototypeOf = 2;
}
}
let c2 = new C2();
print(ArkTools.hasTSSubtyping(c2)); // false
print(c2.isPrototypeOf);
class C3 {
propertyIsEnumerable:number;
constructor() {
this.propertyIsEnumerable = 3;
}
}
let c3 = new C3();
print(ArkTools.hasTSSubtyping(c3)); // false
print(c3.propertyIsEnumerable);
class C4 {
toLocaleString:number;
constructor() {
this.toLocaleString = 4;
}
}
let c4 = new C4();
print(ArkTools.hasTSSubtyping(c4)); // false
print(c4.toLocaleString);
class C5 {
toString:number;
constructor() {
this.toString = 5;
}
}
let c5 = new C5();
print(ArkTools.hasTSSubtyping(c5)); // false
print(c5.toString);
class C6 {
valueOf:number;
constructor() {
this.valueOf = 6;
}
}
let c6 = new C6();
print(ArkTools.hasTSSubtyping(c6)); // false
print(c6.valueOf);

View File

@ -0,0 +1,18 @@
# Copyright (c) 2023 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.
import("//arkcompiler/ets_runtime/test/test_helper.gni")
host_aot_test_action("special_object") {
deps = []
}

View File

@ -0,0 +1,15 @@
# Copyright (c) 2023 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.
5
true

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 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.
*/
// @ts-nocheck
declare function print(a:any):string;
// Proxy
class A {
x:number;
constructor() {
this.x = 10;
}
}
let p = new Proxy(new A(), {
get() {
return 5;
}
})
function foo(a:A) {
print(a.x);
}
foo(p);
// Undefined
class B {
x:number;
static getInstance():B {
return undefined;
}
}
try {
B.getInstance().x;
} catch(e) {
print(e instanceof TypeError);
}