From 4cf7f4d82df6367b2aed86ccaa3787e3d95a0022 Mon Sep 17 00:00:00 2001 From: Hetman Sofya Date: Mon, 8 Sep 2025 15:46:12 +0300 Subject: [PATCH] Update tests for spec Bugfix #468 Issue: https://gitee.com/openharmony/arkcompiler_runtime_core/issues/ICWYY3 Testing: All required pre-merge tests passed. Results are available in GGW. Signed-off-by: Hetman Sofya --- .../negative_binary_operator_cts.ets | 34 ++++++++++++++++++ .../negative_binary_operator_cts.params.yaml | 20 +++++++++++ ...or.ets => negative_unary_operator_cts.ets} | 11 ++++-- .../negative_unary_operator_cts.params.yaml | 18 ++++++++++ .../numeric_expressions_no_widening.ets | 35 +++++++++++++++++++ ...umeric_expressions_no_widening.params.yaml | 24 +++++++++++++ .../numeric_expressions_widening.ets | 10 ++++-- .../test-lists/ets-cts/ets-cts-ignored.txt | 3 -- 8 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.params.yaml rename static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/{negative_unary_operator.ets => negative_unary_operator_cts.ets} (65%) create mode 100644 static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.params.yaml create mode 100644 static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.ets create mode 100644 static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.params.yaml diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.ets new file mode 100644 index 0000000000..5421669ad2 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.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. + */ + +{%- for c in cases %} +/*--- +desc: For other numeric operators, the operands of unary and binary numeric expressions are widened to a larger numeric + type. The minimum type is int. None of those operators evaluates values of types byte and short without + widening. +tags: [compile-only, negative] +---*/ + +function foo(x: short) { +} + +function main() { + let b: byte = 1 + let s: short = 2 + let x = b {{c}} s + + foo(x); // Should be CTE: TypeError: No matching call signature for foo(Int) +} +{%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.params.yaml new file mode 100644 index 0000000000..ee9e4f8b99 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_binary_operator_cts.params.yaml @@ -0,0 +1,20 @@ +# 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. + +--- +cases: + - '+' + - '-' + - '*' + - '/' + - '%' \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.ets similarity index 65% rename from static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator.ets rename to static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.ets index 1c04c8fd0e..a548df7ea6 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.ets @@ -13,9 +13,11 @@ * limitations under the License. */ - +{%- for c in cases %} /*--- -desc: Specifically, no arithmetic operator evaluates values of types byte and short without widening. +desc: For other numeric operators, the operands of unary and binary numeric expressions are widened to a larger numeric + type. The minimum type is int. None of those operators evaluates values of types byte and short without + widening. tags: [compile-only, negative] ---*/ @@ -24,5 +26,8 @@ function foo(x: short) { function main() { let b: byte = 1 - foo(b++) // #27628: Should be CTE: TypeError: No matching call signature for foo(Int) + let x = {{c}}b + + foo(x); // Should be CTE: TypeError: No matching call signature for foo(Int) } +{%- endfor %} diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.params.yaml new file mode 100644 index 0000000000..7dea5403ca --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator_cts.params.yaml @@ -0,0 +1,18 @@ +# 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. + +--- +cases: + - '~' + - '-' + - '+' \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.ets new file mode 100644 index 0000000000..ebf2f1385f --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.ets @@ -0,0 +1,35 @@ +/* + * 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: >- + The postfix and prefix increment and decrement operators evaluate byte and short operands without + widening. Same is true also for an assignment operator (considering assignment as a binary operator). +---*/ + +function main() { +{%- for t in type %} + let y_{{t}}: {{t}} = 1 + +{%- for op in unaryop %} + let x_{{t}}_prefix_{{loop.index}} = {{op}}y_{{t}} + arktest.assertTrue(x_{{t}}_prefix_{{loop.index}} instanceof {{t}}) + let x_{{t}}_postfix_{{loop.index}} = y_{{t}}{{op}} + arktest.assertTrue(x_{{t}}_postfix_{{loop.index}} instanceof {{t}}) +{%- endfor %} + let x_{{t}}_assignment = y_{{t}} + arktest.assertTrue(x_{{t}}_assignment instanceof {{t}}) +{%- endfor %} +} \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.params.yaml b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.params.yaml new file mode 100644 index 0000000000..9aaf57ffe7 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_no_widening.params.yaml @@ -0,0 +1,24 @@ +# 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. + +type: + - byte + - short + - int + - long +unaryop: + - '++' + - '--' +position: + - 'prefix' + - 'postfix' \ No newline at end of file diff --git a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_widening.ets b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_widening.ets index 74a1899f29..439bc1592b 100644 --- a/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_widening.ets +++ b/static_core/plugins/ets/tests/ets-templates/15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/numeric_expressions_widening.ets @@ -21,9 +21,9 @@ desc: >- function main() { let b: byte = 1 - let s: short = 2 + let s: Short = 2 let i: int = 3 - let l: long = 4 + let l: Long = 4 {%- for c in binary %} let x1_{{loop.index}} = b {{c}} b @@ -43,5 +43,9 @@ function main() { arktest.assertTrue(y1_{{loop.index}} instanceof int) let y2_{{loop.index}} = {{c}}s arktest.assertTrue(y2_{{loop.index}} instanceof int) + let y3_{{loop.index}} = {{c}}i + arktest.assertTrue(y3_{{loop.index}} instanceof int) + let y4_{{loop.index}} = {{c}}l + arktest.assertTrue(y4_{{loop.index}} instanceof long) {%- endfor -%} -} +} \ 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 beca84746e..f6077fe3be 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 @@ -2743,9 +2743,6 @@ # 27390 15.semantic_rules/01.semantic_essentials/01.type_of_standalone_expression/union_types.ets -# 27628 -15.semantic_rules/01.semantic_essentials/04.specifics_of_numeric_operator_contexts/negative_unary_operator.ets - # 28436 15.semantic_rules/08.overriding/01.overriding_in_classes/access_modifier_over_private_5.ets 15.semantic_rules/08.overriding/01.overriding_in_classes/access_modifier_over_private_6.ets -- Gitee