From 8287a4f41c9b9c74d56f488509d3841b1f3cc402 Mon Sep 17 00:00:00 2001 From: daizihan Date: Wed, 3 Sep 2025 15:51:09 +0800 Subject: [PATCH] Add test for lambda unsafe call Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICW6J1?from=project-issue Signed-off-by: daizihan --- .../test/runtime/ets/lambda_union_infer.ets | 1 - .../ets/lambda_unsafecall_optional.ets | 34 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/runtime/ets/lambda_unsafecall_optional.ets diff --git a/ets2panda/test/runtime/ets/lambda_union_infer.ets b/ets2panda/test/runtime/ets/lambda_union_infer.ets index d9ffa84722..d2dfce3387 100644 --- a/ets2panda/test/runtime/ets/lambda_union_infer.ets +++ b/ets2panda/test/runtime/ets/lambda_union_infer.ets @@ -1,4 +1,3 @@ - /* * Copyright (c) 2025 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/ets2panda/test/runtime/ets/lambda_unsafecall_optional.ets b/ets2panda/test/runtime/ets/lambda_unsafecall_optional.ets new file mode 100644 index 0000000000..4027408308 --- /dev/null +++ b/ets2panda/test/runtime/ets/lambda_unsafecall_optional.ets @@ -0,0 +1,34 @@ + +/* + * 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. + */ + + +function func(param1: int, param2 ?: int) { + arktest.assertEQ(param1, 1) + if (param2 !== undefined) { + arktest.assertEQ(param2, 2) + } else { + arktest.assertEQ(param2, undefined) + } +} + +export function setTimeoutC(func: Function, delayMs: int, ...args: FixedArray) { + func.unsafeCall(...args) +} + +function main() { + setTimeoutC(func, 1, 1) + setTimeoutC(func, 1, 1, 2) +} -- Gitee