From 8445f57d2a732125bb74962a6fe0a09c743c6afc Mon Sep 17 00:00:00 2001 From: fotograf Date: Thu, 19 Oct 2023 14:27:23 +0000 Subject: [PATCH 1/2] Added tests for 3.7.5 Character Types and Operations Change-Id: I60fbc3f73104579e410da37758bb7a5620316842 Signed-off-by: fotograf --- .../addition/add_arr_ref.ets | 31 ++++ .../addition/add_arr_ref.params.yaml | 48 +++++++ .../addition/add_arr_val.ets | 31 ++++ .../addition/add_arr_val.params.yaml | 48 +++++++ .../addition/add_func_ref.ets | 32 +++++ .../addition/add_func_ref.params.yaml | 48 +++++++ .../addition/add_func_val.ets | 32 +++++ .../addition/add_func_val.params.yaml | 48 +++++++ .../ch_n.ets | 25 ++++ .../ch_n.params.yaml | 27 ++++ .../comparison/cmp_ref.ets | 30 ++++ .../comparison/cmp_ref.params.yaml | 53 +++++++ .../comparison/cmp_val.ets | 30 ++++ .../comparison/cmp_val.params.yaml | 53 +++++++ .../concat/conc2.ets | 25 ++++ .../concat/conc2.params.yaml | 39 +++++ .../concat/conc_ref.ets | 38 +++++ .../concat/conc_ref.params.yaml | 38 +++++ .../concat/conc_val.ets | 38 +++++ .../concat/conc_val.params.yaml | 38 +++++ .../conditional/cond_exp_val.ets | 30 ++++ .../conditional/cond_exp_val.params.yaml | 34 +++++ .../conditional/cond_fld_val.ets | 32 +++++ .../conditional/cond_fld_val.params.yaml | 28 ++++ .../conditional/cond_func_ref.ets | 32 +++++ .../conditional/cond_func_ref.params.yaml | 38 +++++ .../conditional/cond_func_val.ets | 32 +++++ .../conditional/cond_func_val.params.yaml | 38 +++++ .../decrement/dec_arr_ref.ets | 34 +++++ .../decrement/dec_arr_ref.params.yaml | 33 +++++ .../decrement/dec_arr_val.ets | 34 +++++ .../decrement/dec_arr_val.params.yaml | 33 +++++ .../decrement/dec_func_ref.ets | 36 +++++ .../decrement/dec_func_ref.params.yaml | 69 +++++++++ .../decrement/dec_func_val.ets | 36 +++++ .../decrement/dec_func_val.params.yaml | 69 +++++++++ .../increment/inc_arr_ref.ets | 34 +++++ .../increment/inc_arr_ref.params.yaml | 37 +++++ .../increment/inc_arr_val.ets | 34 +++++ .../increment/inc_arr_val.params.yaml | 37 +++++ .../increment/inc_func_ref.ets | 36 +++++ .../increment/inc_func_ref.params.yaml | 69 +++++++++ .../increment/inc_func_val.ets | 36 +++++ .../increment/inc_func_val.params.yaml | 69 +++++++++ .../subtraction/sub_arr_ref.ets | 31 ++++ .../subtraction/sub_arr_ref.params.yaml | 48 +++++++ .../subtraction/sub_arr_val.ets | 31 ++++ .../subtraction/sub_arr_val.params.yaml | 48 +++++++ .../subtraction/sub_func_ref.ets | 32 +++++ .../subtraction/sub_func_ref.params.yaml | 48 +++++++ .../subtraction/sub_func_val.ets | 32 +++++ .../subtraction/sub_func_val.params.yaml | 48 +++++++ .../unary/unary_ref.ets | 35 +++++ .../unary/unary_ref.params.yaml | 41 ++++++ .../unary/unary_val.ets | 35 +++++ .../unary/unary_val.params.yaml | 41 ++++++ .../runner/plugins/ets/ets-cts-ignored.txt | 136 +++++++++++++++--- 57 files changed, 2299 insertions(+), 19 deletions(-) create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.params.yaml create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.params.yaml diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.ets new file mode 100644 index 000000000..79dcc3577 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.ets @@ -0,0 +1,31 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: Char[] = new Char[1] + +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + a[0] = {{v.exp}} // unboxing/boxing is expected here + assert a[0] == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.params.yaml new file mode 100644 index 000000000..d0417a740 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: 'v1 + v2' + r: c'A' + + - v1: c'\u0020' + v2: c'\u0001' + exp: "v1 + v2 + c' '" + r: c'A' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: "v1 + v2" + r: c'\uFFFE' + + - v1: c'\uFFFF' + v2: c'\u0001' + exp: "v1 + v2" + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "v1 + c'\\u000F'" + r: c'\u000E' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "v1 + c'\\u1010' + v2 + c'\\u0101'" + r: c'\u2222' + + - v1: c'∫' + v2: c'\x01' + exp: "v1 + v2" + r: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.ets new file mode 100644 index 000000000..889f670f9 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.ets @@ -0,0 +1,31 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: char[] = new char[1] + +function main() { + const v1 = {{v.v1}} + const v2 = {{v.v2}} + + a[0] = {{v.exp}} + assert a[0] == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.params.yaml new file mode 100644 index 000000000..d0417a740 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: 'v1 + v2' + r: c'A' + + - v1: c'\u0020' + v2: c'\u0001' + exp: "v1 + v2 + c' '" + r: c'A' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: "v1 + v2" + r: c'\uFFFE' + + - v1: c'\uFFFF' + v2: c'\u0001' + exp: "v1 + v2" + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "v1 + c'\\u000F'" + r: c'\u000E' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "v1 + c'\\u1010' + v2 + c'\\u0101'" + r: c'\u2222' + + - v1: c'∫' + v2: c'\x01' + exp: "v1 + v2" + r: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.ets new file mode 100644 index 000000000..96b9fe2a3 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function add(p: Char, q: Char): Char { + return p + q // unboxing/boxing is expected here +} + +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.params.yaml new file mode 100644 index 000000000..86a19326c --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: 'add(v1, v2)' + r: c'A' + + - v1: c'\u0020' + v2: c'\u0001' + exp: "add(v1, v2) + c' '" + r: c'A' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: "add(v1, v2)" + r: c'\uFFFE' + + - v1: c'\uFFFF' + v2: c'\u0001' + exp: "add(v1, v2)" + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "add(v1, c'\\u000F')" + r: c'\u000E' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "add(v1 + c'\\u1010', v2 + c'\\u0101')" + r: c'\u2222' + + - v1: c'∫' + v2: c'\x01' + exp: "add(v1, v2)" + r: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.ets new file mode 100644 index 000000000..3e2ef0d27 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function add(p: char, q: char): char { + return p + q +} + +function main() { + const v1 = {{v.v1}} + const v2 = {{v.v2}} + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.params.yaml new file mode 100644 index 000000000..86a19326c --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/addition/add_func_val.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: 'add(v1, v2)' + r: c'A' + + - v1: c'\u0020' + v2: c'\u0001' + exp: "add(v1, v2) + c' '" + r: c'A' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: "add(v1, v2)" + r: c'\uFFFE' + + - v1: c'\uFFFF' + v2: c'\u0001' + exp: "add(v1, v2)" + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "add(v1, c'\\u000F')" + r: c'\u000E' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "add(v1 + c'\\u1010', v2 + c'\\u0101')" + r: c'\u2222' + + - v1: c'∫' + v2: c'\x01' + exp: "add(v1, v2)" + r: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.ets new file mode 100644 index 000000000..4ca188229 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.ets @@ -0,0 +1,25 @@ +/*--- +Copyright (c) 2021-2023 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: check addition of two bytes +tags: [compile-only, negative] +---*/ + +function main() { + const v = {{c.exp}} +} +{% endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml new file mode 100644 index 000000000..24bd9072f --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml @@ -0,0 +1,27 @@ +# Copyright (c) 2021-2023 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: + - exp: c'0' * c'2' + - exp: c'1' / c'1' + - exp: c'2' % c'2' + - exp: c'2' >> c'2' + - exp: c'2' >>> c'2' + - exp: c'2' << c'2' + - exp: c'2' & c'2' + - exp: c'2' && c'2' + - exp: c'2' | c'2' + - exp: c'2' || c'2' + - exp: c'2' ^ c'2' + - exp: "!c'2' && !c'2'" diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.ets new file mode 100644 index 000000000..c744a32bd --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.ets @@ -0,0 +1,30 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Comparison operators that produce a value of type boolean. +---*/ + +function main() { + const v1: Char = new Char({{v.v1}}) + const v2: Char = new Char({{v.v2}}) + + {%- for c in v.cases %} + assert (v1 {{c.op}} v2) == {{c.r}} + {%- endfor %} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.params.yaml new file mode 100644 index 000000000..432850f23 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_ref.params.yaml @@ -0,0 +1,53 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0000' + v2: c'\u0000' + cases: + - { op: '==', r: 'true' } + - { op: '!=', r: 'false' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'true' } + + - v1: c'\uFFFF' + v2: c'\uFFFF' + cases: + - { op: '==', r: 'true' } + - { op: '!=', r: 'false' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'true' } + + - v1: c'\u000F' + v2: c'\uF000' + cases: + - { op: '==', r: 'false' } + - { op: '!=', r: 'true' } + - { op: '<', r: 'true' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'false' } + + - v1: c'\u0100' + v2: c'\u00FF' + cases: + - { op: '==', r: 'false' } + - { op: '!=', r: 'true' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'false' } + - { op: '>', r: 'true' } + - { op: '>=', r: 'true' } diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.ets new file mode 100644 index 000000000..08b6bcae9 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.ets @@ -0,0 +1,30 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Comparison operators that produce a value of type boolean. +---*/ + +function main() { + const v1: char = {{v.v1}} + const v2: char = {{v.v2}} + + {%- for c in v.cases %} + assert (v1 {{c.op}} v2) == {{c.r}} + {%- endfor %} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.params.yaml new file mode 100644 index 000000000..432850f23 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/comparison/cmp_val.params.yaml @@ -0,0 +1,53 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0000' + v2: c'\u0000' + cases: + - { op: '==', r: 'true' } + - { op: '!=', r: 'false' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'true' } + + - v1: c'\uFFFF' + v2: c'\uFFFF' + cases: + - { op: '==', r: 'true' } + - { op: '!=', r: 'false' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'true' } + + - v1: c'\u000F' + v2: c'\uF000' + cases: + - { op: '==', r: 'false' } + - { op: '!=', r: 'true' } + - { op: '<', r: 'true' } + - { op: '<=', r: 'true' } + - { op: '>', r: 'false' } + - { op: '>=', r: 'false' } + + - v1: c'\u0100' + v2: c'\u00FF' + cases: + - { op: '==', r: 'false' } + - { op: '!=', r: 'true' } + - { op: '<', r: 'false' } + - { op: '<=', r: 'false' } + - { op: '>', r: 'true' } + - { op: '>=', r: 'true' } diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.ets new file mode 100644 index 000000000..c2bfe7821 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.ets @@ -0,0 +1,25 @@ +/*--- +Copyright (c) 2021-2023 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 string concatenation operator '+' (see String Concatenation), which (if a string operand and character + operand are available) converts the character operand to a string and then creates a concatenation of + the two strings as a new string. +---*/ +function main() { +{%- for v in vals %} + assert {{v.expr}} == {{v.res}} +{%- endfor %} +} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.params.yaml new file mode 100644 index 000000000..aa7474f3a --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc2.params.yaml @@ -0,0 +1,39 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - expr: "'a' + c'b' + 'c' + c'd'" + res: '"abcd"' + - expr: "'a' + c'b' + c'c' + c'd'" + res: '"abcd"' + - expr: "c'a' + 'b' + 'c' + c'd'" + res: '"abcd"' + - expr: "c'a' + c'b' + c'c' + c'd'" + res: c'Ɗ' + - expr: "c'a' + c'b' + c'c' + 'd'" + res: '"Ħd"' + - expr: "c'a' + c'b' + 'c' + 'd'" + res: '"Ãcd"' + + - expr: "'a' + new Char(c'b') + 'c' + new Char(c'd')" + res: '"abcd"' + - expr: "'a' + new Char(c'b') + new Char(c'c') + new Char(c'd')" + res: '"abcd"' + - expr: "new Char(c'a') + 'b' + 'c' + new Char(c'd')" + res: '"abcd"' + - expr: "new Char(c'a') + new Char(c'b') + new Char(c'c') + new Char(c'd')" + res: c'Ɗ' + - expr: "new Char(c'a') + new Char(c'b') + new Char(c'c') + 'd'" + res: '"Ħd"' + - expr: "new Char(c'a') + new Char(c'b') + 'c' + 'd'" + res: '"Ãcd"' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.ets new file mode 100644 index 000000000..173bea549 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.ets @@ -0,0 +1,38 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + The string concatenation operator '+' (see String Concatenation), which (if a string operand and character + operand are available) converts the character operand to a string and then creates a concatenation of + the two strings as a new string. +---*/ +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + assert "" + v1 + v2 == {{v.r1}} + assert v1 + "" + v2 == {{v.r1}} + assert v1 + v2 + "" == {{v.r2}} + + assert "" + {{v.v1}} + v2 == {{v.r1}} + assert {{v.v1}} + "" + v2 == {{v.r1}} + assert {{v.v1}} + v2 + "" == {{v.r2}} + + assert "" + {{v.v1}} + {{v.v2}} == {{v.r1}} + assert {{v.v1}} + "" + {{v.v2}} == {{v.r1}} + assert {{v.v1}} + {{v.v2}} + "" == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.params.yaml new file mode 100644 index 000000000..157a114e3 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_ref.params.yaml @@ -0,0 +1,38 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + r1: '" !"' + r2: '"A"' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + r1: '"\uFFFF\uFFFF"' + r2: '"\uFFFE"' + + - v1: c'\uFFFF' + v2: c'\u0000' + r1: '"\uFFFF\u0000"' + r2: '"\uFFFF"' + + - v1: c'\u2200' + v2: c'\u002C' + r1: '"∀,"' + r2: '"∬"' + + - v1: c'1' + v2: c'2' + r1: '"12"' + r2: '"c"' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.ets new file mode 100644 index 000000000..536ea8f31 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.ets @@ -0,0 +1,38 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + The string concatenation operator '+' (see String Concatenation), which (if a string operand and character + operand are available) converts the character operand to a string and then creates a concatenation of + the two strings as a new string. +---*/ +function main() { + let v1 = {{v.v1}} + let v2 = {{v.v2}} + + assert "" + v1 + v2 == {{v.r1}} + assert v1 + "" + v2 == {{v.r1}} + assert v1 + v2 + "" == {{v.r2}} + + assert "" + {{v.v1}} + v2 == {{v.r1}} + assert {{v.v1}} + "" + v2 == {{v.r1}} + assert {{v.v1}} + v2 + "" == {{v.r2}} + + assert "" + {{v.v1}} + {{v.v2}} == {{v.r1}} + assert {{v.v1}} + "" + {{v.v2}} == {{v.r1}} + assert {{v.v1}} + {{v.v2}} + "" == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.params.yaml new file mode 100644 index 000000000..157a114e3 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/concat/conc_val.params.yaml @@ -0,0 +1,38 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + r1: '" !"' + r2: '"A"' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + r1: '"\uFFFF\uFFFF"' + r2: '"\uFFFE"' + + - v1: c'\uFFFF' + v2: c'\u0000' + r1: '"\uFFFF\u0000"' + r2: '"\uFFFF"' + + - v1: c'\u2200' + v2: c'\u002C' + r1: '"∀,"' + r2: '"∬"' + + - v1: c'1' + v2: c'2' + r1: '"12"' + r2: '"c"' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.ets new file mode 100644 index 000000000..61004b7e2 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.ets @@ -0,0 +1,30 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Conditional operator ‘?:’ (see Conditional Expressions); +---*/ + +class A { + static b: boolean = {{v.b}} + static r: char = {{v.r}} +} + +function main() { + assert A.r - (A.b ? {{v.v1}} : {{v.v2}}) == c'\u0000' +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.params.yaml new file mode 100644 index 000000000..b0dbf41ae --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val.params.yaml @@ -0,0 +1,34 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + b: 'true' + r: c' ' + + - v1: c'\u0020' + v2: c'\uF041' + b: 'false' + r: c'A' + c'\uF000' + + - v1: c'\uFFFE' + c'\u0023' + v2: c'\u0021' + c'\u0001' + b: 'true' + r: c'!' + + - v1: 65535 as char + v2: 65534 as char + b: 'true' + r: c'\uFFFF' + diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.ets new file mode 100644 index 000000000..610e3a70a --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Conditional operator ‘?:’ (see Conditional Expressions); +---*/ + +class A { + static b: boolean = {{v.b}} + static v1: char = {{v.v1}} + static v2: char = {{v.v2}} + static r: char = {{v.r}} +} + +function main() { + assert (A.b ? A.v1 : A.v2) == A.r +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.params.yaml new file mode 100644 index 000000000..b94ed9f6a --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val.params.yaml @@ -0,0 +1,28 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + b: 'true' + r: c' ' + + - v1: c'\u0020' + v2: c'\uF041' + b: 'false' + r: c'A' + c'\uF000' + + - v1: c'\uFFFE' + c'\u0023' + v2: c'\u0021' + c'\u0001' + b: 'true' + r: c'!' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.ets new file mode 100644 index 000000000..ebcefaf9b --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Conditional operator ‘?:’ (see Conditional Expressions); +---*/ + +function foo(c: boolean, p: Char, q: Char): Char { + return c ? p : q +} + +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.params.yaml new file mode 100644 index 000000000..987a25759 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref.params.yaml @@ -0,0 +1,38 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: foo(true, v1, v2) + r: c' ' + + - v1: c'\u0020' + v2: c'\u0021' + exp: foo(false, v1, v2) + v1 + r: c'A' + + - v1: c'\u0020' + v2: c'\u0021' + exp: '" " + foo(false, v1, v2) + v1' + r: "' ! '" + + - v1: c'\u0020' + v2: c'\u0021' + exp: "c' ' + foo(false, v1, v2) + v1" + r: c'a' + + - v1: c'\u0020' + v2: c'\u0021' + exp: "c' ' + foo(false, v2 + v1, v2 - v1)" + r: v2 diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.ets new file mode 100644 index 000000000..af27bd37b --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Conditional operator ‘?:’ (see Conditional Expressions); +---*/ + +function foo(c: boolean, p: char, q: char): char { + return c ? p : q +} + +function main() { + const v1 = {{v.v1}} + const v2 = {{v.v2}} + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.params.yaml new file mode 100644 index 000000000..9c11aa021 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val.params.yaml @@ -0,0 +1,38 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0021' + exp: foo(true, v1, v2) + r: c' ' + + - v1: c'\u0020' + v2: c'\u0021' + exp: foo(false, v1, v2) + v + r: c'A' + + - v1: c'\u0020' + v2: c'\u0021' + exp: '" " + foo(false, v1, v2) + v1' + r: ' ! ' + + - v1: c'\u0020' + v2: c'\u0021' + exp: "c' ' + foo(false, v1, v2) + v1" + r: c'a' + + - v1: c'\u0020' + v2: c'\u0021' + exp: "c' ' + foo(false, v2 + v1, v2 - v1)" + r: v2 diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.ets new file mode 100644 index 000000000..2bcacfe64 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.ets @@ -0,0 +1,34 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: Char[] = new Char[2] + +function main() { + let v1 = new Char({{v.v1}}) + + a[0] = --v1 + v1-- + a[1] = v1 + + assert a[0] == {{v.r1}} + assert a[1] == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.params.yaml new file mode 100644 index 000000000..e1cf92dce --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_ref.params.yaml @@ -0,0 +1,33 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0022' + r1: c'!' + r2: c' ' + + - v1: c'\x00' + r1: c'\uFFFF' + r2: c'\uFFFE' + + - v1: c'\u1110' + r1: c'\u110F' + r2: c'\u110E' + + - v1: c'\u0001' + r1: c'\u0000' + r2: c'\uFFFF' + + - v1: c'∭' + r1: c'∬' + r2: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.ets new file mode 100644 index 000000000..f8eaca85e --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.ets @@ -0,0 +1,34 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: char[] = new char[2] + +function main() { + let v1 = {{v.v1}} + + a[0] = --v1 + v1-- + a[1] = v1 + + assert a[0] == {{v.r1}} + assert a[1] == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.params.yaml new file mode 100644 index 000000000..e1cf92dce --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_arr_val.params.yaml @@ -0,0 +1,33 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0022' + r1: c'!' + r2: c' ' + + - v1: c'\x00' + r1: c'\uFFFF' + r2: c'\uFFFE' + + - v1: c'\u1110' + r1: c'\u110F' + r2: c'\u110E' + + - v1: c'\u0001' + r1: c'\u0000' + r2: c'\uFFFF' + + - v1: c'∭' + r1: c'∬' + r2: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.ets new file mode 100644 index 000000000..422f0c7e5 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.ets @@ -0,0 +1,36 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function decPre(p: Char): Char { + return --p +} + +function decPost(p: Char): Char { + p-- + return p +} + +function main() { + const v1 = new Char({{v.v1}}) + + assert ({{v.exp}}) == {{v.res}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.params.yaml new file mode 100644 index 000000000..48363f1ce --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref.params.yaml @@ -0,0 +1,69 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0021' + exp: 'decPre(v1)' + res: c' ' + + - v1: c'\u0022' + exp: 'decPost(v1)' + res: c'!' + + - v1: c'"' + exp: "c' ' + decPre(v1)" + res: c'A' + + - v1: c'\u0020' + exp: "c' ' + decPost(v1)" + res: c'?' + + - v1: c'\u0000' + exp: "decPre(v1)" + res: c'\uFFFF' + + - v1: c'\u0000' + exp: "decPost(v1)" + res: c'\uFFFF' + + - v1: c'\u00FF' + exp: "decPre(c'!' + v1 + v1)" + res: c'\u021E' + + - v1: c'\u0001' + exp: "decPost(v1 - c'!' - v1)" + res: c'\uFFDE' + + - v1: c'\u0F0F' + exp: "decPre(v1 - c'1') - decPre(c'\\uACD9')" + res: c'\u6205' + + - v1: c'\u0F0F' + exp: "decPost(v1 + c'1') + decPost(c'\\uACD9')" + res: c'\uBC17' + + - v1: c'\u1110' + exp: "decPre(c'\\u0000') - decPre(v1)" + res: c'\uEEF0' + + - v1: c'\u1000' + exp: "decPost(c'\\u0000') - decPost(v1)" + res: c'\uF000' + + - v1: c'∬' + exp: "decPre(v1)" + res: c'∫' + + - v1: c'∬' + exp: "decPost(v1)" + res: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.ets new file mode 100644 index 000000000..32e4a17ac --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.ets @@ -0,0 +1,36 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function decPre(p: char): char { + return --p +} + +function decPost(p: char): char { + p-- + return p +} + +function main() { + const v1 = {{v.v1}} + + assert ({{v.exp}}) == {{v.res}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.params.yaml new file mode 100644 index 000000000..48363f1ce --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val.params.yaml @@ -0,0 +1,69 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0021' + exp: 'decPre(v1)' + res: c' ' + + - v1: c'\u0022' + exp: 'decPost(v1)' + res: c'!' + + - v1: c'"' + exp: "c' ' + decPre(v1)" + res: c'A' + + - v1: c'\u0020' + exp: "c' ' + decPost(v1)" + res: c'?' + + - v1: c'\u0000' + exp: "decPre(v1)" + res: c'\uFFFF' + + - v1: c'\u0000' + exp: "decPost(v1)" + res: c'\uFFFF' + + - v1: c'\u00FF' + exp: "decPre(c'!' + v1 + v1)" + res: c'\u021E' + + - v1: c'\u0001' + exp: "decPost(v1 - c'!' - v1)" + res: c'\uFFDE' + + - v1: c'\u0F0F' + exp: "decPre(v1 - c'1') - decPre(c'\\uACD9')" + res: c'\u6205' + + - v1: c'\u0F0F' + exp: "decPost(v1 + c'1') + decPost(c'\\uACD9')" + res: c'\uBC17' + + - v1: c'\u1110' + exp: "decPre(c'\\u0000') - decPre(v1)" + res: c'\uEEF0' + + - v1: c'\u1000' + exp: "decPost(c'\\u0000') - decPost(v1)" + res: c'\uF000' + + - v1: c'∬' + exp: "decPre(v1)" + res: c'∫' + + - v1: c'∬' + exp: "decPost(v1)" + res: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.ets new file mode 100644 index 000000000..2acd9331d --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.ets @@ -0,0 +1,34 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: Char[] = new Char[2] + +function main() { + let v1 = new Char({{v.v1}}) + + a[0] = ++v1 + v1++ + a[1] = v1 + + assert a[0] == {{v.r1}} + assert a[1] == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.params.yaml new file mode 100644 index 000000000..99c330c86 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref.params.yaml @@ -0,0 +1,37 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + r1: c'!' + r2: c'"' + + - v1: c'\x00' + r1: c'\x01' + r2: c'\x02' + + - v1: c'\uFFFF' + r1: c'\u0000' + r2: c'\u0001' + + - v1: c'\u007F' + r1: c'\u0080' + r2: c'\u0081; + + - v1: c'\u00FF' + r1: c'\u0100' + r2: c'\u0101; + + - v1: c'∫' + r1: c'∬' + r2: c'∭' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.ets new file mode 100644 index 000000000..0266760cf --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.ets @@ -0,0 +1,34 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: char[] = new char[2] + +function main() { + let v1 = {{v.v1}} + + a[0] = ++v1 + v1++ + a[1] = v1 + + assert a[0] == {{v.r1}} + assert a[1] == {{v.r2}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.params.yaml new file mode 100644 index 000000000..99c330c86 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val.params.yaml @@ -0,0 +1,37 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + r1: c'!' + r2: c'"' + + - v1: c'\x00' + r1: c'\x01' + r2: c'\x02' + + - v1: c'\uFFFF' + r1: c'\u0000' + r2: c'\u0001' + + - v1: c'\u007F' + r1: c'\u0080' + r2: c'\u0081; + + - v1: c'\u00FF' + r1: c'\u0100' + r2: c'\u0101; + + - v1: c'∫' + r1: c'∬' + r2: c'∭' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.ets new file mode 100644 index 000000000..471ba5131 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.ets @@ -0,0 +1,36 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function incPre(p: Char): Char { + return ++p +} + +function incPost(p: Char): Char { + p++ + return p +} + +function main() { + const v1 = new Char({{v.v1}}) + + assert ({{v.exp}}) == {{v.res}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.params.yaml new file mode 100644 index 000000000..d72c66667 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref.params.yaml @@ -0,0 +1,69 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + exp: 'incPre(v1)' + res: c'!' + + - v1: c'\u0020' + exp: 'incPost(v1)' + res: c'!' + + - v1: c'\u0020' + exp: "c' ' + incPre(v1)" + res: c'A' + + - v1: c'\u0020' + exp: "c' ' + incPost(v1)" + res: c'A' + + - v1: c'\uFFFF' + exp: "incPre(v1)" + res: c'\x00' + + - v1: c'\uFFFF' + exp: "incPost(v1)" + res: c'\x00' + + - v1: c'\uFFFF' + exp: "incPre(c'!' + v1 + v1)" + res: c'\u0020' + + - v1: c'\uFFFF' + exp: "incPost(c'!' + v1 + v1)" + res: c'\u0020' + + - v1: c'\u0F0F' + exp: "incPre(v1 + c'1') + incPre(c'\\uACD9')" + res: c'\uBC1B' + + - v1: c'\u0F0F' + exp: "incPost(v1 + c'1') + incPost(c'\\uACD9')" + res: c'\uBC1B' + + - v1: c'\u007F' + exp: "incPre(c'\\u0000') + incPre(v1)" + res: c'\u0081' + + - v1: c'\u007F' + exp: "incPost(c'\\u0000') + incPost(v1)" + res: c'\u0081' + + - v1: c'∫' + exp: "incPre(v1)" + res: c'∬' + + - v1: c'∫' + exp: "incPost(v1)" + res: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.ets new file mode 100644 index 000000000..9c26217d2 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.ets @@ -0,0 +1,36 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function incPre(p: char): char { + return ++p +} + +function incPost(p: char): char { + p++ + return p +} + +function main() { + const v1 = {{v.v1}} + + assert ({{v.exp}}) == {{v.res}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.params.yaml new file mode 100644 index 000000000..d72c66667 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val.params.yaml @@ -0,0 +1,69 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + exp: 'incPre(v1)' + res: c'!' + + - v1: c'\u0020' + exp: 'incPost(v1)' + res: c'!' + + - v1: c'\u0020' + exp: "c' ' + incPre(v1)" + res: c'A' + + - v1: c'\u0020' + exp: "c' ' + incPost(v1)" + res: c'A' + + - v1: c'\uFFFF' + exp: "incPre(v1)" + res: c'\x00' + + - v1: c'\uFFFF' + exp: "incPost(v1)" + res: c'\x00' + + - v1: c'\uFFFF' + exp: "incPre(c'!' + v1 + v1)" + res: c'\u0020' + + - v1: c'\uFFFF' + exp: "incPost(c'!' + v1 + v1)" + res: c'\u0020' + + - v1: c'\u0F0F' + exp: "incPre(v1 + c'1') + incPre(c'\\uACD9')" + res: c'\uBC1B' + + - v1: c'\u0F0F' + exp: "incPost(v1 + c'1') + incPost(c'\\uACD9')" + res: c'\uBC1B' + + - v1: c'\u007F' + exp: "incPre(c'\\u0000') + incPre(v1)" + res: c'\u0081' + + - v1: c'\u007F' + exp: "incPost(c'\\u0000') + incPost(v1)" + res: c'\u0081' + + - v1: c'∫' + exp: "incPre(v1)" + res: c'∬' + + - v1: c'∫' + exp: "incPost(v1)" + res: c'∬' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.ets new file mode 100644 index 000000000..f3b8a0845 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.ets @@ -0,0 +1,31 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: Char[] = new Char[1] + +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + a[0] = {{v.exp}} + assert a[0] == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.params.yaml new file mode 100644 index 000000000..6521acad4 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0041' + exp: 'v2 - v1' + r: c'!' + + - v1: c'\u0041' + v2: c'\u0001' + exp: "v1 - v2 - c' '" + r: c' ' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: 'v1 - v2' + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u0000' + exp: 'v2 - v1' + r: c'\u0001' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "c'\\u000F' - v1" + r: c'\u0010' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "v1 - c'\\u0101' - v2 - c'\\u1010'" + r: c'\uFDFE' + + - v1: c'∬' + v2: c'\x01' + exp: 'v1 - v2' + r: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.ets new file mode 100644 index 000000000..889f670f9 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.ets @@ -0,0 +1,31 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +const a: char[] = new char[1] + +function main() { + const v1 = {{v.v1}} + const v2 = {{v.v2}} + + a[0] = {{v.exp}} + assert a[0] == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.params.yaml new file mode 100644 index 000000000..6521acad4 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0041' + exp: 'v2 - v1' + r: c'!' + + - v1: c'\u0041' + v2: c'\u0001' + exp: "v1 - v2 - c' '" + r: c' ' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: 'v1 - v2' + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u0000' + exp: 'v2 - v1' + r: c'\u0001' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "c'\\u000F' - v1" + r: c'\u0010' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "v1 - c'\\u0101' - v2 - c'\\u1010'" + r: c'\uFDFE' + + - v1: c'∬' + v2: c'\x01' + exp: 'v1 - v2' + r: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.ets new file mode 100644 index 000000000..c12a5ad80 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function sub(p: Char, q: Char): Char { + return p - q +} + +function main() { + const v1 = new Char({{v.v1}}) + const v2 = new Char({{v.v2}}) + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.params.yaml new file mode 100644 index 000000000..38c8a3a2b --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0041' + exp: 'sub(v2, v1)' + r: c'!' + + - v1: c'\u0041' + v2: c'\u0001' + exp: "sub(v1, v2) - c' '" + r: c' ' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: 'sub(v1, v2)' + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u0000' + exp: 'sub(v2, v1)' + r: c'\u0001' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "sub(c'\\u000F', v1)" + r: c'\u0010' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "sub(v1 - c'\\u0101', v2 - c'\\u1010')" + r: c'\u1E1E' + + - v1: c'∬' + v2: c'\x01' + exp: 'sub(v1, v2)' + r: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.ets new file mode 100644 index 000000000..ad928ef5b --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.ets @@ -0,0 +1,32 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function sub(p: char, q: char): char { + return p - q +} + +function main() { + const v1 = {{v.v1}} + const v2 = {{v.v2}} + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.params.yaml new file mode 100644 index 000000000..38c8a3a2b --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val.params.yaml @@ -0,0 +1,48 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + v2: c'\u0041' + exp: 'sub(v2, v1)' + r: c'!' + + - v1: c'\u0041' + v2: c'\u0001' + exp: "sub(v1, v2) - c' '" + r: c' ' + + - v1: c'\uFFFF' + v2: c'\uFFFF' + exp: 'sub(v1, v2)' + r: c'\u0000' + + - v1: c'\uFFFF' + v2: c'\u0000' + exp: 'sub(v2, v1)' + r: c'\u0001' + + - v1: c'\uFFFF' + v2: c'\u000F' + exp: "sub(c'\\u000F', v1)" + r: c'\u0010' + + - v1: c'\u1010' + v2: c'\u0101' + exp: "sub(v1 - c'\\u0101', v2 - c'\\u1010')" + r: c'\u1E1E' + + - v1: c'∬' + v2: c'\x01' + exp: 'sub(v1, v2)' + r: c'∫' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.ets new file mode 100644 index 000000000..5fc15f990 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.ets @@ -0,0 +1,35 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function minus(p: Char): Char { + return -p +} + +function plus(p: Char): Char { + return +p +} + +function main() { + const v1 = new Char({{v.v1}}) + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.params.yaml new file mode 100644 index 000000000..c4baf0ac2 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_ref.params.yaml @@ -0,0 +1,41 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + exp: 'minus(plus(v1)) - plus(minus(v1))' + r: c'\u0000' + + - v1: c'∬' + exp: 'plus(v1)' + r: c'∬' + + - v1: c'∬' + exp: 'minus(v1)' + r: c'\uDDD4' + + - v1: c'\uFFFF' + exp: 'minus(v1)' + r: c'\u0001' + + - v1: c'\uFFFF' + exp: 'plus(v1)' + r: c'\uFFFF' + + - v1: c'\u0000' + exp: 'minus(v1)' + r: c'\u0000' + + - v1: c'\u0000' + exp: 'plus(v1)' + r: c'\u0000' diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.ets new file mode 100644 index 000000000..d4f9b8ea3 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.ets @@ -0,0 +1,35 @@ +/*--- +Copyright (c) 2021-2023 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 v in vals %} +/*--- +desc: >- + ArkTS provides a number of operators to act on character values: + Character operators that produce a value of type char. +---*/ + +function minus(p: char): char { + return -p +} + +function plus(p: char): char { + return +p +} + +function main() { + const v1 = {{v.v1}} + + assert ({{v.exp}}) == {{v.r}} +} +{%- endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.params.yaml new file mode 100644 index 000000000..c4baf0ac2 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/unary/unary_val.params.yaml @@ -0,0 +1,41 @@ +# Copyright (c) 2021-2023 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. +--- +vals: + - v1: c'\u0020' + exp: 'minus(plus(v1)) - plus(minus(v1))' + r: c'\u0000' + + - v1: c'∬' + exp: 'plus(v1)' + r: c'∬' + + - v1: c'∬' + exp: 'minus(v1)' + r: c'\uDDD4' + + - v1: c'\uFFFF' + exp: 'minus(v1)' + r: c'\u0001' + + - v1: c'\uFFFF' + exp: 'plus(v1)' + r: c'\uFFFF' + + - v1: c'\u0000' + exp: 'minus(v1)' + r: c'\u0000' + + - v1: c'\u0000' + exp: 'plus(v1)' + r: c'\u0000' diff --git a/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt b/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt index 63e4c0c49..f31d42afd 100644 --- a/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt +++ b/tests/tests-u-runner/runner/plugins/ets/ets-cts-ignored.txt @@ -451,14 +451,6 @@ 07.expressions/01.evaluation_of_expressions/02.normal_and_abrupt_completion_of_expression_evaluation/ase1.ets # end of verifier problems # runtime fails: panda#11542 -03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_byte_3.ets -03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_short_3.ets -03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_byte_4.ets -03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_short_4.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_byte_3.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_short_3.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_byte_4.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_short_4.ets 03.types/07.value_types/01.integer_types_and_operations/right_shift/right_shift_long_10.ets 03.types/07.value_types/01.integer_types_and_operations/unsigned_right_shift/unsigned_right_shift_byte_7.ets 03.types/07.value_types/01.integer_types_and_operations/unsigned_right_shift/unsigned_right_shift_short_7.ets @@ -986,7 +978,6 @@ 03.types/07.value_types/01.integer_types_and_operations/not_equal/not_equal_ushort_7.ets 03.types/07.value_types/01.integer_types_and_operations/not_equal/not_equal_ushort_8.ets 03.types/07.value_types/01.integer_types_and_operations/not_equal/not_equal_ushort_9.ets -03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_char_2.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ubyte_0.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ubyte_1.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ubyte_2.ets @@ -1008,7 +999,6 @@ 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ushort_2.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ushort_3.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_decrement/postfix_decrement_ushort_4.ets -03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_char_3.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ubyte_0.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ubyte_1.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ubyte_2.ets @@ -1029,7 +1019,6 @@ 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ushort_2.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ushort_3.ets 03.types/07.value_types/01.integer_types_and_operations/postfix_increment/postfix_increment_ushort_4.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_char_2.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ubyte_0.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ubyte_1.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ubyte_2.ets @@ -1050,7 +1039,6 @@ 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ushort_2.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ushort_3.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_decrement/prefix_decrement_ushort_4.ets -03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_char_3.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_ubyte_0.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_ubyte_1.ets 03.types/07.value_types/01.integer_types_and_operations/prefix_increment/prefix_increment_ubyte_2.ets @@ -1921,6 +1909,123 @@ 05.generics/05.parameterized_declarations/type_arguments_of_parameterized_declarations/method_args1_13.ets # end of verifier fails +# es2panda fails: panda#14140 +03.types/07.value_types/05.character_types_and_operations/ch_n_0.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_1.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_10.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_2.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_3.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_4.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_5.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_6.ets +03.types/07.value_types/05.character_types_and_operations/ch_n_8.ets +# end of es2panda fails + +# es2panda fails: panda#14110 +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref_7.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref_8.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_ref_9.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val_6.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val_7.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val_8.ets +03.types/07.value_types/05.character_types_and_operations/decrement/dec_func_val_9.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val_3.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_arr_val_4.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref_7.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref_8.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_ref_9.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val_6.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val_7.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val_8.ets +03.types/07.value_types/05.character_types_and_operations/increment/inc_func_val_9.ets +# end of es2panda fails + +# es2panda fails: panda#14105 +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_5.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val_2.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val_3.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_arr_val_4.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_5.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_0.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_1.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_2.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_3.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_4.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_5.ets +03.types/07.value_types/05.character_types_and_operations/addition/add_func_val_6.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_5.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val_3.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val_4.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_arr_val_5.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_5.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_0.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_1.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_2.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_3.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_4.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_5.ets +03.types/07.value_types/05.character_types_and_operations/subtraction/sub_func_val_6.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_val_0.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_val_1.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_val_2.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_val_3.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc_val_4.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_exp_val_2.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_fld_val_2.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val_1.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val_2.ets +03.types/07.value_types/05.character_types_and_operations/conditional/cond_func_val_4.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_0.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_1.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_2.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_3.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_4.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_5.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_ref_6.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_0.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_1.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_2.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_3.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_4.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_5.ets +03.types/07.value_types/05.character_types_and_operations/unary/unary_val_6.ets +03.types/07.value_types/05.character_types_and_operations/concat/conc2.ets +# end of es2panda fails + # es2panda fails: panda#13203 09.classes/01.class_declaration/06.implementing_interface_properties/getter_setter_implementation.ets 10.interfaces/05.interface_properties/getter_setter_form.ets @@ -1928,10 +2033,3 @@ 10.interfaces/05.interface_properties/readonly_simple_form_0.ets 10.interfaces/05.interface_properties/simple_form.ets # end of es2panda fails - -# es2panda fail: panda#13730 -04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_n_0.ets -04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_n_2.ets -04.names_declarations_and_scopes/08.function_declarations/03.optional_parameters/opt_param_n_10.ets -# end of es2panda fails - -- Gitee From f62571b638b25bd1cebc084a3ba94f51f178c258 Mon Sep 17 00:00:00 2001 From: Anna Antipina Date: Tue, 17 Oct 2023 18:43:25 +0300 Subject: [PATCH 2/2] Fix tests after implementing extended conditional expressions Signed-off-by: Anna Antipina --- plugins/ets/doc/spec/15_semantics.rst | 3 ++ .../05.character_types_and_operations/ch.ets | 24 +++++++++++++++ .../ch.params.yaml | 20 +++++++++++++ .../ch_n.params.yaml | 5 ---- .../first_expression_not_boolean.ets | 3 +- .../05.if_statements/if2.params.yaml | 30 +++++++++++++++++++ .../05.if_statements/if_neg.params.yaml | 16 ---------- .../do.params.yaml | 8 +++++ .../neg.params.yaml | 16 ---------- .../while.params.yaml | 8 +++++ .../arktscts-int-amd64-FastVerify.txt | 22 -------------- 11 files changed, 95 insertions(+), 60 deletions(-) create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.ets create mode 100644 plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.params.yaml diff --git a/plugins/ets/doc/spec/15_semantics.rst b/plugins/ets/doc/spec/15_semantics.rst index ed89d7e04..6239a483b 100644 --- a/plugins/ets/doc/spec/15_semantics.rst +++ b/plugins/ets/doc/spec/15_semantics.rst @@ -231,6 +231,9 @@ while doing the |LANG| programming. Extended Conditional Expressions ================================ +.. meta: + frontend_status: Done + |LANG| provides extended semantics for conditional-and and conditional-or expressions for better alignment. It affects the semantics of conditional expressions (see :ref:`Conditional Expressions`), ``while`` statements and diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.ets b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.ets new file mode 100644 index 000000000..4910c45ba --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.ets @@ -0,0 +1,24 @@ +/*--- +Copyright (c) 2021-2023 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: check addition of two bytes +---*/ + +function main() { + const v = {{c.exp}} +} +{% endfor %} diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.params.yaml new file mode 100644 index 000000000..959ed0774 --- /dev/null +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch.params.yaml @@ -0,0 +1,20 @@ +# Copyright (c) 2021-2023 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: + - exp: c'2' & c'2' + - exp: c'2' && c'2' + - exp: c'2' | c'2' + - exp: c'2' || c'2' + - exp: "!c'2' && !c'2'" diff --git a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml index 24bd9072f..76f3a63d6 100644 --- a/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml +++ b/plugins/ets/tests/ets-templates/03.types/07.value_types/05.character_types_and_operations/ch_n.params.yaml @@ -19,9 +19,4 @@ cases: - exp: c'2' >> c'2' - exp: c'2' >>> c'2' - exp: c'2' << c'2' - - exp: c'2' & c'2' - - exp: c'2' && c'2' - - exp: c'2' | c'2' - - exp: c'2' || c'2' - exp: c'2' ^ c'2' - - exp: "!c'2' && !c'2'" diff --git a/plugins/ets/tests/ets-templates/07.expressions/29.conditional_expressions/first_expression_not_boolean.ets b/plugins/ets/tests/ets-templates/07.expressions/29.conditional_expressions/first_expression_not_boolean.ets index b3b2d1d2e..d82beda36 100644 --- a/plugins/ets/tests/ets-templates/07.expressions/29.conditional_expressions/first_expression_not_boolean.ets +++ b/plugins/ets/tests/ets-templates/07.expressions/29.conditional_expressions/first_expression_not_boolean.ets @@ -21,5 +21,6 @@ tags: [compile-only, negative] function cond(): void {} function main(): void { - let a = cond() ? 0 : 1; + let a = cond() ? 1 : 0; + return a; } diff --git a/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if2.params.yaml b/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if2.params.yaml index cc402a6c3..386cf7b19 100644 --- a/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if2.params.yaml +++ b/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if2.params.yaml @@ -133,3 +133,33 @@ cases: else return retcode("FF") } + + - use: |- + if (i) return 0; + else return j; + + - use: |- + if (new Object()) return 0; + else return j; + + - use: |- + if ("xyz") return 0; + else return j; + + - use: |- + if (!"") return 0; + else return j; + + - use: |- + if (!null) return 0; + else return j; + + - use: |- + if ([1, 1]) return 0; + else return j; + + - use: |- + let k: int[] = []; + if (!k) return 0; + else return j; + diff --git a/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if_neg.params.yaml b/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if_neg.params.yaml index b19ec808e..7ee892375 100644 --- a/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if_neg.params.yaml +++ b/plugins/ets/tests/ets-templates/08.statements/05.if_statements/if_neg.params.yaml @@ -13,22 +13,6 @@ --- cases: - - use: |- - // wrong type - if (i) return 1; - - - use: |- - // wrong type - if (new Object()) return 1; - - - use: |- - // wrong type - if ("xyz") return 1; - - - use: |- - // wrong type - if (!null) return 1; - - use: |- // missing statement in then branch if (i == j) diff --git a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/do.params.yaml b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/do.params.yaml index 864e870b0..f92b77994 100644 --- a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/do.params.yaml +++ b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/do.params.yaml @@ -41,3 +41,11 @@ cases: i = j; } while (j < 3) if (i == 1 && j == 4) return 0; + + - use: |- + do {i--} while (i+j) + if (i == -1) return 0; + + - use: |- + do {i--} while (i & j) + if (i == 0) return 0; diff --git a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/neg.params.yaml b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/neg.params.yaml index d24cf73a4..be3dd17a4 100644 --- a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/neg.params.yaml +++ b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/neg.params.yaml @@ -13,22 +13,6 @@ --- cases: - - use: |- - // wrong type - while (1) {} - - - use: |- - // wrong type - do {} while (1) - - - use: |- - // wrong type - while (i & j) {} - - - use: |- - // wrong type - do {} while (i & j) - - use: |- // missing parentheses while i > j {} diff --git a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/while.params.yaml b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/while.params.yaml index 923f33217..1f1f81ec2 100644 --- a/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/while.params.yaml +++ b/plugins/ets/tests/ets-templates/08.statements/07.while_statements_and_do_statements/while.params.yaml @@ -37,3 +37,11 @@ cases: - use: |- while(++i < 10); { i-- } if (i == 9) return 0; + + - use: |- + while (i+j) { i-- } + if (i == -1) return 0; + + - use: |- + while (i & j) {i--} + if (i == 0) return 0; diff --git a/plugins/ets/tests/scripts/CtsTools/skiplists/arktscts-int-amd64-FastVerify.txt b/plugins/ets/tests/scripts/CtsTools/skiplists/arktscts-int-amd64-FastVerify.txt index 56dc431dc..6f0e4e658 100644 --- a/plugins/ets/tests/scripts/CtsTools/skiplists/arktscts-int-amd64-FastVerify.txt +++ b/plugins/ets/tests/scripts/CtsTools/skiplists/arktscts-int-amd64-FastVerify.txt @@ -846,28 +846,6 @@ 03.types/04.value_types/01.integer_types_and_operations/subtraction/subtraction_ushort_7 # Not implemented 03.types/04.value_types/01.integer_types_and_operations/subtraction/subtraction_ushort_8 # Not implemented 03.types/04.value_types/01.integer_types_and_operations/subtraction/subtraction_ushort_9 # Not implemented -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_byte_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_byte_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_byte_2 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_char_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_char_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_int_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_int_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_int_2 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_long_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_long_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_long_2 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_short_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_short_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_short_2 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ubyte_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ubyte_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_uint_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_uint_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ulong_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ulong_1 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ushort_0 # TypeError: Condition must be of type boolean -03.types/04.value_types/01.integer_types_and_operations/ternary/ternary_ushort_1 # TypeError: Condition must be of type boolean 03.types/04.value_types/01.integer_types_and_operations/unary_minus/unary_minus_char_2 # TypeError: Method MAX_VALUE does not exist on this type. 03.types/04.value_types/01.integer_types_and_operations/unary_minus/unary_minus_char_3 # TypeError: Method MIN_VALUE does not exist on this type. 03.types/04.value_types/01.integer_types_and_operations/unary_minus/unary_minus_ubyte_0 # Not implemented -- Gitee