From 81aa0260cde47d4473cadf05f7a3b18a82c0127a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=9D=B0?= Date: Wed, 30 Jul 2025 09:44:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?[=E6=96=B0=E9=9C=80=E6=B1=82]:=20=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICPHT3 Signed-off-by: 唐杰 --- test/moduletest/allocatearraybuffer/BUILD.gn | 2 +- .../allocatearraybuffer/allocatearraybuffer.js | 8 ++++---- .../allocatearraybuffer/expect_output.txt | 17 ----------------- 3 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 test/moduletest/allocatearraybuffer/expect_output.txt diff --git a/test/moduletest/allocatearraybuffer/BUILD.gn b/test/moduletest/allocatearraybuffer/BUILD.gn index 8a192e7775..50a29eb99e 100644 --- a/test/moduletest/allocatearraybuffer/BUILD.gn +++ b/test/moduletest/allocatearraybuffer/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("allocatearraybuffer") { +host_moduletest_assert_action("allocatearraybuffer") { deps = [] } diff --git a/test/moduletest/allocatearraybuffer/allocatearraybuffer.js b/test/moduletest/allocatearraybuffer/allocatearraybuffer.js index 0e5a07d549..b6ed2b7dae 100644 --- a/test/moduletest/allocatearraybuffer/allocatearraybuffer.js +++ b/test/moduletest/allocatearraybuffer/allocatearraybuffer.js @@ -21,7 +21,7 @@ */ var newTarget = function() {}.bind(null); var arrayBuffer = Reflect.construct(ArrayBuffer, [16], newTarget); -print(arrayBuffer.length); +assert_equal(arrayBuffer.length, "undefined"); /* * @tc.name:allocatearraybuffer @@ -31,14 +31,14 @@ print(arrayBuffer.length); */ const dataview = new DataView(new ArrayBuffer(64)); dataview.setInt16(0,-1); -print(dataview.getFloat64("cas")); +assert_equal(dataview.getFloat64("cas"), "NaN"); const v32 = new Int32Array(10); for (let i = 0; i < v32.length; i++) { v32[i] = i + 1; } const v36 = this.Atomics; -print(v36.and(v32, this, v36)); +assert_equal(v36.and(v32, this, v36), "1"); function SendableArrayBufferTest() { try { @@ -46,7 +46,7 @@ function SendableArrayBufferTest() { const v3 = new Proxy(SendableArrayBuffer, o1); new v3(); } catch (error) { - print(error); + assert_equal(error, "TypeError: shared ctor cannot assign unshared newTarget"); } } SendableArrayBufferTest() \ No newline at end of file diff --git a/test/moduletest/allocatearraybuffer/expect_output.txt b/test/moduletest/allocatearraybuffer/expect_output.txt deleted file mode 100644 index 5fd9e962a3..0000000000 --- a/test/moduletest/allocatearraybuffer/expect_output.txt +++ /dev/null @@ -1,17 +0,0 @@ -# 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. - -undefined -NaN -1 -TypeError: shared ctor cannot assign unshared newTarget \ No newline at end of file -- Gitee From 1b8dab58b0cb9c4ef55342e8966ed54b45fa4ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=9D=B0?= Date: Wed, 30 Jul 2025 14:32:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?[=E6=96=B0=E9=9C=80=E6=B1=82]:=20=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICPHT3 --- .../allocatearraybuffer.js | 11 ++-- test/moduletest/allocatesizeoverflow/BUILD.gn | 2 +- .../allocatesizeoverflow.js | 3 +- .../allocatesizeoverflow/expect_output.txt | 14 ---- .../arktoolsgetundetectable/BUILD.gn | 2 +- .../arktoolsgetundetectable.js | 25 +++---- .../arktoolsgetundetectable/expect_output.txt | 25 ------- test/moduletest/arrayconcat/BUILD.gn | 2 +- test/moduletest/arrayconcat/arrayconcat.js | 65 ++++++++++++++----- 9 files changed, 71 insertions(+), 78 deletions(-) delete mode 100644 test/moduletest/allocatesizeoverflow/expect_output.txt delete mode 100755 test/moduletest/arktoolsgetundetectable/expect_output.txt diff --git a/test/moduletest/allocatearraybuffer/allocatearraybuffer.js b/test/moduletest/allocatearraybuffer/allocatearraybuffer.js index b6ed2b7dae..a6f08b049b 100644 --- a/test/moduletest/allocatearraybuffer/allocatearraybuffer.js +++ b/test/moduletest/allocatearraybuffer/allocatearraybuffer.js @@ -21,7 +21,7 @@ */ var newTarget = function() {}.bind(null); var arrayBuffer = Reflect.construct(ArrayBuffer, [16], newTarget); -assert_equal(arrayBuffer.length, "undefined"); +assert_equal(arrayBuffer.length.toString(), "undefined"); /* * @tc.name:allocatearraybuffer @@ -31,14 +31,14 @@ assert_equal(arrayBuffer.length, "undefined"); */ const dataview = new DataView(new ArrayBuffer(64)); dataview.setInt16(0,-1); -assert_equal(dataview.getFloat64("cas"), "NaN"); +assert_equal(dataview.getFloat64("cas").toString(), "NaN"); const v32 = new Int32Array(10); for (let i = 0; i < v32.length; i++) { v32[i] = i + 1; } const v36 = this.Atomics; -assert_equal(v36.and(v32, this, v36), "1"); +assert_equal(v36.and(v32, this, v36).toString(), "1"); function SendableArrayBufferTest() { try { @@ -46,7 +46,8 @@ function SendableArrayBufferTest() { const v3 = new Proxy(SendableArrayBuffer, o1); new v3(); } catch (error) { - assert_equal(error, "TypeError: shared ctor cannot assign unshared newTarget"); + assert_equal(error.toString(), "TypeError: shared ctor cannot assign unshared newTarget"); } } -SendableArrayBufferTest() \ No newline at end of file +SendableArrayBufferTest() +test_end(); \ No newline at end of file diff --git a/test/moduletest/allocatesizeoverflow/BUILD.gn b/test/moduletest/allocatesizeoverflow/BUILD.gn index bf27d97bd4..fce3db02e8 100644 --- a/test/moduletest/allocatesizeoverflow/BUILD.gn +++ b/test/moduletest/allocatesizeoverflow/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("allocatesizeoverflow") { +host_moduletest_assert_action("allocatesizeoverflow") { deps = [] } diff --git a/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js b/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js index 29083188bc..7681f4c35c 100644 --- a/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js +++ b/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js @@ -23,5 +23,6 @@ v0.length = 2465979003; try { isNaN.apply(undefined, v0); } catch (error) { - print(error); + assert_equal(error.toString(), "TypeError: len is bigger than 2^32 - 1"); } +test_end(); diff --git a/test/moduletest/allocatesizeoverflow/expect_output.txt b/test/moduletest/allocatesizeoverflow/expect_output.txt deleted file mode 100644 index 518afaa244..0000000000 --- a/test/moduletest/allocatesizeoverflow/expect_output.txt +++ /dev/null @@ -1,14 +0,0 @@ -# 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. - -TypeError: len is bigger than 2^32 - 1 diff --git a/test/moduletest/arktoolsgetundetectable/BUILD.gn b/test/moduletest/arktoolsgetundetectable/BUILD.gn index e08d61b7f2..e9b090f908 100755 --- a/test/moduletest/arktoolsgetundetectable/BUILD.gn +++ b/test/moduletest/arktoolsgetundetectable/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arktoolsgetundetectable") { +host_moduletest_assert_action("arktoolsgetundetectable") { deps = [] } diff --git a/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js b/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js index 14bc49ab4f..6e1ff75ae8 100755 --- a/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js +++ b/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js @@ -17,19 +17,20 @@ var undetectable = ArkTools.getUndetectable(); // Undefined -print(typeof undetectable == 'undefined'); -print(typeof undetectable === 'undefined'); -print(typeof undetectable != 'undefined'); -print(typeof undetectable !== 'undefined'); +assert_equal(typeof undetectable == 'undefined', true); +assert_equal(typeof undetectable === 'undefined', true); +assert_equal(typeof undetectable != 'undefined', false); +assert_equal(typeof undetectable !== 'undefined', false); // Function -print(typeof undetectable != 'function'); -print(typeof undetectable !== 'function'); -print(typeof undetectable == 'function'); -print(typeof undetectable === 'function'); +assert_equal(typeof undetectable != 'function', true); +assert_equal(typeof undetectable !== 'function', true); +assert_equal(typeof undetectable == 'function', false); +assert_equal(typeof undetectable === 'function', false); // Object -print(typeof undetectable != 'object'); -print(typeof undetectable !== 'object'); -print(typeof undetectable == 'object'); -print(typeof undetectable === 'object'); \ No newline at end of file +assert_equal(typeof undetectable != 'object', true); +assert_equal(typeof undetectable !== 'object', true); +assert_equal(typeof undetectable == 'object', false); +assert_equal(typeof undetectable === 'object', false); +test_end(); \ No newline at end of file diff --git a/test/moduletest/arktoolsgetundetectable/expect_output.txt b/test/moduletest/arktoolsgetundetectable/expect_output.txt deleted file mode 100755 index 60b5fdafe7..0000000000 --- a/test/moduletest/arktoolsgetundetectable/expect_output.txt +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (c) 2024 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 -true -false -false -true -true -false -false -true -true -false -false diff --git a/test/moduletest/arrayconcat/BUILD.gn b/test/moduletest/arrayconcat/BUILD.gn index 32dda9fb22..52dbb724c3 100644 --- a/test/moduletest/arrayconcat/BUILD.gn +++ b/test/moduletest/arrayconcat/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayconcat") { +host_moduletest_assert_action("arrayconcat") { deps = [] } diff --git a/test/moduletest/arrayconcat/arrayconcat.js b/test/moduletest/arrayconcat/arrayconcat.js index 61b8ebdd7b..cfe147e5f8 100644 --- a/test/moduletest/arrayconcat/arrayconcat.js +++ b/test/moduletest/arrayconcat/arrayconcat.js @@ -15,13 +15,13 @@ const array1 = ['a', 'b', 'c']; const array2 = ['d', 'e', 'f']; const array3 = array1.concat(array2); -print(array3); +assert_equal(array3.toString(), "a,b,c,d,e,f"); const letters = ["a", "b", "c"]; const numbers = [1, 2, 3]; const alphaNumeric = letters.concat(numbers); -print(alphaNumeric); +assert_equal(alphaNumeric.toString(), "a,b,c,1,2,3"); const num1 = [1, 2, 3]; const num2 = [4, 5, 6]; @@ -29,32 +29,32 @@ const num3 = [7, 8, 9]; const numbers1 = num1.concat(num2, num3); -print(numbers1); +assert_equal(numbers1.toString(), "1,2,3,4,5,6,7,8,9"); const letters1 = ["a", "b", "c"]; const alphaNumeric1 = letters1.concat(1, [2, 3]); -print(alphaNumeric1); +assert_equal(alphaNumeric1.toString(), "a,b,c,1,2,3"); const num11 = [[1]]; const num22 = [2, [3]]; const numbers2 = num1.concat(num22); -print(numbers2); +assert_equal(numbers2.toString(), "1,2,3,2,3"); // [[1], 2, [3]] num11[0].push(4); -print(numbers2); +assert_equal(numbers2.toString(), "1,2,3,2,3"); -print([1, , 3].concat([4, 5])); // [1, empty, 3, 4, 5] -print([1, 2].concat([3, , 5])); // [1, 2, 3, empty, 5] +assert_equal([1, , 3].concat([4, 5]).toString(), "1,,3,4,5"); // [1, empty, 3, 4, 5] +assert_equal([1, 2].concat([3, , 5]).toString(), "1,2,3,,5"); // [1, 2, 3, empty, 5] const emptyArr = []; -print(emptyArr.concat([]).length); +assert_equal(emptyArr.concat([]).length, 0); /* * @tc.name:Array concat1 @@ -73,7 +73,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(2000); let arr4 = arr3.concat(arr2); - print(arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004]); + assert_equal(arr4[2000], 1); + assert_equal(arr4[2001], 3); + assert_equal(arr4[2002], 2); + assert_equal(arr4[2003].toString(), "ab"); + assert_equal(arr4[2004], 1); } /* @@ -93,7 +97,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(2000); let arr4 = arr3.concat(arr2); - print(arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004]); + assert_equal(arr4[2000], 1); + assert_equal(arr4[2001], 3); + assert_equal(arr4[2002], 2); + assert_equal(arr4[2003].toString(), "ab"); + assert_equal(arr4[2004], 1); } /* @@ -113,7 +121,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(10); let arr4 = arr3.concat(arr2); - print(arr4[10], arr4[11], arr4[12], arr4[13], arr4[14]); + assert_equal(arr4[10], 1); + assert_equal(arr4[11], 3); + assert_equal(arr4[12], 2); + assert_equal(arr4[13].toString(), "ab"); + assert_equal(arr4[14], 1); } /* @@ -129,7 +141,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(2000); let arr4 = arr3.concat(arr2); - print(arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004]); + assert_equal(arr4[2000].toString(), "undefined"); + assert_equal(arr4[2001], 3); + assert_equal(arr4[2002], 2); + assert_equal(arr4[2003], ab); + assert_equal(arr4[2004], 1); } /* @@ -145,7 +161,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(2000); let arr4 = arr3.concat(arr2); - print(arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004]); + assert_equal(arr4[2000].toString(), "undefined"); + assert_equal(arr4[2001], 3); + assert_equal(arr4[2002], 2); + assert_equal(arr4[2003].toString(), "ab"); + assert_equal(arr4[2004], 1); } /* @@ -161,7 +181,11 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(10); let arr4 = arr3.concat(arr2); - print(arr4[10], arr4[11], arr4[12], arr4[13], arr4[14]); + assert_equal(arr4[10].toString(), "undefined"); + assert_equal(arr4[11], 3); + assert_equal(arr4[12], 2); + assert_equal(arr4[13], ab); + assert_equal(arr4[14], 1); } /* @@ -178,7 +202,12 @@ print(emptyArr.concat([]).length); arr2[4] = 1; let arr3 = new Array(2000); let arr4 = arr3.concat(arr2); - print(arr4[0], arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004]); + assert_equal(arr4[0].toString(), "??"); + assert_equal(arr4[2000].toString(), "??"); + assert_equal(arr4[2001], 3); + assert_equal(arr4[2002], 2); + assert_equal(arr4[2003].toString(), "ab"); + assert_equal(arr4[2004], 1); } print("test arrayconcat success!"); @@ -186,10 +215,10 @@ print("test arrayconcat success!"); print("proxy defineproperty success!"); const v1 = [1, 2, "j", 9999, , 23]; const v2 = ["sss", 2, "j", , , ,"test"]; -print(v1.concat(v2)); +assert_equal(v1.concat(v2), "1,2,j,9999,,23,sss,2,j,,,,test"); let v3 = new Array(); v3.push('foo'); var v4 = ['bar']; var v5 = v3.concat(v4); -print(v5); \ No newline at end of file +assert_equal(v5.toString(), "foo,bar"); \ No newline at end of file -- Gitee