From 14e83f196d626359047d5671c26bae112b6e8f69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=9D=B0?= Date: Tue, 29 Jul 2025 13:51:05 +0800 Subject: [PATCH] =?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.js | 8 ++--- .../allocatearraybuffer/expect_output.txt | 17 --------- test/moduletest/allocatesizeoverflow/BUILD.gn | 2 +- .../allocatesizeoverflow.js | 2 +- .../allocatesizeoverflow/expect_output.txt | 14 -------- .../arktoolsgetundetectable/BUILD.gn | 2 +- .../arktoolsgetundetectable.js | 24 ++++++------- test/moduletest/arrayFindIndexCase/BUILD.gn | 2 +- .../arrayFindIndexCase/expect_output.txt | 21 ----------- .../arrayFindIndexCase/findIndex.js | 16 ++++----- test/moduletest/arrayconcat/BUILD.gn | 2 +- test/moduletest/arrayconcat/arrayconcat.js | 36 +++++++++---------- test/moduletest/arrayconcat/expect_output.txt | 33 ----------------- test/moduletest/arrayconstructor/BUILD.gn | 2 +- .../arrayconstructor/arrayconstructor.js | 24 ++++++------- .../arrayconstructor/expect_output.txt | 25 ------------- test/moduletest/arrayderived/BUILD.gn | 2 +- test/moduletest/arrayderived/arrayderived.js | 17 ++++----- .../moduletest/arrayderived/expect_output.txt | 22 ------------ test/moduletest/arrayfillproto/BUILD.gn | 2 +- .../arrayfillproto/arrayfillproto.js | 7 +++- .../arrayfillproto/expect_output.txt | 14 -------- test/moduletest/arrayfindlast/BUILD.gn | 2 +- .../moduletest/arrayfindlast/arrayfindlast.js | 24 ++++++------- .../arrayfindlast/expect_output.txt | 26 -------------- 26 files changed, 88 insertions(+), 260 deletions(-) delete mode 100644 test/moduletest/allocatearraybuffer/expect_output.txt delete mode 100644 test/moduletest/allocatesizeoverflow/expect_output.txt delete mode 100644 test/moduletest/arrayFindIndexCase/expect_output.txt delete mode 100644 test/moduletest/arrayconcat/expect_output.txt delete mode 100644 test/moduletest/arrayconstructor/expect_output.txt delete mode 100755 test/moduletest/arrayderived/expect_output.txt delete mode 100644 test/moduletest/arrayfillproto/expect_output.txt delete mode 100755 test/moduletest/arrayfindlast/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 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..ed432c44db 100644 --- a/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js +++ b/test/moduletest/allocatesizeoverflow/allocatesizeoverflow.js @@ -23,5 +23,5 @@ v0.length = 2465979003; try { isNaN.apply(undefined, v0); } catch (error) { - print(error); + assert_equal(error, "TypeError: len is bigger than 2^32 - 1"); } 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..b423e27509 100755 --- a/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js +++ b/test/moduletest/arktoolsgetundetectable/arktoolsgetundetectable.js @@ -17,19 +17,19 @@ 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"); \ No newline at end of file diff --git a/test/moduletest/arrayFindIndexCase/BUILD.gn b/test/moduletest/arrayFindIndexCase/BUILD.gn index db14fd79d8..67290dbbc2 100644 --- a/test/moduletest/arrayFindIndexCase/BUILD.gn +++ b/test/moduletest/arrayFindIndexCase/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("findIndex") { +host_moduletest_assert_action("findIndex") { deps = [] } diff --git a/test/moduletest/arrayFindIndexCase/expect_output.txt b/test/moduletest/arrayFindIndexCase/expect_output.txt deleted file mode 100644 index 390336e3c3..0000000000 --- a/test/moduletest/arrayFindIndexCase/expect_output.txt +++ /dev/null @@ -1,21 +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. - -3 -1 -1 --1 -2 --1 -2 -0 \ No newline at end of file diff --git a/test/moduletest/arrayFindIndexCase/findIndex.js b/test/moduletest/arrayFindIndexCase/findIndex.js index 561459622d..bd96fd7c37 100644 --- a/test/moduletest/arrayFindIndexCase/findIndex.js +++ b/test/moduletest/arrayFindIndexCase/findIndex.js @@ -22,7 +22,7 @@ const array1 = [5, 12, 8, 130, 44]; const isLargeNumber = (element) => element > 13; -print(array1.findIndex(isLargeNumber)); +assert_equal(array1.findIndex(isLargeNumber), "3"); const arrayLike = { length: 3, @@ -30,8 +30,8 @@ const arrayLike = { 1: 7.3, 2: 4, }; -print(Array.prototype.findIndex.call(arrayLike, (x) => !Number.isInteger(x))); -print([1, , 3].findIndex((x) => x === undefined)); +assert_equal(Array.prototype.findIndex.call(arrayLike, (x) => !Number.isInteger(x)), "1"); +assert_equal([1, , 3].findIndex((x) => x === undefined), "1"); function isPrime(element) { if (element % 2 === 0 || element < 2) { return false; @@ -43,16 +43,16 @@ function isPrime(element) { } return true; } -print([4, 6, 8, 9, 12].findIndex(isPrime)); -print([4, 6, 7, 9, 12].findIndex(isPrime)); +assert_equal([4, 6, 8, 9, 12].findIndex(isPrime), "-1"); +assert_equal([4, 6, 7, 9, 12].findIndex(isPrime), "2"); const words = ["spray", "limit", "limits"]; const deleteWords = words.findIndex((word, index, arr) => { arr.length=2 return word == "limits" }); -print(deleteWords); -print(words.length); +assert_equal(deleteWords, "-1"); +assert_equal(words.length, "2"); var array = ["first", "second"]; Object.defineProperty(array, 0, { @@ -62,4 +62,4 @@ Object.defineProperty(array, 0, { } }); const hasFirst = (element) => element == "first"; -print(array.findIndex(hasFirst)); +assert_equal(array.findIndex(hasFirst), "0"); 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..1c50026641 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, "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, "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, "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, "a,b,c,1,2,3"); const num11 = [[1]]; const num22 = [2, [3]]; const numbers2 = num1.concat(num22); -print(numbers2); +assert_equal(numbers2, "1,2,3,2,3"); // [[1], 2, [3]] num11[0].push(4); -print(numbers2); +assert_equal(numbers2, "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]), "1,,3,4,5"); // [1, empty, 3, 4, 5] +assert_equal([1, 2].concat([3, , 5]), "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,7 @@ 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], arr4[2001], arr4[2002], arr4[2003], arr4[2004], "1 3 2 ab 1"); } /* @@ -93,7 +93,7 @@ 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], arr4[2001], arr4[2002], arr4[2003], arr4[2004], "1 3 2 ab 1"); } /* @@ -113,7 +113,7 @@ 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], arr4[11], arr4[12], arr4[13], arr4[14], "1 3 2 ab 1"); } /* @@ -129,7 +129,7 @@ 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], arr4[2001], arr4[2002], arr4[2003], arr4[2004], "undefined 3 2 ab 1"); } /* @@ -145,7 +145,7 @@ 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], arr4[2001], arr4[2002], arr4[2003], arr4[2004], "undefined 3 2 ab 1"); } /* @@ -161,7 +161,7 @@ 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], arr4[11], arr4[12], arr4[13], arr4[14], "undefined 3 2 ab 1"); } /* @@ -178,7 +178,7 @@ 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], arr4[2000], arr4[2001], arr4[2002], arr4[2003], arr4[2004], "?? ?? 3 2 ab 1"); } print("test arrayconcat success!"); @@ -186,10 +186,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, "foo,bar"); \ No newline at end of file diff --git a/test/moduletest/arrayconcat/expect_output.txt b/test/moduletest/arrayconcat/expect_output.txt deleted file mode 100644 index a6718a7e42..0000000000 --- a/test/moduletest/arrayconcat/expect_output.txt +++ /dev/null @@ -1,33 +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. - -a,b,c,d,e,f -a,b,c,1,2,3 -1,2,3,4,5,6,7,8,9 -a,b,c,1,2,3 -1,2,3,2,3 -1,2,3,2,3 -1,,3,4,5 -1,2,3,,5 -0 -1 3 2 ab 1 -1 3 2 ab 1 -1 3 2 ab 1 -undefined 3 2 ab 1 -undefined 3 2 ab 1 -undefined 3 2 ab 1 -?? ?? 3 2 ab 1 -test arrayconcat success! -proxy defineproperty success! -1,2,j,9999,,23,sss,2,j,,,,test -foo,bar diff --git a/test/moduletest/arrayconstructor/BUILD.gn b/test/moduletest/arrayconstructor/BUILD.gn index 181d7c860b..efaa1c9acc 100644 --- a/test/moduletest/arrayconstructor/BUILD.gn +++ b/test/moduletest/arrayconstructor/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayconstructor") { +host_moduletest_assert_action("arrayconstructor") { deps = [] } diff --git a/test/moduletest/arrayconstructor/arrayconstructor.js b/test/moduletest/arrayconstructor/arrayconstructor.js index f0757d1afa..db6f74feeb 100644 --- a/test/moduletest/arrayconstructor/arrayconstructor.js +++ b/test/moduletest/arrayconstructor/arrayconstructor.js @@ -19,51 +19,49 @@ function testSpeciesEffect() { let custom = [1,2,3,4,5,6,7,8,9] custom.constructor = CustomArray; - print("Testing methods affected by constructor:"); - // Array.prototype.concat let result = custom.concat([4, 5]); - print("concat:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.map result = custom.map(x => x * 2); - print("map:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.filter result = custom.filter(x => x > 1); - print("filter:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.slice result = custom.slice(1); - print("slice:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.flatMap result = custom.flatMap(x => [x, x * 2]); - print("flatMap:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.flat result = custom.flat(); - print("flat:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.splice result = custom.splice(1,2,3); - print("splice:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.toReversed result = custom.toReversed(); - print("toReversed:", result instanceof Array); // true + assert_equal(result instanceof Array, "true"); // true // Array.prototype.toSorted result = custom.toSorted(); - print("toSorted:", result instanceof Array); // true + assert_equal(result instanceof Array, "true"); // true // Array.prototype.toSpliced result = custom.toSpliced(0,1); - print("toSpliced:", result instanceof Array); // true + assert_equal(result instanceof Array, "true"); // true // Array.prototype.toSpliced result = custom.with(0,1); - print("with:", result instanceof Array); // true + assert_equal(result instanceof Array, "true"); // true } testSpeciesEffect() diff --git a/test/moduletest/arrayconstructor/expect_output.txt b/test/moduletest/arrayconstructor/expect_output.txt deleted file mode 100644 index 1d812d0d70..0000000000 --- a/test/moduletest/arrayconstructor/expect_output.txt +++ /dev/null @@ -1,25 +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. - -Testing methods affected by constructor: -concat: true -map: true -filter: true -slice: true -flatMap: true -flat: true -splice: true -toReversed: true -toSorted: true -toSpliced: true -with: true diff --git a/test/moduletest/arrayderived/BUILD.gn b/test/moduletest/arrayderived/BUILD.gn index 185dab8938..c684252f48 100755 --- a/test/moduletest/arrayderived/BUILD.gn +++ b/test/moduletest/arrayderived/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayderived") { +host_moduletest_assert_action("arrayderived") { deps = [] } diff --git a/test/moduletest/arrayderived/arrayderived.js b/test/moduletest/arrayderived/arrayderived.js index d2a344cee6..9d018b28b7 100755 --- a/test/moduletest/arrayderived/arrayderived.js +++ b/test/moduletest/arrayderived/arrayderived.js @@ -19,36 +19,33 @@ class CustomArray extends Array {} function testConstructorEffect() { let custom = new CustomArray(1, 2, 3); - print("Testing methods affected by constructor:"); - // Array.prototype.concat let result = custom.concat([4, 5]); - print("concat:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.map result = custom.map(x => x * 2); - print("map:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.filter result = custom.filter(x => x > 1); - print("filter:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.slice result = custom.slice(1); - print("slice:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.flatMap result = custom.flatMap(x => [x, x * 2]); - print("flatMap:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true // Array.prototype.flat result = custom.flat(); - print("flat:", result instanceof CustomArray); // true + assert_equal(result instanceof CustomArray, "true"); // true } function testArrayprototypechange() { - print("Testing array when Array's prototype changed.") let newProto = {}; Object.defineProperty(newProto, '1', { get: function() { @@ -57,7 +54,7 @@ function testArrayprototypechange() { }) Array.prototype.__proto__ = newProto; let a = new Array(10); - print(a[1]); + assert_equal(a[1], "1"); } testConstructorEffect() diff --git a/test/moduletest/arrayderived/expect_output.txt b/test/moduletest/arrayderived/expect_output.txt deleted file mode 100755 index bc4856fe58..0000000000 --- a/test/moduletest/arrayderived/expect_output.txt +++ /dev/null @@ -1,22 +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. - -Testing methods affected by constructor: -concat: true -map: true -filter: true -slice: true -flatMap: true -flat: true -Testing array when Array's prototype changed. -1 \ No newline at end of file diff --git a/test/moduletest/arrayfillproto/BUILD.gn b/test/moduletest/arrayfillproto/BUILD.gn index 3d93459c01..306ebd16d8 100644 --- a/test/moduletest/arrayfillproto/BUILD.gn +++ b/test/moduletest/arrayfillproto/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayfillproto") { +host_moduletest_assert_action("arrayfillproto") { deps = [] } diff --git a/test/moduletest/arrayfillproto/arrayfillproto.js b/test/moduletest/arrayfillproto/arrayfillproto.js index 78170888ce..2810fc8dbe 100644 --- a/test/moduletest/arrayfillproto/arrayfillproto.js +++ b/test/moduletest/arrayfillproto/arrayfillproto.js @@ -23,4 +23,9 @@ arr1.__proto__.length = 10; arr1.__proto__.fill(233, 0, 7); let arr2 = new Array(500); let arr3 = arr1.concat(arr2); -print(arr3[0], arr3[1], arr3[2], arr3[500], arr3[501], arr3[502]); \ No newline at end of file +assert_equal(arr3[0], "233"); +assert_equal(arr3[1], "233"); +assert_equal(arr3[2], "233"); +assert_equal(arr3[500], "233"); +assert_equal(arr3[501], "233"); +assert_equal(arr3[502], "233"); \ No newline at end of file diff --git a/test/moduletest/arrayfillproto/expect_output.txt b/test/moduletest/arrayfillproto/expect_output.txt deleted file mode 100644 index 6b22c2372c..0000000000 --- a/test/moduletest/arrayfillproto/expect_output.txt +++ /dev/null @@ -1,14 +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. - -233 233 233 233 233 233 \ No newline at end of file diff --git a/test/moduletest/arrayfindlast/BUILD.gn b/test/moduletest/arrayfindlast/BUILD.gn index 4afb17fad3..f559d60a2b 100755 --- a/test/moduletest/arrayfindlast/BUILD.gn +++ b/test/moduletest/arrayfindlast/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayfindlast") { +host_moduletest_assert_action("arrayfindlast") { deps = [] } diff --git a/test/moduletest/arrayfindlast/arrayfindlast.js b/test/moduletest/arrayfindlast/arrayfindlast.js index 3b7a4826cd..b439c95233 100644 --- a/test/moduletest/arrayfindlast/arrayfindlast.js +++ b/test/moduletest/arrayfindlast/arrayfindlast.js @@ -26,11 +26,11 @@ result = arr.findLast((element, index, array) => { array.length = 5; return (element == 5); }); -print(result); +assert_equal(result, "undefined"); result = arr.findLast((element) => { return element > 2; }); -print(result); +assert_equal(result, "4"); result = arr.findLastIndex((element, index, array) => { if (array.length == 5) { @@ -38,28 +38,28 @@ result = arr.findLastIndex((element, index, array) => { } return (element == 100); }); -print(result); +assert_equal(result, "-1"); result = arr.findLastIndex((element, index, array) => { return (element == 100); }); -print(result); +assert_equal(result, "5"); var arr2 = new Array(1025); result = arr2.findLast((element, index, array) => { return (element == undefined); }); -print(result); +assert_equal(result, "undefined"); result = arr2.findLastIndex((element, index, array) => { return (element == undefined); }); -print(result); +assert_equal(result, "1024"); result = arr2.findLastIndex((element, index, array) => { array[5] = 100; return (element == 100); }); -print(result); +assert_equal(result, "5"); var arr3 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var arr4 = new Array(); @@ -72,9 +72,9 @@ function testFunction(element, index, array) { for (let i = 0; i < 10; i++) arr4[i] = i; result = arr3.findLast(testFunction); -print(result); +assert_equal(result, "0"); result = arr4.findLast(testFunction); -print(result); +assert_equal(result, "0"); let arr1 = [1, 2, , 7, , undefined]; arr1.__proto__.push(9); @@ -83,7 +83,7 @@ arr1.__proto__.push(9); function fun1(element){ return element === 1; } -print(arr1.findLast(fun1)); +assert_equal(arr1.findLast(fun1), "1"); arr1.__proto__.pop(9); arr1.__proto__.pop(9); arr1.__proto__.pop(9); @@ -93,7 +93,7 @@ let arr5 = [1, 2, 3, 4, 5, 6, 7, 8]; function func2(element, index, arr) { return element === 6; } -print(arr5.findLast(func2)); +assert_equal(arr5.findLast(func2), "6"); //notFound let arr6 = new Array(5, 2, 7); @@ -101,7 +101,7 @@ function func3(element, index, arr) { arr.length = 3; return element === 100; } -print(arr6.findLast(func3)); +assert_equal(arr6.findLast(func3), "undefined"); { function call(obj, ...args) { diff --git a/test/moduletest/arrayfindlast/expect_output.txt b/test/moduletest/arrayfindlast/expect_output.txt deleted file mode 100755 index 2389e38ae4..0000000000 --- a/test/moduletest/arrayfindlast/expect_output.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 -4 --1 -5 -undefined -1024 -5 -0 -0 -1 -6 -undefined -test findeLast & pop success -- Gitee