From ada88a7ff4a3e2e99c1d7ae92b7d29bdc18db65b Mon Sep 17 00:00:00 2001 From: Vladimir Lind Date: Tue, 9 Sep 2025 11:44:33 +0300 Subject: [PATCH] CTS tests chapter 4.2 Reason: CTS tests development Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICX5J2 Signed-off-by: Vladimir Lind --- .../02.declarations/spec_decl1.ets | 8 +++-- .../02.declarations/spec_decl2.ets | 4 --- .../02.declarations/spec_decl2_rt.ets | 15 ++++------ .../02.declarations/spec_decl3.ets | 30 +++++++++++++++++++ .../02.declarations/spec_decl_n1.ets | 3 -- .../02.declarations/spec_decl_n10.ets | 1 - .../02.declarations/spec_decl_n11.ets | 2 -- .../02.declarations/spec_decl_n12.ets | 29 ++++++++++++++++++ .../02.declarations/spec_decl_n2.ets | 26 ++++++++++++++++ .../02.declarations/spec_decl_n4.ets | 4 --- .../02.declarations/spec_decl_n5.ets | 4 --- .../02.declarations/spec_decl_n6.ets | 1 - .../02.declarations/spec_decl_n7.ets | 1 - .../02.declarations/spec_decl_n8.ets | 4 +-- .../02.declarations/spec_decl_n9.ets | 1 - .../unary_minus.params.yaml | 2 +- .../unary_plus.params.yaml | 2 +- .../ets-cts/declgen-ets2ts-cts-ignored.txt | 18 +++++++++++ .../test-lists/ets-cts/ets-cts-ignored.txt | 4 +-- 19 files changed, 117 insertions(+), 42 deletions(-) create mode 100644 static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl3.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n12.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n2.ets diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl1.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl1.ets index bda724d1e4..5d4853dcd0 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl1.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl1.ets @@ -24,10 +24,12 @@ function Pi(): double { return PI; } type IP = byte[] +enum Ip {one = 1, two, three} -function main(): int { +function main() { let x: IP = new byte[4] Pi() - if (Pi() == PI && pi == 3) return 0; - return 1; + arktest.assertEQ(Pi(), PI) + arktest.assertEQ(pi, 3) + arktest.assertEQ(Ip.three, 3) } diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2.ets index 7377642af6..dacebac0c4 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2.ets @@ -25,7 +25,3 @@ class A {} type Person = A let Person: Person - -function main(): int { - return 0; -} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2_rt.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2_rt.ets index 12390f1c7d..efc2f14d2e 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2_rt.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl2_rt.ets @@ -35,14 +35,9 @@ function foo(x: string): int { return 4; } -function main(): int { - if (foo() != 1) return 1; - - if (foo(1) != 2) return 1; - - if (foo(new int[0]) != 3) return 1; - - if (foo("") != 4) return 1; - - return 0; +function main() { + arktest.assertEQ(foo(), 1) + arktest.assertEQ(foo(1), 2) + arktest.assertEQ(foo(new int[0]), 3) + arktest.assertEQ(foo(""), 4) } diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl3.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl3.ets new file mode 100644 index 0000000000..8d81b62528 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl3.ets @@ -0,0 +1,30 @@ +/*--- +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. +---*/ + +/*--- +desc: Declarations must be distinguishable in a declaration space. +tags: [negative, compile-only] +---*/ + +class A { + name: string = 'Alex' + age: string = '20' +} + +// The type and enum have the same name: + +type Person = A + +enum Person {name = 'Alex', age = '20'} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n1.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n1.ets index 62200994cd..c8cdc29e62 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n1.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n1.ets @@ -24,6 +24,3 @@ const PI = 3.14 function PI(): double { return 3.14 } -function main(): int { - return 0; -} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n10.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n10.ets index 2bb15b5f73..863635daa9 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n10.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n10.ets @@ -22,4 +22,3 @@ tags: [compile-only, negative] interface Object {} -function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n11.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n11.ets index 37f9366885..a6b7fcb47c 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n11.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n11.ets @@ -21,5 +21,3 @@ tags: [compile-only, negative] // CTE: Name of the declaration clashes with the predefined type or standard library entity name. let Array = 6666 - -function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n12.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n12.ets new file mode 100644 index 0000000000..c83c59da3e --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n12.ets @@ -0,0 +1,29 @@ +/* + * 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: Declarations must be distinguishable in a declaration space. +tags: [compile-only, negative] +---*/ + +// CTE: Class and enum have the same name. + +class Person { + name: string = 'Alex' + age: string = '20' +} + +enum Person (name = 'Alex', age = '20') + diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n2.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n2.ets new file mode 100644 index 0000000000..c6317f513d --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n2.ets @@ -0,0 +1,26 @@ +/*--- +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 + +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: Declarations must be distinguishable in a declaration space. +tags: [compile-only, negative] +---*/ + +// The constant and enum have the same name: + +const PI = 3.14 + +enum PI { One = 1, Two, Three } + diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n4.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n4.ets index 62157ddf52..4b5ae1619f 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n4.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n4.ets @@ -23,7 +23,3 @@ tags: [compile-only, negative] function foo(x: int) {} function foo(y: int) {} - -function main(): int { - return 0; -} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n5.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n5.ets index def05a34d7..4f8e1fea79 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n5.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n5.ets @@ -25,7 +25,3 @@ function foo(x: int) {} type MyInt = int function foo(x: MyInt) {} - -function main(): int { - return 0; -} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n6.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n6.ets index baa962d7c7..a1076343ea 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n6.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n6.ets @@ -24,4 +24,3 @@ class Person {} let Person: Person -function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n7.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n7.ets index 6a38635955..57e296234b 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n7.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n7.ets @@ -22,4 +22,3 @@ tags: [compile-only, negative] let number: number = 1.0 -function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n8.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n8.ets index 8e173b11a2..274c5717cc 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n8.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n8.ets @@ -20,6 +20,4 @@ tags: [compile-only, negative] // CTE: Name of the declaration clashes with the predefined type or standard library entity name. -let String = true - -function main() {} +let String = true \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n9.ets b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n9.ets index cefbe40695..5d6b65ae66 100644 --- a/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n9.ets +++ b/static_core/plugins/ets/tests/ets-templates/04.names_declarations_and_scopes/02.declarations/spec_decl_n9.ets @@ -22,4 +22,3 @@ tags: [compile-only, negative] function Record() {} -function main() {} diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml index 5320611d93..ee375fbf75 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_minus.params.yaml @@ -27,5 +27,5 @@ cases: - { type: Long, val: new Long(1), r: [6, 6, 6, -1, 1, -1] } - { type: Float, val: new Float(1.0f), r: [7.0f, 7.0f, 7.0f, -1.0f, 1.0f, -1.0f] } - { type: Double, val: new Double(1.00), r: [8, 8, 8, -1.0, 1.0, -1.0] } - - { type: IntEnum, val: IntEnum.Two, r: [5, 5, 5, 0, -1, 0] } + - { type: IntEnum, val: IntEnum.Two, r: [5, 5, 5, 1, -1, 1] } \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml index 5b2394c74b..eceb362eeb 100644 --- a/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml +++ b/static_core/plugins/ets/tests/ets-templates/06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_plus.params.yaml @@ -27,4 +27,4 @@ cases: - { type: Long, val: new Long(1), r: [6, 6, 6, 1, 1, 1] } - { type: Float, val: new Float(1.0f), r: [7.0f, 7.0f, 7.0f, 1.0f, 1.0f, 1.0f] } - { type: Double, val: new Double(1.00), r: [8, 8, 8, 1.0, 1.0, 1.0] } - - { type: IntEnum, val: IntEnum.Two, r: [5, 5, 5, 0, -1, 0] } + - { type: IntEnum, val: IntEnum.Two, r: [5, 5, 5, -1, -1, -1] } diff --git a/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt index 5351568085..c1c5101fa2 100644 --- a/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt @@ -2038,3 +2038,21 @@ 09.classes/03.class_implementation_clause/02.implementing_required_interface_properties/override_field_with_static.ets 09.classes/10.inheritance/inheritance_static_methods_from_superinterface.ets 10.interfaces/03.interface_members/static_methods_inheritance.ets +04.names_declarations_and_scopes/02.declarations/spec_decl2.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n3.ets +04.names_declarations_and_scopes/02.declarations/spec_decl2_co.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n9.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n1.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n4.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n12.ets +04.names_declarations_and_scopes/02.declarations/spec_decl3.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n10.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n6.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n2.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n11.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n8.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n5.ets +04.names_declarations_and_scopes/02.declarations/spec_decl2_rt.ets +04.names_declarations_and_scopes/02.declarations/spec_decl1.ets +04.names_declarations_and_scopes/02.declarations/spec_decl_n7.ets + 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 84c2587464..ffddba123b 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 @@ -911,9 +911,7 @@ #27058 06.contexts_and_conversions/01.type_of_expression/standalone_expression_n_1.ets -#27123 -06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_minus_14.ets -06.contexts_and_conversions/04.numeric_operator_contexts/unary_numeric_promotion/unary_plus_14.ets +#29887 06.contexts_and_conversions/04.numeric_operator_contexts/binary_numeric_promotion/result_type_cond_72.ets 06.contexts_and_conversions/04.numeric_operator_contexts/binary_numeric_promotion/result_type_cond_73.ets 06.contexts_and_conversions/04.numeric_operator_contexts/binary_numeric_promotion/result_type_cond_74.ets -- Gitee