diff --git a/test/moduletest/allocatearraybuffer/BUILD.gn b/test/moduletest/allocatearraybuffer/BUILD.gn index 8a192e777588da2b9eb9ba086630d414ecfdb278..50a29eb99ea9c2c3ee3c6d8b134cd49aa72a9552 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 0e5a07d549ce9fda4da7b6abe50b040f9b620123..b6ed2b7daedfe44f0aaef53ac21de1e1a5faa568 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 5fd9e962a359b02511ec76f82633c98d8d966fb4..0000000000000000000000000000000000000000 --- 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 bf27d97bd43450895e43dfa8e4b0e91a95d7c990..fce3db02e874e2185d8f0410c9684c47efa5152e 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 29083188bc0b10340214567bdf6b6b92252d9f07..ed432c44dbf777a011be9c7d98079034d80edb1c 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 518afaa244669fe56de958219a24f14c1aa9eae8..0000000000000000000000000000000000000000 --- 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 e08d61b7f294f871dfac35d72276093301f962ae..e9b090f9086dcd2d3b2edb2c19e61966c2904930 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 14bc49ab4fe1809f29e80b582af103877249ae11..b423e27509133f618655895f1a41db4a4adf5804 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 db14fd79d8b71e7e71c672bb6f2f67a1705d1cca..67290dbbc292086a4bd48fd054d400018686386e 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 390336e3c3e6124def65864ce86d972240e8cbc3..0000000000000000000000000000000000000000 --- 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 561459622dc10a5c750a1ef37853c90c78813656..bd96fd7c379610ef724f4bbe062f0c7a3135439f 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 32dda9fb22784fc839763569b93b9ae22f4951c6..52dbb724c3222c35aab5b3c6bac7b339deb2fdeb 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 61b8ebdd7bc689420d73dee8ea13672d73a394fd..1c50026641a37b32dcedb8bc0c7c8ff9645ea36b 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 a6718a7e42455aef61f64b1d372f9445e4ec828c..0000000000000000000000000000000000000000 --- 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 181d7c860b15d7ee4810f7f90836abd92cc06aa3..efaa1c9acc75de8fc2a23f5e6450a6631a7fb4f5 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 f0757d1afa782436b3591439b081affcb37e263d..db6f74feebc977b8f85df8e78b192ebec89eef17 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 1d812d0d70112c67daea25f328d12cdb1e1de779..0000000000000000000000000000000000000000 --- 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 185dab893841209d30eec420e59deb20f34ee25f..c684252f48c76192039ae410da73ddc37bd8357c 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 d2a344cee6a8c02edc2347d2e0a0b167305b6f1d..9d018b28b7c5a7b3961566e9fe45f260d3193efe 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 bc4856fe588cfa1f9d2da30c2bb945e17bd370f6..0000000000000000000000000000000000000000 --- 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 3d93459c01a7a86fdd7f90f280b93b541d0c9ff3..306ebd16d827866dccbba98e7ab11242fe10fffa 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 78170888ce10919c764334bdea5a155aaf23de49..2810fc8dbef9a6adea1de88c96e9166a27c3652c 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 6b22c2372cff2098a01fd080fbb516ff3c652f25..0000000000000000000000000000000000000000 --- 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 4afb17fad30f070b09e7dc491e44cf612ed1fbed..f559d60a2b68e4c62e9e4bb4aa1fe5af25a444aa 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 3b7a4826cd5cd8439f58f8d26a9798032da0807c..b439c95233cdad3304d96a1fff15466633b23217 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 2389e38ae41d88c2374e2195e8018bf04c517bef..0000000000000000000000000000000000000000 --- 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