From 2965a6e3b4ab33888338a93a766df97fafe6573d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=9D=B0?= Date: Thu, 31 Jul 2025 10:18:53 +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/ICPZ97 Signed-off-by: 唐杰 --- test/moduletest/allocatearraybuffer/BUILD.gn | 2 +- .../allocatearraybuffer.js | 11 ++++---- .../allocatearraybuffer/expect_output.txt | 17 ------------- test/moduletest/allocatesizeoverflow/BUILD.gn | 2 +- .../allocatesizeoverflow.js | 3 ++- .../allocatesizeoverflow/expect_output.txt | 14 ----------- test/moduletest/arrayFindIndexCase/BUILD.gn | 2 +- .../arrayFindIndexCase/expect_output.txt | 21 ---------------- .../arrayFindIndexCase/findIndex.js | 17 +++++++------ test/moduletest/arrayPopCase/BUILD.gn | 2 +- test/moduletest/arrayPopCase/arrayPopCase.js | 8 +++--- .../moduletest/arrayPopCase/expect_output.txt | 16 ------------ test/moduletest/arrayconstructor/BUILD.gn | 2 +- .../arrayconstructor/arrayconstructor.js | 25 ++++++++++--------- .../arrayconstructor/expect_output.txt | 25 ------------------- test/moduletest/arrayderived/BUILD.gn | 2 +- test/moduletest/arrayderived/arrayderived.js | 18 +++++++------ .../moduletest/arrayderived/expect_output.txt | 22 ---------------- test/moduletest/arrayfillproto/BUILD.gn | 2 +- .../arrayfillproto/arrayfillproto.js | 9 ++++++- .../arrayfillproto/expect_output.txt | 14 ----------- test/moduletest/arrayfindlastindex/BUILD.gn | 2 +- .../arrayfindlastindex/arrayfindlastindex.js | 13 +++++----- .../arrayfindlastindex/expect_output.txt | 19 -------------- test/moduletest/arrayflat/BUILD.gn | 2 +- test/moduletest/arrayflat/arrayflat.js | 7 +++--- test/moduletest/arrayprotochange/BUILD.gn | 2 +- .../arrayprotochange/arrayprotochange.js | 6 +++-- .../arrayprotochange/expect_output.txt | 15 ----------- test/moduletest/arraypushproto/BUILD.gn | 2 +- .../arraypushproto/arraypushproto.js | 5 +++- .../arraypushproto/expect_output.txt | 14 ----------- test/moduletest/arrayslice/BUILD.gn | 2 +- test/moduletest/arrayslice/arrayslice.js | 11 ++++---- test/moduletest/arrayslice/expect_output.txt | 18 ------------- 35 files changed, 90 insertions(+), 262 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/arrayPopCase/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 100644 test/moduletest/arrayfindlastindex/expect_output.txt delete mode 100755 test/moduletest/arrayprotochange/expect_output.txt delete mode 100644 test/moduletest/arraypushproto/expect_output.txt delete mode 100644 test/moduletest/arrayslice/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..0e5796f1e5 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.toString(), "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").toString(), "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,8 @@ function SendableArrayBufferTest() { const v3 = new Proxy(SendableArrayBuffer, o1); new v3(); } catch (error) { - print(error); + 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/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..9551fab6c4 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(); \ No newline at end of file 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/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..96dc4d3f23 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,5 @@ Object.defineProperty(array, 0, { } }); const hasFirst = (element) => element == "first"; -print(array.findIndex(hasFirst)); +assert_equal(array.findIndex(hasFirst), 0); +test_end(); diff --git a/test/moduletest/arrayPopCase/BUILD.gn b/test/moduletest/arrayPopCase/BUILD.gn index 7464141965..77176bfeb8 100644 --- a/test/moduletest/arrayPopCase/BUILD.gn +++ b/test/moduletest/arrayPopCase/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayPopCase") { +host_moduletest_assert_action("arrayPopCase") { deps = [] } diff --git a/test/moduletest/arrayPopCase/arrayPopCase.js b/test/moduletest/arrayPopCase/arrayPopCase.js index eeb81a39fe..b69d623854 100644 --- a/test/moduletest/arrayPopCase/arrayPopCase.js +++ b/test/moduletest/arrayPopCase/arrayPopCase.js @@ -22,13 +22,15 @@ const plants = ['broccoli', 'cauliflower', 'cabbage', 'kale', 'tomato']; -print(plants.pop()); +assert_equal(plants.pop().toString(), "toma"); // Expected output: "tomato" -print(plants); +assert_equal(plants.toString(), "broccoli,cauliflower,cabbage,kale"); // Expected output: Array ["broccoli", "cauliflower", "cabbage", "kale"] plants.pop(); -print(plants); +assert_equal(plants.toString(), "broccoli,cauliflower,cabbage"); // Expected output: Array ["broccoli", "cauliflower", "cabbage"] + +test_end(); diff --git a/test/moduletest/arrayPopCase/expect_output.txt b/test/moduletest/arrayPopCase/expect_output.txt deleted file mode 100644 index 99d78e677e..0000000000 --- a/test/moduletest/arrayPopCase/expect_output.txt +++ /dev/null @@ -1,16 +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. - -tomato -broccoli,cauliflower,cabbage,kale -broccoli,cauliflower,cabbage 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..27d23aae33 100644 --- a/test/moduletest/arrayconstructor/arrayconstructor.js +++ b/test/moduletest/arrayconstructor/arrayconstructor.js @@ -20,50 +20,51 @@ function testSpeciesEffect() { 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() +test_end(); 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..cf7b854e5e 100755 --- a/test/moduletest/arrayderived/arrayderived.js +++ b/test/moduletest/arrayderived/arrayderived.js @@ -23,27 +23,27 @@ function testConstructorEffect() { // 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 } @@ -57,9 +57,11 @@ function testArrayprototypechange() { }) Array.prototype.__proto__ = newProto; let a = new Array(10); - print(a[1]); + assert_equal(a[1], 1); } testConstructorEffect() -testArrayprototypechange() \ No newline at end of file +testArrayprototypechange() + +test_end(); \ No newline at end of file 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..a07677692d 100644 --- a/test/moduletest/arrayfillproto/arrayfillproto.js +++ b/test/moduletest/arrayfillproto/arrayfillproto.js @@ -23,4 +23,11 @@ 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); + +test_end(); \ 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/arrayfindlastindex/BUILD.gn b/test/moduletest/arrayfindlastindex/BUILD.gn index 5415623086..31d93e0034 100644 --- a/test/moduletest/arrayfindlastindex/BUILD.gn +++ b/test/moduletest/arrayfindlastindex/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayfindlastindex") { +host_moduletest_assert_action("arrayfindlastindex") { deps = [] } diff --git a/test/moduletest/arrayfindlastindex/arrayfindlastindex.js b/test/moduletest/arrayfindlastindex/arrayfindlastindex.js index 7ff2f8c0f4..61a5d1053b 100644 --- a/test/moduletest/arrayfindlastindex/arrayfindlastindex.js +++ b/test/moduletest/arrayfindlastindex/arrayfindlastindex.js @@ -25,7 +25,7 @@ var index = a.findLastIndex(function(val){ return val === undefined; }); - print(index); + assert_equal(index, 2); })(); var arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; @@ -39,9 +39,9 @@ function testFunction(element, index, array) { for (let i = 0; i < 10; i++) arr2[i] = i; var result1 = arr1.findLastIndex(testFunction); -print(result1); +assert_equal(result1, 0); var result2 = arr2.findLastIndex(testFunction); -print(result2); +assert_equal(result2, 0); let arr3 = [1, 2, , 7, , undefined]; arr3.__proto__.push(9); @@ -50,7 +50,7 @@ arr3.__proto__.push(9); function fun1(element) { return element === 1; } -print(arr3.findLastIndex(fun1)); +assert_equal(arr3.findLastIndex(fun1), 0); arr3.__proto__.pop(9); arr3.__proto__.pop(9); arr3.__proto__.pop(9); @@ -60,7 +60,7 @@ let arr4 = [1, 2, 3, 4, 5, 6, 7, 8]; function func2(element, index, arr) { return element === 6; } -print(arr4.findLastIndex(func2)); +assert_equal(arr4.findLastIndex(func2), 5); //notFound let arr5 = new Array(5, 2, 7, 9, 20); @@ -68,4 +68,5 @@ function func3(element, index, arr) { arr.length = 3; return element === 100; } -print(arr5.findLastIndex(func3)); \ No newline at end of file +assert_equal(arr5.findLastIndex(func3), -1); +test_end(); \ No newline at end of file diff --git a/test/moduletest/arrayfindlastindex/expect_output.txt b/test/moduletest/arrayfindlastindex/expect_output.txt deleted file mode 100644 index 10dfc45620..0000000000 --- a/test/moduletest/arrayfindlastindex/expect_output.txt +++ /dev/null @@ -1,19 +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. - -2 -0 -0 -0 -5 --1 diff --git a/test/moduletest/arrayflat/BUILD.gn b/test/moduletest/arrayflat/BUILD.gn index 504879ce72..fe3b8c6a05 100644 --- a/test/moduletest/arrayflat/BUILD.gn +++ b/test/moduletest/arrayflat/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayflat") { +host_moduletest_assert_action("arrayflat") { deps = [] } diff --git a/test/moduletest/arrayflat/arrayflat.js b/test/moduletest/arrayflat/arrayflat.js index 041653e738..9f90bf0193 100644 --- a/test/moduletest/arrayflat/arrayflat.js +++ b/test/moduletest/arrayflat/arrayflat.js @@ -20,7 +20,7 @@ * @tc.require: issueI5NO8G issueI8FBM3 */ const input = [1, [2], [[3]]]; -print(input.flat(undefined)); +assert_equal(input.flat(undefined).toString(), "1,2,3"); { class MyArray extends Array { @@ -30,5 +30,6 @@ print(input.flat(undefined)); } const wannabe = new MyArray(); const flattened = wannabe.flat(Infinity); - print(flattened instanceof MyArray); -} \ No newline at end of file + assert_equal(flattened instanceof MyArray, true); +} +test_end(); \ No newline at end of file diff --git a/test/moduletest/arrayprotochange/BUILD.gn b/test/moduletest/arrayprotochange/BUILD.gn index 68f61dffc2..1b38b77e85 100755 --- a/test/moduletest/arrayprotochange/BUILD.gn +++ b/test/moduletest/arrayprotochange/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayprotochange") { +host_moduletest_assert_action("arrayprotochange") { deps = [] } diff --git a/test/moduletest/arrayprotochange/arrayprotochange.js b/test/moduletest/arrayprotochange/arrayprotochange.js index 01e695fd51..0084992240 100644 --- a/test/moduletest/arrayprotochange/arrayprotochange.js +++ b/test/moduletest/arrayprotochange/arrayprotochange.js @@ -23,5 +23,7 @@ var arr = [0, 1, 2, 3, 4]; var arr2 = [0, , , 3, 4]; arr2.__proto__ = arr; -print(arr2[1]); -print(arr2.at(1)); \ No newline at end of file +assert_equal(arr2[1], 1); +assert_equal(arr2.at(1), 1); + +test_end(); \ No newline at end of file diff --git a/test/moduletest/arrayprotochange/expect_output.txt b/test/moduletest/arrayprotochange/expect_output.txt deleted file mode 100755 index a45895c8a7..0000000000 --- a/test/moduletest/arrayprotochange/expect_output.txt +++ /dev/null @@ -1,15 +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. - -1 -1 diff --git a/test/moduletest/arraypushproto/BUILD.gn b/test/moduletest/arraypushproto/BUILD.gn index 40d37db466..8c7e1ab477 100644 --- a/test/moduletest/arraypushproto/BUILD.gn +++ b/test/moduletest/arraypushproto/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arraypushproto") { +host_moduletest_assert_action("arraypushproto") { deps = [] } diff --git a/test/moduletest/arraypushproto/arraypushproto.js b/test/moduletest/arraypushproto/arraypushproto.js index 141116edf1..a049e1e5c8 100644 --- a/test/moduletest/arraypushproto/arraypushproto.js +++ b/test/moduletest/arraypushproto/arraypushproto.js @@ -22,4 +22,7 @@ let arr1 = new Array(500); arr1.__proto__.push(1); let arr2 = new Array(500); let arr3 = arr1.concat(arr2); -print(arr3[0], arr3[500]); \ No newline at end of file +assert_equal(arr3[0], 1); +assert_equal(arr3[500], 1); + +test_end(); \ No newline at end of file diff --git a/test/moduletest/arraypushproto/expect_output.txt b/test/moduletest/arraypushproto/expect_output.txt deleted file mode 100644 index 8bbcbbbc7d..0000000000 --- a/test/moduletest/arraypushproto/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. - -1 1 \ No newline at end of file diff --git a/test/moduletest/arrayslice/BUILD.gn b/test/moduletest/arrayslice/BUILD.gn index 94bd687aaf..90495512ef 100644 --- a/test/moduletest/arrayslice/BUILD.gn +++ b/test/moduletest/arrayslice/BUILD.gn @@ -13,6 +13,6 @@ import("//arkcompiler/ets_runtime/test/test_helper.gni") -host_moduletest_action("arrayslice") { +host_moduletest_assert_action("arrayslice") { deps = [] } diff --git a/test/moduletest/arrayslice/arrayslice.js b/test/moduletest/arrayslice/arrayslice.js index b4eb9191b5..e0258b851b 100644 --- a/test/moduletest/arrayslice/arrayslice.js +++ b/test/moduletest/arrayslice/arrayslice.js @@ -27,12 +27,12 @@ Array.prototype.slice.apply(arr, [2, length]); arr.splice(length, 2, 127, undefined, 127, undefined); } - print(arr.length); + assert_equal(arr.length, 4); } var holey_array = [1, 2, 3, 4, 5,,,,,,]; -print(holey_array.slice(6, 7)[0]); -print(holey_array.slice(2, 3)[0]); +assert_equal(holey_array.slice(6, 7)[0].toString(), "undefined"); +assert_equal(holey_array.slice(2, 3)[0], 3); (function() { var array = [,]; @@ -41,7 +41,7 @@ print(holey_array.slice(2, 3)[0]); } array.__proto__.push(5); var narr = slice(); - print(Object.getOwnPropertyDescriptor(narr, 0)); + assert_equal(Object.getOwnPropertyDescriptor(narr, 0).toString(), "[object Object]"); })(); @@ -67,4 +67,5 @@ function f0() { v7.bind(); } runNearStackLimit(f0); -print("runNearStackLimit test success!"); \ No newline at end of file +print("runNearStackLimit test success!"); +test_end(); \ No newline at end of file diff --git a/test/moduletest/arrayslice/expect_output.txt b/test/moduletest/arrayslice/expect_output.txt deleted file mode 100644 index 062f2a8f64..0000000000 --- a/test/moduletest/arrayslice/expect_output.txt +++ /dev/null @@ -1,18 +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. - -4 -undefined -3 -[object Object] -runNearStackLimit test success! -- Gitee