From 28feddb25765d00d0d9f0e9b143ec67c77c51cc1 Mon Sep 17 00:00:00 2001 From: Konstantin Kuznetsov Date: Tue, 26 Sep 2023 14:40:54 +0300 Subject: [PATCH] Add ets test for class composite inside array Add test to make sure that the compiler correctly infers the type for class composite in the array context. See the following issue for details: https://gitee.com/openharmony-sig/arkcompiler_ets_frontend/issues/I81TR9 Signed-off-by: Konstantin Kuznetsov --- .../ets/tests/ets_test_suite/CMakeLists.txt | 1 + .../ets_test_suite/arrays/CMakeLists.txt | 29 +++++++++++++++++++ .../ets_test_suite/arrays/class_composite.ets | 7 +++++ 3 files changed, 37 insertions(+) create mode 100644 plugins/ets/tests/ets_test_suite/arrays/CMakeLists.txt create mode 100644 plugins/ets/tests/ets_test_suite/arrays/class_composite.ets diff --git a/plugins/ets/tests/ets_test_suite/CMakeLists.txt b/plugins/ets/tests/ets_test_suite/CMakeLists.txt index 253d1e32..10e60bc8 100644 --- a/plugins/ets/tests/ets_test_suite/CMakeLists.txt +++ b/plugins/ets/tests/ets_test_suite/CMakeLists.txt @@ -19,3 +19,4 @@ add_subdirectory(lambda) add_subdirectory(gc) add_subdirectory(intrinsics) add_subdirectory(atomics) +add_subdirectory(arrays) diff --git a/plugins/ets/tests/ets_test_suite/arrays/CMakeLists.txt b/plugins/ets/tests/ets_test_suite/arrays/CMakeLists.txt new file mode 100644 index 00000000..63609b4e --- /dev/null +++ b/plugins/ets/tests/ets_test_suite/arrays/CMakeLists.txt @@ -0,0 +1,29 @@ +# Copyright (c) 2021-2022 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(arrays_tests + class_composite +) + +set(arrays_tests_in_dir "${CMAKE_CURRENT_SOURCE_DIR}") +set(arrays_tests_out_dir "${CMAKE_CURRENT_BINARY_DIR}") + +foreach(test ${arrays_tests}) + set(test_out_dir "${arrays_tests_out_dir}/${test}") + set(test_src "${arrays_tests_in_dir}/${test}.ets") + set(target ets_test_suite_arrays_${test}) + + run_ets_code_verifier(${test_src} ${test_out_dir} ${target}-ets-verifier) + run_int_jit_aot_ets_code(${test_src} ${test_out_dir} ${target}) +endforeach() + diff --git a/plugins/ets/tests/ets_test_suite/arrays/class_composite.ets b/plugins/ets/tests/ets_test_suite/arrays/class_composite.ets new file mode 100644 index 00000000..bba2a354 --- /dev/null +++ b/plugins/ets/tests/ets_test_suite/arrays/class_composite.ets @@ -0,0 +1,7 @@ +class C0 { + x0: boolean +} + +function main() : void { + let x0: C0 = ([{x0: true}])[0] +} -- Gitee