diff --git a/test/moduletest/BUILD.gn b/test/moduletest/BUILD.gn index 65267303..f13cc900 100644 --- a/test/moduletest/BUILD.gn +++ b/test/moduletest/BUILD.gn @@ -38,6 +38,7 @@ group("ark_js_moduletest") { "multiargs:multiargsAction", "newobjdynrange:newobjdynrangeAction", "objectcloneproperties:objectclonepropertiesAction", + "objoperate:objoperateAction", "promise:promiseAction", "proxy:proxyAction", "regexpcallthrow:regexpcallthrowAction", @@ -77,11 +78,12 @@ group("ark_asm_test") { "globalthis:globalthisAsmAction", "helloworld:helloworldAsmAction", "lexicalenv:lexicalenvAsmAction", - "loadicbyvalue:loadicbyvalueAction", + "loadicbyvalue:loadicbyvalueAsmAction", "module:moduleAsmAction", "multiargs:multiargsAsmAction", "newobjdynrange:newobjdynrangeAsmAction", "objectcloneproperties:objectclonepropertiesAsmAction", + "objoperate:objoperateAsmAction", "promise:promiseAsmAction", "proxy:proxyAsmAction", "regexpcallthrow:regexpcallthrowAsmAction", diff --git a/test/moduletest/class/class.js b/test/moduletest/class/class.js index a5c20f68..6ab3e12c 100644 --- a/test/moduletest/class/class.js +++ b/test/moduletest/class/class.js @@ -40,4 +40,30 @@ class Child extends Parent { var c = new Child(2, 3); print(c.value()); -print(Child.toString()); \ No newline at end of file +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); \ No newline at end of file diff --git a/test/moduletest/class/expect_output.txt b/test/moduletest/class/expect_output.txt index 6b506e71..e7212fb2 100644 --- a/test/moduletest/class/expect_output.txt +++ b/test/moduletest/class/expect_output.txt @@ -13,3 +13,5 @@ 6 parent child +PASS +10 diff --git a/test/moduletest/objoperate/BUILD.gn b/test/moduletest/objoperate/BUILD.gn new file mode 100644 index 00000000..332c5f83 --- /dev/null +++ b/test/moduletest/objoperate/BUILD.gn @@ -0,0 +1,18 @@ +# 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. + +import("//ark/js_runtime/test/test_helper.gni") + +host_moduletest_action("objoperate") { + deps = [] +} diff --git a/test/moduletest/objoperate/expect_output.txt b/test/moduletest/objoperate/expect_output.txt new file mode 100644 index 00000000..d684a92a --- /dev/null +++ b/test/moduletest/objoperate/expect_output.txt @@ -0,0 +1,15 @@ +# 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. + +PASS +PASS diff --git a/test/moduletest/objoperate/objoperate.js b/test/moduletest/objoperate/objoperate.js new file mode 100644 index 00000000..ef0266bc --- /dev/null +++ b/test/moduletest/objoperate/objoperate.js @@ -0,0 +1,31 @@ +/* + * 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. + */ + +function assertEqual(a, b) { + var t1 = JSON.stringify(a); + var t2 = JSON.stringify(b); + if (t1 == t2) { + print("PASS"); + } else { + print("FAIL"); + } +} + +var obj1 = {a:2, b:3, c:4}; +var obj2 = {d:1, ...obj1, e:5}; +assertEqual(obj2, {d:1, a:2, b:3, c:4, e:5}); + +var obj = {["a" + "b" + "de"]:function() {return 1;}} +assertEqual(obj.abde.name, "abde"); \ No newline at end of file