From 842a1174584d53f2a06439814ef067993aa76e2d Mon Sep 17 00:00:00 2001 From: nickgorodilov Date: Mon, 25 Aug 2025 15:37:28 +0400 Subject: [PATCH] Add and fix async methods tests for Ch. 16.3.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue:https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICVIKW Testing: all pre-merge tests passed, logs available in ggWatcher Signed-off-by: Iaroslav_Antonov --- .../modules/mod1.ets | 2 +- .../default_import_const_var_binding.ets | 2 +- .../default_import_const_var_binding_neg.ets | 2 +- ...c_function_returns_promise_predefined0.ets | 19 ++++ .../03.async_methods/ameth.ets | 8 +- .../03.async_methods/ameth.params.yaml | 105 ++++++++++-------- .../{async_method23.ets => ameth_48_old.ets} | 39 ++++--- .../03.async_methods/async_method0.ets | 35 ------ .../03.async_methods/async_method10.ets | 4 +- .../03.async_methods/async_method12.ets | 35 ------ .../03.async_methods/async_method15.ets | 6 +- .../03.async_methods/async_method16.ets | 36 ------ .../03.async_methods/async_method17.ets | 16 ++- .../03.async_methods/async_method18.ets | 2 +- .../03.async_methods/async_method19.ets | 4 +- .../03.async_methods/async_method20.ets | 2 +- .../03.async_methods/async_method21.ets | 4 +- .../03.async_methods/async_method22.ets | 2 +- .../03.async_methods/async_method24.ets | 2 +- .../03.async_methods/async_method25.ets | 2 +- .../03.async_methods/async_method26.ets | 2 +- .../03.async_methods/async_method27.ets | 7 +- .../03.async_methods/async_method28.ets | 2 +- .../03.async_methods/async_method29.ets | 2 +- .../03.async_methods/async_method3.ets | 36 ------ .../03.async_methods/async_method30.ets | 2 +- .../03.async_methods/async_method4.ets | 2 +- .../03.async_methods/async_method5.ets | 2 +- .../03.async_methods/async_method6.ets | 2 +- .../03.async_methods/async_method7.ets | 4 +- .../03.async_methods/async_method8.ets | 2 +- .../03.async_methods/async_method9.ets | 2 +- ...ync_method_returns_promise_predefined0.ets | 19 ++++ ...ync_method_returns_promise_predefined1.ets | 19 ++++ .../async_method_returns_void.ets} | 59 +++++++--- ...async_method_with_promise_with_return.ets} | 19 ++-- ...nc_method_with_promise_without_return.ets} | 18 ++- ...nc_method_without_promise_with_return.ets} | 19 ++-- ...method_without_promise_without_return.ets} | 18 ++- .../async_returns_predefined0.base.jinja | 73 ++++++++++++ .../async_returns_predefined1.base.jinja | 72 ++++++++++++ .../predefined_types.jinja | 98 ++++++++++++++++ .../test-lists/ets-cts/ets-cts-ignored.txt | 5 + .../plugins/ets/ets_templates/template.py | 11 +- 44 files changed, 519 insertions(+), 303 deletions(-) create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/01.async_functions/return_type_is_promise/no_input_params/predefined_types/async_function_returns_promise_predefined0.ets rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method23.ets => ameth_48_old.ets} (50%) mode change 100644 => 100755 delete mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method0.ets delete mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method12.ets delete mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method16.ets delete mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method3.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined0.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined1.ets rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method11.ets => return_type_is_promise/no_input_params/predefined_types/async_method_returns_void.ets} (33%) rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method14.ets => return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_with_return.ets} (69%) rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method2.ets => return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_without_return.ets} (69%) rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method1.ets => return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_with_return.ets} (70%) rename static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/{async_method13.ets => return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_without_return.ets} (71%) create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined1.base.jinja create mode 100644 static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/01.bind_all_with_qualified_access/modules/mod1.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/01.bind_all_with_qualified_access/modules/mod1.ets index 187bcc0379..c2d73815bb 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/01.bind_all_with_qualified_access/modules/mod1.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/01.bind_all_with_qualified_access/modules/mod1.ets @@ -28,4 +28,4 @@ export class C { foo(): int { return 3 } -} +} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding.ets index ac03e52b47..c4d9e3065e 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding.ets @@ -23,4 +23,4 @@ import {default as const_var} from "../../05.top-level_declarations/01.exported_ function main(): void { arktest.assertEQ(const_var, 2); -} +} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding_neg.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding_neg.ets index 44ac1386a2..f98e302b54 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding_neg.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/02.import_directives/02.default_import_binding/default_import_const_var_binding_neg.ets @@ -24,4 +24,4 @@ import {default as const_var} from "../../05.top-level_declarations/01.exported_ function main(): void { const_var = 3 -} +} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/01.async_functions/return_type_is_promise/no_input_params/predefined_types/async_function_returns_promise_predefined0.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/01.async_functions/return_type_is_promise/no_input_params/predefined_types/async_function_returns_promise_predefined0.ets new file mode 100644 index 0000000000..399c3bb605 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/01.async_functions/return_type_is_promise/no_input_params/predefined_types/async_function_returns_promise_predefined0.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024-2025 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. + */ + +{% from 'ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja' import numeric_types_cases, boolean_types_cases, symbol_types_cases, no_value_types_cases %} +{% from 'ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja' import generate_complete_test %} + +{{ generate_complete_test(numeric_types_cases + boolean_types_cases + symbol_types_cases + no_value_types_cases, 'function') }} diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.ets index 432e6534f7..689fa321b6 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.ets @@ -20,7 +20,13 @@ desc: The method async is an implicit coroutine that can be called as a regular {{c.decl}} -function main() { +async function startTest() { {{c.use|indent}} } + + +function main(){ + waitForCompletion(startTest); +} + {% endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.params.yaml b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.params.yaml index acb7bf76fe..2f2b427786 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth.params.yaml @@ -20,7 +20,7 @@ cases: use: |- // Promise of void let r = new A().foo() - arktest.assertTrue((await r) == undefined) + arktest.assertEQ((await r), undefined) - decl: |- class A { @@ -30,7 +30,7 @@ cases: } use: |- // Promise of primitive - arktest.assertTrue((await new A().foo(42)) == 84) + arktest.assertEQ((await new A().foo(42)), 84) - decl: |- class A { @@ -40,7 +40,7 @@ cases: } use: |- // Promise of primitive - arktest.assertTrue((await new A().foo(42)) == 84) + arktest.assertEQ((await new A().foo(42)), 84) - decl: |- class A { @@ -50,7 +50,7 @@ cases: } use: |- // Promise of boxed - arktest.assertTrue((await new A().foo(new Double(42.0))) == 84.0) + arktest.assertEQ((await new A().foo(new Double(42.0))), 84.0) - decl: |- class A { @@ -60,7 +60,7 @@ cases: } use: |- // Promise of boxed - arktest.assertTrue((await new A().foo(new Double(42.0))) == 84.0) + arktest.assertEQ((await new A().foo(new Double(42.0))), 84.0) - decl: |- class A { @@ -71,7 +71,7 @@ cases: use: |- // Promise of string let r = new A().foo(42) - arktest.assertTrue((await r) == '42') + arktest.assertEQ((await r), '42') - decl: |- class A { @@ -82,7 +82,7 @@ cases: use: |- // Promise of string let r = new A().foo(42) - arktest.assertTrue((await r) == '4242') + arktest.assertEQ((await r), '4242') - decl: |- class A { @@ -132,7 +132,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -142,7 +142,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -152,7 +152,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -162,7 +162,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -172,7 +172,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -185,7 +185,7 @@ cases: } use: |- // Promise of nullish - arktest.assertTrue((await new A().foo(42)) == 43) + arktest.assertEQ((await new A().foo(42)), 43) - decl: |- class A { @@ -199,7 +199,7 @@ cases: } use: |- // Promise of promise - arktest.assertTrue((await new A().bar('A')) == 'AA') + arktest.assertEQ((await new A().bar('A')), 'AA') - decl: |- class A { @@ -213,7 +213,7 @@ cases: } use: |- // Promise of promise - arktest.assertTrue((await new A().bar('A')) == 'AA') + arktest.assertEQ((await new A().bar('A')), 'AA') - decl: |- class A { @@ -224,7 +224,10 @@ cases: use: |- // Promise of array let q: int[] = await new A().foo() - arktest.assertTrue(q[0] == 1 && q[1] == 2 && q[2] == 3) + //arktest.assertTrue(q[0] == 1 && q[1] == 2 && q[2] == 3) + arktest.assertEQ(q[0], 1) + arktest.assertEQ(q[1], 2) + arktest.assertEQ(q[2], 3) - decl: |- class A { @@ -235,7 +238,12 @@ cases: use: |- // Promise of array let q: int[] = await new A().foo() - arktest.assertTrue(q[0] == 1 && q[1] == 2 && q[2] == 3) + //arktest.assertTrue(q[0] == 1 && q[1] == 2 && q[2] == 3) + arktest.assertEQ(q[0], 1) + arktest.assertEQ(q[1], 2) + arktest.assertEQ(q[2], 3) + arktest.assertEQ(q.length, 3) + - decl: |- class A { @@ -245,7 +253,7 @@ cases: } use: |- // Promise of function - arktest.assertTrue((await new A().foo())('A') == 'AA') + arktest.assertEQ((await new A().foo())('A'), 'AA') - decl: |- type FT = (p: string) => string @@ -257,7 +265,7 @@ cases: } use: |- // Promise of function - arktest.assertTrue((await new A().foo())('A') == 'AA') + arktest.assertEQ((await new A().foo())('A'), 'AA') - decl: |- type UT = number | string | boolean @@ -269,7 +277,7 @@ cases: use: |- // Promise of union let q: boolean|number|string = await new A().foo(-1) - arktest.assertTrue(q as string == '-1') + arktest.assertEQ(q as string, '-1') - decl: |- type UT = number | string | boolean @@ -282,7 +290,7 @@ cases: use: |- // Promise of union let q: boolean|number|string = await new A().foo(-1) - arktest.assertTrue(q as string == '-1') + arktest.assertEQ(q as string, '-1') - decl: |- class A { @@ -293,7 +301,9 @@ cases: use: |- // Promise of tuple let q: [Boolean, Error] = await new A().foo(42) - arktest.assertTrue(q[0] && (q[1] instanceof Error)) + arktest.assertEQ(q[0], true) + arktest.assertTrue(q[1] instanceof Error) + - decl: |- class A { @@ -304,7 +314,8 @@ cases: use: |- // Promise of tuple let q: [Boolean, Error] = await new A().foo(42) - arktest.assertTrue(q[0] && (q[1] instanceof Error)) + arktest.assertEQ(q[0], true) + arktest.assertTrue(q[1] instanceof Error) - decl: |- class A { @@ -315,7 +326,7 @@ cases: use: |- // Promise of BigInt let q: BigInt = await new A().foo('123456789012345678901234567890') - arktest.assertTrue(q == 123456789012345678901234567890n) + arktest.assertEQ(q, 123456789012345678901234567890n) - decl: |- class A { @@ -326,7 +337,7 @@ cases: use: |- // Promise of BigInt let q: BigInt = await new A().foo('123456789012345678901234567890') - arktest.assertTrue(q == 123456789012345678901234567890n) + arktest.assertEQ(q, 123456789012345678901234567890n) - decl: |- class A { @@ -337,7 +348,7 @@ cases: use: |- // Promise of bigint let q: bigint = await new A().foo(123456789012345678901234567890n) - arktest.assertTrue(q == 123456789012345678901234567890n) + arktest.assertEQ(q, 123456789012345678901234567890n) - decl: |- class A { @@ -348,7 +359,7 @@ cases: use: |- // Promise of bigint let q: bigint = await new A().foo(123456789012345678901234567890n) - arktest.assertTrue(q == 123456789012345678901234567890n) + arktest.assertEQ(q, 123456789012345678901234567890n) - decl: |- class B { @@ -374,7 +385,7 @@ cases: ] let cnt = 0.0 for (let v of arr) cnt += (await v) - arktest.assertTrue(cnt == 90.0) + arktest.assertEQ(cnt, 90.0) - decl: |- class A { @@ -398,7 +409,7 @@ cases: ] let cnt = 0.0 for (let v of arr) cnt += (await v) - arktest.assertTrue(cnt == 90.0) + arktest.assertEQ(cnt, 90.0) - decl: |- enum Color { Red, Green, Blue } @@ -409,7 +420,7 @@ cases: } use: |- // Promise of enum - arktest.assertTrue((await new A().foo(42)) == Color.Green) + arktest.assertEQ((await new A().foo(42)), Color.Green) - decl: |- enum Color { Red, Green, Blue } @@ -420,7 +431,7 @@ cases: } use: |- // Promise of enum - arktest.assertTrue((await new A().foo(42)) == Color.Green) + arktest.assertEQ((await new A().foo(42)), Color.Green) - decl: |- enum Color { R="red", G="green", B="blue" } @@ -431,7 +442,7 @@ cases: } use: |- // Promise of string-based enum - arktest.assertTrue((await new A().foo(-42)) == Color.B) + arktest.assertEQ((await new A().foo(-42)), Color.B) - decl: |- enum Color { R="red", G="green", B="blue" } @@ -442,7 +453,7 @@ cases: } use: |- // Promise of string-based enum - arktest.assertTrue((await new A().foo(-42)) == Color.B) + arktest.assertEQ((await new A().foo(-42)), Color.B) - decl: |- class B { @@ -463,7 +474,7 @@ cases: use: |- // Promise of T let a: A = new A("abc") - arktest.assertTrue(a.meth() == "abc") + arktest.assertEQ(a.meth(), "abc") - decl: |- class B { @@ -487,7 +498,7 @@ cases: use: |- // Promise of T let a: A = new A("abc") - arktest.assertTrue(a.meth() == "abc") + arktest.assertEQ(a.meth(), "abc") - decl: |- class A { @@ -501,7 +512,7 @@ cases: use: |- // Promise in object literal let a: A = { fld: new B().foo(42.0) } - arktest.assertTrue((await a.fld!) == '42') + arktest.assertEQ((await a.fld!), '42') - decl: |- class A { @@ -515,7 +526,7 @@ cases: use: |- // Promise in object literal let a: A = { fld: B.foo(42.0) } - arktest.assertTrue((await a.fld!) == '42') + arktest.assertEQ((await a.fld!), '42') - decl: |- let s = 'ABC' @@ -527,7 +538,7 @@ cases: use: |- // Launch in argument lambda let r = await new A().foo((): Promise => (async (): Promise => s)()) - arktest.assertTrue(r == 'ABC') + arktest.assertEQ(r, 'ABC') - decl: |- let s = 'ABC' @@ -539,7 +550,7 @@ cases: use: |- // Launch in argument lambda let r = await new A().foo((): Promise => (async (): Promise => s)()) - arktest.assertTrue(r == 'ABC') + arktest.assertEQ(r, 'ABC') - decl: |- let s = 'ABC' @@ -551,7 +562,7 @@ cases: use: |- // Launch in trailing lambda let r = await new A().foo(async (): Promise => s) - arktest.assertTrue(r == 'ABC') + arktest.assertEQ(r, 'ABC') - decl: |- let s = 'ABC' @@ -563,7 +574,7 @@ cases: use: |- // Launch in trailing lambda let r = await A.foo(async (): Promise => s) - arktest.assertTrue(r == 'ABC') + arktest.assertEQ(r, 'ABC') - decl: |- let s = 'A' @@ -578,7 +589,7 @@ cases: .then((p: string): string => p + p) .then((p: string): string => p + p) - arktest.assertTrue((await r) == 'AAAAAAAA') + arktest.assertEQ((await r), 'AAAAAAAA') - decl: |- type EN = Error|null @@ -598,7 +609,7 @@ cases: .catch((p: EN): string => p!.message) .then((p: string): string => p + p) - arktest.assertTrue((await r) == 'EE') + arktest.assertEQ((await r), 'EE') - decl: |- type EN = Error|null @@ -614,7 +625,7 @@ cases: .then((p: string): string => { throw new Error(p) }) .catch((p: EN): string => p!.message + p!.message) - arktest.assertTrue((await r) == 'AAAA') + arktest.assertEQ((await r), 'AAAA') - decl: |- type EN = Error|null @@ -635,8 +646,8 @@ cases: .catch((p: EN): string => { throw p! }) try { await r + arktest.assertTrue(false) } catch (e) { - arktest.assertTrue((e as Error).message == 'E') - return + arktest.assertEQ((e as Error).message, 'E') } - arktest.assertTrue(false) + \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method23.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth_48_old.ets old mode 100644 new mode 100755 similarity index 50% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method23.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth_48_old.ets index f28ee0bd26..2d682e6af5 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method23.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/ameth_48_old.ets @@ -14,26 +14,31 @@ */ /*--- -desc: Test cases for various usage scenarios of asynchronous method. - Using loops in asynchronous methods. +desc: Throw error in chained catch await is forbidden for non-async function ---*/ -class MethodWithLoop { - async methodWithLoop(): Promise { - let sum = 0.0; - for (let i = 1; i <= 5; i++) { - sum += i; +type EN = Error|null +let s = 'A' +class A { + async foo(p: string): Promise { + if (p == 'A') { + throw new Error('E') } - return sum; + return 'X' } } - -async function startTest() { - const example = new MethodWithLoop(); - const result = await example.methodWithLoop(); - arktest.assertEQ(result, 15); +//old test +function main() { + // Throw error in chained catch + // await is forbidden for non-async function + let r = new A().foo(s) + .then((p: string): string => p + p) + .catch((p: EN): string => { throw p! }) + try { + await r + } catch (e) { + arktest.assertEQ((e as Error).message, 'E') + return + } + arktest.assertTrue(false) } - -function main(): void { - startTest(); -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method0.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method0.ets deleted file mode 100644 index d2079dabd8..0000000000 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method0.ets +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/*--- -desc: Test cases for various usage scenarios of asynchronous method. - The asynchronous method returns a string. ----*/ - -class MethodReturnString { - async methodReturnString(): Promise { - return "Hello, World!"; - } -} - -async function startTest() { - const example = new MethodReturnString(); - const result = await example.methodReturnString(); - arktest.assertEQ(result, "Hello, World!"); -} - -function main(): void { - waitForCompletion(startTest); -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method10.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method10.ets index 90022474db..08d5008148 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method10.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method10.ets @@ -28,7 +28,7 @@ class MethodWithErrorHandling { await this.methodThrowError(); return "Success"; } catch (error) { - return `Caught error: ${error as string}`; + return `Caught error: ${(error as Error).message}`; } } } @@ -40,5 +40,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method12.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method12.ets deleted file mode 100644 index bb58d7954c..0000000000 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method12.ets +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/*--- -desc: Test cases for various usage scenarios of asynchronous method. - Asynchronous method returns undefined. ----*/ - -class MethodReturnUndefined { - async methodReturnUndefined(): Promise { - return undefined; - } -} - -async function startTest() { - const example = new MethodReturnUndefined(); - const result = await example.methodReturnUndefined(); - arktest.assertEQ(result === undefined, true) -} - -function main(): void { - startTest(); -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method15.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method15.ets index 3ffec03f06..ccd70e04ac 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method15.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method15.ets @@ -36,10 +36,10 @@ class MethodReturnObject { async function startTest() { const example = new MethodReturnObject(); const result = await example.methodReturnObject(); - arktest.assertEQ(result.name === "Alice", true); - arktest.assertEQ(result.age === 25, true); + arktest.assertEQ(result.name, "Alice"); + arktest.assertEQ(result.age, 25); } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method16.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method16.ets deleted file mode 100644 index b90e10f278..0000000000 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method16.ets +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/*--- -desc: Test cases for various usage scenarios of asynchronous method. - Asynchronous method returns array. ----*/ - -class MethodReturnArray { - async methodReturnArray(): Promise> { - return new Array(1, 2, 3); - } -} - -async function startTest() { - const example = new MethodReturnArray(); - const result = await example.methodReturnArray(); - const resTemp = new Array(1, 2, 3); - arktest.assertEQ(result === resTemp, true); -} - -function main(): void { - startTest(); -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method17.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method17.ets index 935e807c09..7c50398774 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method17.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method17.ets @@ -27,22 +27,26 @@ class MethodConcurrentExecution { return 42.0; } - async methodConcurrentExecution(): Promise>> { - const result = await Promise.all( new Array>( + async methodConcurrentExecution(): Promise>> { + const result = await Promise.all( new Array>( this.methodReturnString(), this.methodReturnNumber(), )); - return result as Array>; + return result; } } async function startTest() { const example = new MethodConcurrentExecution(); const result = await example.methodConcurrentExecution(); - const resTemp = new Array("Hello", 42); - arktest.assertEQ(result === resTemp, true); + + arktest.assertTrue(Array.isArray(result)); + arktest.assertEQ(result.length, 2); + arktest.assertEQ(result[0], "Hello"); + arktest.assertEQ(result[1], 42.0); + } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method18.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method18.ets index c54fd1daa5..79d5df5b8e 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method18.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method18.ets @@ -41,5 +41,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method19.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method19.ets index b82bf1d822..6e341e457d 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method19.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method19.ets @@ -29,10 +29,10 @@ async function startTest() { try { await example.methodReturnReject(); } catch (error) { - arktest.assertEQ(error as string, "Rejected!"); + arktest.assertEQ((error as Error).message, "Rejected!"); } } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method20.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method20.ets index 57a2a11bc8..197f7928ee 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method20.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method20.ets @@ -32,5 +32,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method21.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method21.ets index d3ea286091..7d163cfebd 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method21.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method21.ets @@ -32,9 +32,9 @@ class MethodAwaitReject { async function startTest() { const example = new MethodAwaitReject(); const result = await example.methodAwaitReject(); - arktest.assertEQ(result, "Rejected!"); + arktest.assertEQ(result, "Caught error: Rejected!"); } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method22.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method22.ets index 38edd61934..6dea9ce2e4 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method22.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method22.ets @@ -37,5 +37,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method24.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method24.ets index 2d9a2cd454..3150bfd072 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method24.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method24.ets @@ -34,5 +34,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method25.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method25.ets index ede876a145..2e8c894f4d 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method25.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method25.ets @@ -34,5 +34,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method26.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method26.ets index fc716944cc..f8d7dc1e2b 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method26.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method26.ets @@ -44,5 +44,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method27.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method27.ets index ccf9fcd599..a3f6777122 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method27.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method27.ets @@ -31,9 +31,12 @@ class MethodWithAllSettled { async function startTest() { const example = new MethodWithAllSettled(); const result = await example.methodWithAllSettled(); - arktest.assertEQ(result, '[{"status":"fulfilled","value":"Resolved!"},{"status":"rejected","reason":{}}]'); + + //redo it... + let expected = '[{"status":"fulfilled","value":"Resolved!"},{"status":"rejected","reason":{"name_":"Error","message_":"Rejected!","stackLines":[{"className":"escompat.Error","methodName":"","sourceFileName":"Error.ets","lineNumber":56,"colNumber":0},{"className":"escompat.Error","methodName":"","sourceFileName":"Error.ets","lineNumber":57,"colNumber":0},{"className":"escompat.Error","methodName":"","sourceFileName":"Error.ets","lineNumber":56,"colNumber":0},{"className":"async_method27.MethodWithAllSettled","methodName":"%%async-methodWithAllSettled","sourceFileName":"async_method27.ets","lineNumber":22,"colNumber":0}],"code_":0}}]'; + arktest.assertEQ(result, expected); } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method28.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method28.ets index 08cba5ada9..1543dabfc4 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method28.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method28.ets @@ -43,5 +43,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method29.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method29.ets index 1929ddd086..b409491dff 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method29.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method29.ets @@ -32,5 +32,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method3.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method3.ets deleted file mode 100644 index 4d044796fd..0000000000 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method3.ets +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2025 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. - */ - -/*--- -desc: Test cases for various usage scenarios of asynchronous method. - The asynchronous method returns a void. ----*/ - -class MethodReturnVoid { - value: number = 0; - async methodReturnVoid(): Promise { - this.value = 1; - arktest.assertEQ(this.value, 1); - } -} - -async function startTest() { - const example = new MethodReturnVoid(); - await example.methodReturnVoid(); -} - -function main(): void { - waitForCompletion(startTest); -} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method30.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method30.ets index d11e45994c..5b1954a446 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method30.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method30.ets @@ -33,5 +33,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method4.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method4.ets index 7e1802f09e..e3b3e16a15 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method4.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method4.ets @@ -32,5 +32,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method5.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method5.ets index b8da6aa276..c7d725ebcd 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method5.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method5.ets @@ -32,5 +32,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method6.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method6.ets index d9d83f75ea..a60ed1b699 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method6.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method6.ets @@ -31,5 +31,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method7.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method7.ets index 4b7e6fc3e8..406504a2f6 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method7.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method7.ets @@ -29,10 +29,10 @@ async function startTest() { try { await example.methodThrowError(); } catch (error) { - arktest.assertEQ(error as string, "Something went wrong!"); + arktest.assertEQ((error as Error).message, "Something went wrong!"); } } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method8.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method8.ets index c368d91cdb..8a29056ebb 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method8.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method8.ets @@ -35,5 +35,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method9.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method9.ets index 268d28a8cf..e320e917ad 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method9.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method9.ets @@ -41,5 +41,5 @@ async function startTest() { } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined0.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined0.ets new file mode 100644 index 0000000000..b6d8e578c8 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined0.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 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. + */ + +{% from 'ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja' import numeric_types_cases, boolean_types_cases, symbol_types_cases, no_value_types_cases %} +{% from 'ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja' import generate_complete_test %} + +{{ generate_complete_test(numeric_types_cases + boolean_types_cases + symbol_types_cases + no_value_types_cases, 'method') }} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined1.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined1.ets new file mode 100644 index 0000000000..064722c4f1 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_promise_predefined1.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2025 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. + */ + +{% from 'ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja' import numeric_types_cases, boolean_types_cases, symbol_types_cases %} +{% from 'ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined1.base.jinja' import generate_complete_test %} + +{{ generate_complete_test(numeric_types_cases + boolean_types_cases + symbol_types_cases, 'method') }} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method11.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_void.ets similarity index 33% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method11.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_void.ets index dcf299b5c8..8dafcedba4 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method11.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_returns_void.ets @@ -13,27 +13,52 @@ * limitations under the License. */ -/*--- -desc: Test cases for various usage scenarios of asynchronous method. - Asynchronous methods return a promise.. ----*/ - -class MethodReturnNestedPromise { - async methodReturnString(): Promise { - return "Hello, World!"; +{% set cases = [ + { + 'body': 'console.log("Hello")', + 'return_type': '', + 'description': 'The return type of an async method must be Promise.' + }, + { + 'body': 'console.log("Hello")', + 'return_type': ':Promise', + 'description': 'No-argument return statement can be added implicitly as the last statement of the method + body if there is no explicit return statement in a method with the return Promise.' + }, + { + 'body': 'return', + 'return_type': ':Promise', + 'description': 'Using return statement without an expression is allowed if the return type is Promise.' } + ] %} - async methodReturnNestedPromise(): Promise> { - return this.methodReturnString(); +{% macro generate_method(body, return_type) %} +class AsyncMethodClass{ + async noParams(){{return_type}}{ + {{body}} } } +{% endmacro %} + +{% for c in cases %} + + /*--- +desc: {{c.description}} +---*/ + +{{ generate_method(c.body, c.return_type) }} + +async function startTest(){ + + let obj = new AsyncMethodClass() + let result = obj.noParams() + arktest.assertTrue(result instanceof Promise) + let awaited_result = await result + arktest.assertTrue(awaited_result instanceof undefined) +} -async function startTest() { - const example = new MethodReturnNestedPromise(); - const result = await example.methodReturnNestedPromise(); - arktest.assertEQ(result, "Hello, World!") +function main(){ + waitForCompletion(startTest) } -function main(): void { - startTest(); -} \ No newline at end of file +{% endfor %} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method14.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_with_return.ets similarity index 69% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method14.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_with_return.ets index 1cbb4ece9d..0b9fb2aca2 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method14.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_with_return.ets @@ -14,22 +14,21 @@ */ /*--- -desc: Test cases for various usage scenarios of asynchronous method. - Asynchronous method returns boolean. +desc: Test cases for various usage scenarios of asynchronous method. With 'Promise', With 'return' ---*/ -class MethodReturnBoolean { - async methodReturnBoolean(): Promise { - return true; - } +class MethodConcurrentExecution { + async methodReturnVoid(): Promise{ + return; + } } async function startTest() { - const example = new MethodReturnBoolean(); - const result = await example.methodReturnBoolean(); - arktest.assertEQ(result === true, true) + const example = new MethodConcurrentExecution(); + const result = await example.methodReturnVoid(); + arktest.assertTrue(result instanceof undefined) } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method2.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_without_return.ets similarity index 69% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method2.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_without_return.ets index 19ee73ade2..ebcf1a0b6c 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method2.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_with_promise_without_return.ets @@ -14,22 +14,20 @@ */ /*--- -desc: Test cases for various usage scenarios of asynchronous method. - The asynchronous method returns a double. +desc: Test cases for various usage scenarios of asynchronous method. With 'Promise', Without 'return' ---*/ -class MethodReturnDouble { - async methodReturnDouble(): Promise { - return 10.0; - } +class MethodConcurrentExecution { + async methodReturnVoid(): Promise{ + } } async function startTest() { - const example = new MethodReturnDouble(); - const result = await example.methodReturnDouble(); - arktest.assertEQ(result, 10.0); + const example = new MethodConcurrentExecution(); + const result = await example.methodReturnVoid(); + arktest.assertTrue(result instanceof undefined) } function main(): void { - waitForCompletion(startTest); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method1.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_with_return.ets similarity index 70% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method1.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_with_return.ets index 9190c8cb29..e996e6378d 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method1.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_with_return.ets @@ -14,22 +14,21 @@ */ /*--- -desc: Test cases for various usage scenarios of asynchronous method. - The asynchronous method returns a int. +desc: Test cases for various usage scenarios of asynchronous method. Without 'Promise', With 'return' ---*/ -class MethodReturnInt { - async methodReturnInt(): Promise { - return 10; - } +class MethodConcurrentExecution { + async methodReturnVoid(){ + return; + } } async function startTest() { - const example = new MethodReturnInt(); - const result = await example.methodReturnInt(); - arktest.assertEQ(result, 10); + const example = new MethodConcurrentExecution(); + const result = await example.methodReturnVoid(); + arktest.assertTrue(result instanceof undefined) } function main(): void { - waitForCompletion(startTest); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method13.ets b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_without_return.ets similarity index 71% rename from static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method13.ets rename to static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_without_return.ets index 04a715d4ce..61eda1746c 100644 --- a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/async_method13.ets +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_without_return.ets @@ -14,22 +14,20 @@ */ /*--- -desc: Test cases for various usage scenarios of asynchronous method. - Asynchronous method returns null. +desc: Test cases for various usage scenarios of asynchronous method. Without 'Promise', Without 'return' ---*/ -class MethodReturnNull { - async methodReturnNull(): Promise { - return null; - } +class MethodConcurrentExecution { + async methodReturnVoid(){ + } } async function startTest() { - const example = new MethodReturnNull(); - const result = await example.methodReturnNull(); - arktest.assertEQ(result === null, true) + const example = new MethodConcurrentExecution(); + const result = await example.methodReturnVoid(); + arktest.assertTrue(result instanceof undefined) } function main(): void { - startTest(); + waitForCompletion(startTest); } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja new file mode 100644 index 0000000000..143bd3188a --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined0.base.jinja @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2025 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. + */ + +{% macro generate_complete_test(cases, declaration_type='function') %} +{% for c in cases %} +{% for type_name in [c.type, c.alias] | select %} + +/*--- +desc: The return type of an async function must be Promise<{{type_name}}>. +---*/ + +{% if declaration_type == 'function' %} +async function noParams(): Promise<{{type_name}}> { +{% elif declaration_type == 'lambda' %} +const noParams = async (): Promise<{{type_name}}> => { +{% elif declaration_type == 'method' %} +class AsyncMethodReturnClass { + async noParams(): Promise<{{type_name}}> { +{% endif %} + + {% if type_name in ['Byte', 'Short'] %} + const value: {{type_name}} = new {{type_name}}({{c.value}}) + {% else %} + const value: {{type_name}} = {{c.value}} + {% endif %} + return value + +} + +{% if declaration_type == 'method' %} +} {# Closing brace of class #} +{% endif %} + +async function startTest(){ + + + {% if declaration_type == 'method' %} + let obj = new AsyncMethodReturnClass() + let result = obj.noParams() + {% else %} + let result = noParams() + {% endif %} + + arktest.assertTrue(result instanceof Promise) + let awaited_result = await result + arktest.assertTrue(awaited_result instanceof {{type_name}}) + {% if type_name in ['Byte', 'Short'] %} + arktest.assertEQ({{type_name}}.valueOf(awaited_result), {{c.value}}) + {% else %} + arktest.assertEQ(awaited_result, {{c.value}}) + + {% endif %} +} + +function main(){ + waitForCompletion(startTest) +} + +{% endfor %} +{% endfor %} +{% endmacro %} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined1.base.jinja b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined1.base.jinja new file mode 100644 index 0000000000..a0dc61efb9 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/async_returns_predefined1.base.jinja @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2025 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. + */ + + +{% macro generate_type_name(array_type, content_type) -%} +{%- if array_type == 'Array' or array_type == 'FixedArray' -%} +{{array_type}}<{{content_type}}> +{%- else -%} +{{content_type}}[] +{%- endif -%} +{%- endmacro %} + +{% macro generate_complete_test(cases, declaration_type='function') %} +{% for c in cases %} +{% for arr_type in ['Array', 'FixedArray', '[]'] %} +{% set type_name = generate_type_name(arr_type, c.type) %} + +/*--- +desc: The return type of an async function must be Promise<{{type_name}}>. +---*/ + +{% if declaration_type == 'function' %} +async function noParams(): Promise<{{type_name}}> { +{% elif declaration_type == 'lambda' %} +const noParams = async (): Promise<{{type_name}}> => { +{% elif declaration_type == 'method' %} +class AsyncMethodReturnClass { + async noParams(): Promise<{{type_name}}> { +{% endif %} + const value: {{type_name}} = [{{c.value}}] + return value +} +{% if declaration_type == 'method' %} +} {# Closing brace of class #} +{% endif %} + +async function startTest(){ + + {% if declaration_type == 'method' %} + let obj = new AsyncMethodReturnClass() + let result = obj.noParams() + {% else %} + let result = noParams() + {% endif %} + arktest.assertTrue(result instanceof Promise) + let awaited_result = await result + arktest.assertTrue(Array.isArray(awaited_result)) + arktest.assertEQ(awaited_result[0], {{c.value}}) + {%- if array_type == 'FixedArray' -%} + arktest.assertTrue(awaited_result instanceof FixedArray) + {% endif %} +} + +function main(){ + waitForCompletion(startTest) +} + +{% endfor %} +{% endfor %} +{% endmacro %} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja new file mode 100644 index 0000000000..886b50b105 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/16.concurrency/03.asynchronous_api/predefined_types.jinja @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2025 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. + */ + +{% set numeric_types_cases = [ + {'type': 'int', 'alias': 'Int', 'value': '42'}, + {'type': 'number', 'alias': 'Number', 'value': '42.0'}, + {'type': 'byte', 'alias': 'Byte', 'value': '127'}, + {'type': 'short', 'alias': 'Short', 'value': '32767'}, + {'type': 'long', 'alias': 'Long', 'value': '9223372036854775807'}, + {'type': 'float', 'alias': 'Float', 'value': '3.14f'}, + {'type': 'double', 'alias': 'Double', 'value': '3.141592653589793'}, + {'type': 'bigint', 'alias': 'BigInt', 'value': '123456789012345678901234567890n'} +] %} + +{% set boolean_types_cases = [ + {'type': 'boolean', 'alias': 'Boolean', 'value': 'true'}, +] %} + +{% set symbol_types_cases = [ + {'type': 'string', 'alias': 'String', 'value': '"Hello, ArkTS!"'}, + {'type': 'char', 'alias': 'Char', 'value': "c'A'"}, +] %} + +{% set non_return_types_cases = [ + {'type': 'never', 'value': 'undefined'}, + {'type': 'void', 'value': 'undefined'} +] %} + +{% set no_value_types_cases = [ + {'type': 'undefined', 'value': 'undefined'}, + {'type': 'null', 'value': 'null'} +] %} + +{% set base_types_cases = [ + {'type': 'Any', 'value': '"Any value"'}, + {'type': 'Object', 'alias': 'object', 'value': 'new Object()'}, +]%} + +{% set resizable_array_types_cases = [ + {'type': 'int[]', 'value': '[1, 2, 3]'}, + {'type': 'number[]', 'value': '[1.0, 2.5, 3.7]'}, + {'type': 'string[]', 'value': '["Hello", "ArkTS", "World"]'}, + {'type': 'boolean[]', 'value': '[true, false, true]'}, + {'type': 'byte[]', 'value': '[127, -128, 0]'}, + {'type': 'short[]', 'value': '[32767, -32768, 0]'}, + {'type': 'long[]', 'value': '[9223372036854775807, 0]'}, + {'type': 'float[]', 'value': '[3.14f, -2.71f, 0.0f]'}, + {'type': 'double[]', 'value': '[3.141592653589793, 0.0]'}, + {'type': 'bigint[]', 'value': '[123456789012345678901234567890n]'}, + {'type': 'char[]', 'value': "[c'A', c'B', c'C']"}, + {'type': 'Any[]', 'value': '["mixed", 42, true]'}, + {'type': 'Object[]', 'value': '[new Object(), new Object()]'} +] %} + +{% set generic_array_types_cases = [ + {'type': 'Array', 'value': '[1, 2, 3]'}, + {'type': 'Array', 'value': '[1.0, 2.5, 3.7]'}, + {'type': 'Array', 'value': '["Hello", "ArkTS"]'}, + {'type': 'Array', 'value': '[true, false]'}, + {'type': 'Array', 'value': '["mixed", 42]'}, + {'type': 'Array', 'value': '[new Object(), new Object()]'} +] %} + +{% set fixed_array_types_cases = [ + {'type': 'FixedArray', 'value': '[1, 2, 3]'}, + {'type': 'FixedArray', 'value': '[1.0, 2.5, 3.7]'}, + {'type': 'FixedArray', 'value': '["Hello", "ArkTS"]'}, + {'type': 'FixedArray', 'value': '[true, false]'}, + {'type': 'FixedArray', 'value': '[127, -128]'}, + {'type': 'FixedArray', 'value': "[c'A', c'B']"} +] %} + +{% set multidimensional_array_types_cases = [ + {'type': 'int[][]', 'value': '[[1, 2], [3, 4]]'}, + {'type': 'string[][]', 'value': '[["Hello", "World"], ["ArkTS", "Test"]]'}, + {'type': 'Array>', 'value': '[[1, 2], [3, 4]]'}, + {'type': 'Array>', 'value': '[["Hello", "World"], ["ArkTS", "Test"]]'}, + {'type': 'FixedArray>', 'value': '[[1, 2], [3, 4]]'}, + {'type': 'FixedArray>', 'value': '[["A", "B"], ["C", "D"]]'} +] %} + +{% set empty_array_types_cases = [ + {'type': 'int[]', 'value': '[]'}, + {'type': 'Array', 'value': '[]'}, + {'type': 'FixedArray', 'value': '[]'} +] %} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index 0aa140820d..45809354ca 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -1479,6 +1479,7 @@ 09.classes/06.field_declarations/05.fields_with_late_initialization/fields_with_late_initialization_rte_153.ets 09.classes/06.field_declarations/05.fields_with_late_initialization/fields_with_late_initialization_rte_154.ets 09.classes/06.field_declarations/05.fields_with_late_initialization/fields_with_late_initialization_rte_155.ets +16.concurrency/03.asynchronous_api/03.async_methods/return_type_is_promise/no_input_params/predefined_types/async_method_without_promise_with_return.ets #29302 09.classes/06.field_declarations/05.fields_with_late_initialization/fields_with_late_initialization_decl_247.ets @@ -2866,6 +2867,7 @@ #2160 14.ambient_declarations/06.namespace_declarations/01.impl_ambient_namespace/negative/namespace_usage_n_5.ets + #29727 10.interfaces/06.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_12.ets 10.interfaces/06.interface_inheritance/multi_layer_interface/complex_inheritance/complex_inheritance_22.ets @@ -2877,3 +2879,6 @@ 13.compilation_units/02.import_directives/05.import_path/file/import_path_file_global_0.ets 13.compilation_units/02.import_directives/05.import_path/file/import_path_file_global_1.ets +#29982 +16.concurrency/03.asynchronous_api/03.async_methods/async_method17.ets + diff --git a/static_core/tests/tests-u-runner/runner/plugins/ets/ets_templates/template.py b/static_core/tests/tests-u-runner/runner/plugins/ets/ets_templates/template.py index 9576a0583e..0cde48a097 100644 --- a/static_core/tests/tests-u-runner/runner/plugins/ets/ets_templates/template.py +++ b/static_core/tests/tests-u-runner/runner/plugins/ets/ets_templates/template.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. +# Copyright (c) 2021-2025 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 @@ -21,7 +21,7 @@ from pathlib import Path from typing import Dict, Any, List, Tuple import yaml -from jinja2 import Environment, select_autoescape, TemplateSyntaxError +from jinja2 import Environment, select_autoescape, TemplateSyntaxError, FileSystemLoader from runner.plugins.ets.utils.constants import META_COPYRIGHT, META_START_STRING, \ META_END_STRING, META_START_COMMENT, META_END_COMMENT from runner.plugins.ets.utils.exceptions import \ @@ -29,6 +29,8 @@ from runner.plugins.ets.utils.exceptions import \ from runner.utils import read_file ROOT_PATH = Path(os.path.realpath(os.path.dirname(__file__))) +PROJECT_ROOT = ROOT_PATH.parent.parent.parent.parent.parent.parent.parent +ETS_TESTS_ROOT = PROJECT_ROOT / "static_core" / "plugins" / "ets" / "tests" BENCH_PATH = ROOT_PATH / "test_template.tpl" COPYRIGHT_PATH = ROOT_PATH / "copyright.txt" @@ -44,7 +46,10 @@ class Template: self.test_path = str(test_path) self.text = read_file(test_path) self.__params = params - self.__jinja_env = Environment(autoescape=select_autoescape()) + self.__jinja_env = Environment( + loader=FileSystemLoader([str(test_path.parent), str(ETS_TESTS_ROOT)]), + autoescape=select_autoescape() + ) if self.is_copyright: self.__copyright = read_file(COPYRIGHT_PATH) -- Gitee