diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2cc4c9482f01c8645390e965210fc2eb5abfa36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..580b03519e45677ae815fed72c5a311819ae72bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5c1873b2842ecd87e85731fcabae2bddb53b002 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd637714c5d55f20aff62a0950c7f29b6f43878b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..763ffc500878bae60bc21bb0b828d91b6f7cd064 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c4e6dff6489d656da4b26d3a7657c05b422437b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca7ed31bcf93bb532184af700cd5a06ba683a055 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..114285ccc88d0ee674c8a033cc917cba3833d350 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7dc9f1424779a6e17999cefe2904f85587df9fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..58d51036bc1287cd3b9d48bd11453450fbfa469c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c92cd760dbb018358c6f6eb62ca87325c60ce6f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..54086063aacf4f70d6320e965e2d4a831598ecc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec078208336157130c71efc1af8e583e8ed6939b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..faecb4228a9e82ac9917c676e45d0a2887290c6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2450559b19b9a9b36affae2f1882a7b877e74129 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..b01a2ec7788a74ee7de3657047ee086d5d8dff2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab4b8e2c2505989cef981033c21ffd695bf21d3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2 ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..53e3d256140ba3ab8e2f671a50bba40491866ee0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..33440e5ed08ad6a2bc48b00bce37bd7c0e79dad8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c97d84826537f4039fb89b71347f374c37644440 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ee3fbda65d46471d59af4f910f22b8b8afa0e20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..75279a11c00c28d75bceb46f6d10e4216d2424cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..edc2d269fbce50cb01b3bbc63603891d6f8eb6ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..98d3bd977cf498973fe7bb24c26b820f5095937c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..34657daf64d3987d9ed659fb7342b4e2594a91b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C();c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5e7534c0073daaf252d5211bb801e083c65b83f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc9f1658447d466e2360d82652451bbc07f2ed89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..92910d4cce15db3c2d2bcc0a488f354fb4b513b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4cff8330cc94354a61578b91116b1b5cee5711c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f18360f332e3a09fd6722edb5f5e0355634c25d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a4c0217398072d3ce709a932fac46662803717a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..b9c89e844a2ba8bab419587f588ea0856fb5746a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd200088923dcf6d3284acd6b12e247c1979bab5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..74f2ac700ffbac0fefbbcff7ed11f52626fa3cb2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f87de5ee6e739ea14315ec59a6012cc13920ccf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed28c4509c940c2830761480cb4ce65a626b0dc9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..67513bad2295a26070bf08a3e051f1d468087c8f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d87134c4f57b92655209707eb2b6d2b2cc2be85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3f3d8311fe33b27cf92b521c26ac00ea22a05ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..429cb2c1429ab2ce631654bc7865d56225ca5b2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..19c5a9a006b4a59c1953ab12afe2df992a13381f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..184272b577d59b2942a43e386d77a132b48bba1d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f883c0d5a2d65773e1c965f137507c52aaa5bdb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..97359f5699fd935b8e2bf918f47872255119c97c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..88cd8df3e3331eb8b92edff2ec9d8d20b6a4a47d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..856b61c0fb0b826016207d80d4697111e11970f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0db11c73a0734cb38165390a10bc5c2348724d86 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5439885404e485ae3f92c786dfdf3ff8769deda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0146c99e3cb9a8c7b4f485527c9e89d81444541d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9f8ff35e8d7abc7ee5f53615c4c384302c8e03b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e9d5d9b5f9b0c5b3a941591ff5f227939156d1a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d66c631a98e0dc0ac8551e26f380d0fe9eea4ccf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dd13bb2109b45865545d7f83a035832eb937242 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..263ad99ea5157a55762615ed89f2e0c5395453f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2 ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..09e6656b1b432396dd4da188aa8d36049a9f7ef3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..753c0322cd37b4762862334b63064109f8e56872 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9effc877c1f6bf8305d1ba60d1ae440bec43c06c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f85ea5a76ba952053cad277c9cc5ce5284f94b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d0031a5e2424bb5d6f8f2c9e92b3a1ae8f26489 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..52bd5a2d9bfef4e7774907c24b55785c15c56a27 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..4aff118e50a05faa5af9ceea88b16aa4a16c832e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..03aa5db411777ac38cd06cf986ad38557903f47a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0c862bebab6887c0b5e571e00f0682e36166f36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f10232d41640b5131bb35b81bfedba69c658358d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..45f7eaf4f5b4addac2cc135016612d2449d469f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8f220c178c1afff4eeb660d2a757cb9740fe3a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..63e4b50fac77b7d2c7d9b45a6ec8fd3684c0cf28 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..48e16242bd5fb6accf40ce121d07195beab84298 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..76887cad38737a2c602cb7c74b8c0eb8c8f8b2fc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a229f296922e4e6111560f918bfccb0ca176494 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b886419a34e87f46ea84962936abd838f8ec81dd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..b54ff9a7c473943e4bd9676ab60c57335f65c572 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..4918e9af19b19157c097811422dae73f68db01f6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..60989e1adf84769759d2670e781a83ac57a46c90 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5179f3adc8e095be6ef9b9ff208b851f72dbaaf6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..32224b8543a46e5189dab140c5523f94293d31d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0a5cd5b893976de0dbaf80538f14dca4c80a405 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..e352a4e5cd1b45b2da7cda1ff1a34f17fdfc0479 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0600d3ea3e5f5d90d98ed48df7e415788f8032ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..93a2208687f301d144ecc8d04a7461546196bd1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c368631dc7c760ec0dae1b838841c72d145151b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..49b47b6a3a201f4aeae7d35dea951f21477bed2e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..65658e88de7ff90d169e3bbffc84487fab27038d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ebe0d58b93c1462682ef28e098a6eea713059bc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ddfc8e7b41f7b6166489df16f8e451e47ce1760a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a84f4dab00b2be4d7d7bf2f0d865bd5585f8f929 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0cdbb2c08151e9037bbec27eff0d8e8dac02efa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8ca5ade98fa5c448c8729d1542deca55129c732 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..e722d79d2aef8945d9cdb46587a247277359e155 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..017a88b487c06b338a820e79bbba22178f4c4523 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..33cdb9ab1e441b0e9699fb5a1597bd8348c55e69 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1871f118c4936f9d60f505290f56e8852abcefa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e70f9b78ca752a8ca0595edafd320e09555f581 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..a639e9504ebde3e66cf0092e418f945e0f966afe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f25713ca36fd314b2e96538ea0004c478b97a2ee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..02eeb897a3b3672b1e5c28da29384c9d8fdb6ffc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3edb4e7518f67cc5cf91d543a50d49e1cceda49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b504521e559b8606616c5f4a7a47f16fdd01bb3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c147e2a11b063bb5fc4fb4cae5e491076c9b43e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..855a693ff122f071c3e4c89ab6d37ff52a2539aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0731e38e6ca7629095ab674beccd486b78c2ac08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a3ad9300997d6acc3ff445efc99c74e4c4562b4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..af81a1cbec760d76fea76633f3e8a52b03424d36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..93a983939e90d4e66e2ac804d04d15637a916a73 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..420672bbb5785e1303323eaca09ea23a52b0a993 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..46317f76fd67216821112ceca7f621ff83e9b555 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..09840fca80dff9a9e98ef50cc660e445fc9031a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..b38a0c64af6aeae3ccb574a18c0aeaa035728417 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd08af8a0dce6e00a6a6ec7d2d8c788109f0d8ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..b65d3b6a98705e54e7bd9ad45ad7f5e7368a0d6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d079e072b994011e6e3e4f20552cd4366c078550 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4ff5952a2fb42efdfe5d1f650438fa0de5a3973 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..d99222724ae728561c35840d74f5dfec2978ab17 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..75bd684881ba47ccefc4310a8d04185e75116369 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b885b88d8b691f368dc0ed43d4bb93d7e6c8b2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..245d762eaf1f2574ef574fef4bb146137450c1c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..48fa038c9d4477de3ca7bf055faa00ec2bc08804 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..54e7fd400dc55e68dcdcb9be01b275208c1a2b6c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2112d65d62f5120f9be6905f5817b52e5209e16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f426eb75e382ec634706d3b7fd7f8b860f54337 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3faa455f98eea50c2fd93d564ed64e8521e41f9d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa0831b9f759cd9b35a02e9b39e46ef269127617 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e198abbe73a6cf2c393a9ed5ec5cba3980123d66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..46276b15ceb246e05c42edbe66e91a3df68d49f7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6413b654d87bce911876a1bfbceb0ce2af41054 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..27863accd3870d19a6a20e9c83445d0cada8a28f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0391f30f119afdf327260b676c16fd23d3e14df5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..16efa94c4f39f7d1830967dbd30c2c24c427c9a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d83fdcf5b64268efb89d8e9620d44345d10a471 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..93605a0ec5e710ea394ff262e55c1ba374cb9c0e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbddce7d41d77aa2aad6882966f18d7f7d9d0502 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0db2280e99528fafa1b0b04d9dd8e87ca583dc4d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf004ab41a374b663143f549ef44a8f750c81308 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..54ae860e0b146035128b55d4eb100663a02b4729 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..acfad6825847400bd1a996f480d0f6c62eb36181 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets new file mode 100644 index 0000000000000000000000000000000000000000..1185055f8e7eee2fe9080d33bba4b6c2aa72ee25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fce81bd4bff4db5043cbc58cc73ce75d1b2acbc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cd3b17b687649184cc46cb5ea83816d4f28306f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..111c6d9e881cb33d02e126668b9055ec7548f63d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecb5b273f215f966b616dd6b4945cbe4d53d550e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd151274ae4cde1b07c5809bb89588c209e1c4e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..741454751778da36c9c5be412f812081ff043acb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9cfb159c98b112bd966524088a45a7e6f64c60d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..00261c18822a19158b0121b8f226964da17ef587 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..314684cea7abda23c10eac9f60954f41d999f278 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..04d8800861a1112b3b12939967e36ce4e4d52ba7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..74767f90abb4afd3415112235234d89d31103742 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fda441e5c948c3f7f9d9ebc7403e8345e92f94f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e8517566855388ef2cfc09ade75f2692199f00f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..771d2104c6b03e3aabe5d0f17c1f1780823fbf33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar { } + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a755c546a6c7be0308f9f862c1b9a4b247c2112 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a1cbcef51c5907590237d2b4d5c082e1367e1e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8855bb31b7ab6e63c7fdd2207b092be7a281f406 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5990221e36f1243198c8d575ca4db780fbc91fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +function sum(x: number, y: int = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +let flo = 2.3; +let y: int = flo as int; +await sum(5 & 3, y, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed7fb6def2cecc355db7487224ce61cbd66e32a5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfde2f1b377967ff4fee36df8503b9cfbd26b911 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..76f39bf78fdb9b55a9f36e8d5f099f91984798c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d79d1f9afcf298ca4854fc73b55ef9654fb8cbc6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6905ba67594f6c5bca3617bb6cc6a81f09e9894 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let x = 3; +sum(x!, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5284467fb25d81a8f7b75440af2270b31d92bfad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..11fbd362a47fca4abd976208bd7ec0adb9c18577 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let dollar of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..417213d924a5cfc555ad92264120037a13085ee0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +for (let dollar = 1; dollar < 10; dollar++) { + if (true) { + sum(7 == 5, 2, 3); + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cf93bb2074538b930f84f6a723a6c660c6e54f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +if ((true)) { + sum(7 == 5, 2, 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..77d623858a807106e522b3a918481da7d37a7d3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +let arr = [1, 2, 3]; +sum(arr[0], 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c906e47ec02ede86f6fb4fad0178bc454efaca6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; + +while(!unionArray) { + sum(7 == 5, 2, 3); + break +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..35c00ef0a06fd62a59abc91a4eb3b4d248610730 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 3 * 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..19ffe4af7715ffa2a8162a0cbdfeeee78f14f671 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, null ?? 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2137226f81d9e9edf99c749b03e786e3bf3d915a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, 3 < 2, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e57c76ce548b4036fb0165f8590f9180e3f2517e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +function call(): void { + sum(1, 2, 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f9d330f9e9b5aafb6b5819b40dc02f494e8b6d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, 3 >> 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c46c1563831c7dfec87a34b7dbbe41eda700394 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..46ca16c69564ecd0f09e233778c74524e6c945c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8aa27631bea7d5aa357eac494392f0b6992ee091 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let a = 0; +switch (a) { + case 0: + sum("name", 2, 3, 4); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..63a3d6bc1d16c0ec8c2b119344e0f50c198f6853 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..eea9420b548aa804c1e720abe34559bd2d46d335 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +function processTwo(a: number): number { + try { + sum("name", 2, 3, 4); + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..75391a23a0948b9788160e493b91082b7a70837f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: boolean, y?: number, ...numbers: number[]): void {} + +let a = 2; +let b = 3; +let c = 4; +let d = 5; +let e = 2; +let f = -3; +let g = 4; +let h = 5; + +sum(!h, a++, ++b, c--, --d, +e, -f, ~g); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c96c34e9afc118c3bbc1f2da13c0dbaf8f235177 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let a = 5; +let b = 3; + +while((a > b)) { + a--; + sum("name", 2, 3, 4); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3f6fbfa124867fc615208e6ffa679ff74cbba3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +(2 + 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..050cfd6fae0601a3ac4815cd43ad0831a219f889 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface dollar { + a: number = (2 + 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..181129f9980352a948674ae308e0071dca085b72 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface Version { + versionNumber: number; +} + +@Version( (2 + 3) ) +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..94605865068e62e398912684847c6e6f490f9947 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let y: number = 3; +(y = 4) diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b763f7f4e7098d0079df08aaf0d6f430c850212a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function main() { + let result = await Promise.resolve(2 + 3); + console.log(result); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0acb04d62cad1544a7b6499e8aa9a52302448b52 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(((5 & 3) | (2 ^ 1)), (3 + 2), 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c8dbb7030ffb118dccb04de3e33496602d13280 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +let dollar: Object = (x1) as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6af1e581802a56ab7b7204b8e26201b7a0b6c16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return (x + 1); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..37cbe9144d963174a568621fc5ba5c162a977bc1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..72f03abd265f8a1f1c9ad8df8617f4a7a87acef0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(((7 > 5) ? 7 : 5), 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d45afb3274fe47a31c73e1d7df7d80be98982e01 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(("a" || "b"), 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..538da23d8fa5c3e79314183b64d5739f885f5702 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = (3 + 2), z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5828eea699d92448982ae33094f282effc6b70e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let dollar: string | null = "Hello"; +(dollar!); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..26952de3cee851abd222d020ddd0fe6e359f5262 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum((7 == 5), 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5996877b7ace80a2863fcfd77ec850646567ebc1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let dollar = new Person(); +(dollar.name) = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5a27e0ce98ad9f9b09a9a8f14606cc0774f2c46 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + (2 + 1) + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ebbd3d1b848bdb70418d4ad531ddb77b08943ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let dollar of (arr)) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..51bb8be4de3736156885d3aecb973f6328691698 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.6 + * Identifier: + * IdentifierStart IdentifierPart* + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let dollar = 1;(dollar < 10);(dollar++)) { + if (true) { + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0945b38726cc3a8cde2ad1ee1dacdee5744c5562 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +(sum(7, 2, 3)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab870c15578c02709a310c03b630f8b79177939f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} +type FA = ((this: dollar) => boolean); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3942d84aa25d569c99d91bb54974c12c060f5898 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if ((true)) { + let dollar = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..849c9da828399ae4ce723488955cfbb45b7a2409 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const arr: number[] | null = null; +(arr?.[0]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..62719060378f236c5eb39344f8e9d03a9cbb2c0e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let str: string = new String("Hello"); +(str instanceof String); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..daff30ddba36b87ca6ecc6dc5a72c15cbb945f42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: (() => void); + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..9214f948d0496cae5129e5ee85d9391e1e5e971b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: (() => void); + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ac9d9d43293ec94aa66384b76723adbdacb100f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 1; +while((a > 0)) { + let dollar = 1; + a--; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3f0e4757a754873dafb09245e62baaafd9268a5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +(person.setName(1, 2, 3, 4)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..75578074160aee61e5f1eef5819a525f8b56469a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let dollar = 1; +let a = (new string[dollar]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..58065b887b284ccb1bd49a4cccadad580aa73e7f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class dollar { + constructor(p: number) {} +} +let instance = (new dollar(5)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c872ec5d048b75e734d1217b7b172927ad55417 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +(null ?? 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..edb009ca94454146f446d8efc4267923b4009405 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: boolean, y: boolean, z: boolean): void {} + +sum((1 < 2), (3 < 2), (1 <= 2)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f005eeec02b2e61530c667e93241e80c7b185364 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return (2 + 3); +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..36e068d202089da908fcc263f70a167894a1bed2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +(3 >> 2) diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..825f85ef83a93def491351283de3517263d9ac9a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let dollar = (10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d3164e6ea997ec97cbb38c74faa301c57f17401 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = ('Alice'); +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ca5c2534b3ffe7048597dd80a14bd2c121a00e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch ((a)) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..51863db3c87c54a21b60d904933aa41192779c06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: (C), n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..843087ea75cf5447e46e9151a31ddaf013f80d35 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let err = new Error(); +throw (err); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..37cbabc9f3e641dd786b81c4516e4bdd6b51227b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +(a.methodTwo)("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0744b4da51d75d7a89c1e68d82b2558861c7c5ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + return (3 + 2); + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..022158321d03de7f9d6c8f02f9613072b2209aba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let n: number = 1; +(typeof n); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..577d17d383dcba7f91860e869df6792dac381fc9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let dollar = 5; +(dollar++); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8367705f7b77d4d6d6f3c3228468d4395b578910 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let a = 5; +let b = 3; + +while((a > b)) { + a--; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f6f2512120cf687c1b28e9451c57c52ef193f83 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..02eb826be759cc65a2b84ff36fe2e3a24204f499 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbcf7806bb39dd2bdac1a1a6642e422492a2a116 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..8afce656c57778ff86f47dc5948a5c0747a4aeed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + first = [1, 2]; + second = [3, 4]; + unionArray = [...this.first, ...this.second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b18bc04e763d6a18c619f32c2f2555e639b64863 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let useFirst = true; + +[...second] && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b61916fd39b8811bf58b07cd085aee3c595b53b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let useFirst = true; + +let result = [...(useFirst ? first : second), 5, 6]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..108220345f9cce468f1d4f72902234d7bf0d4f4e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first || [10]]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cba062368f7386be4c9a66f45f47833fec215c2e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first || [10]]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee07da8ece32e5f06b1708bccc42a9fe45e22479 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first!, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..01a4db30c015dac9d3be0e1c9ae7833000e53928 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f8fbc1a8c64312c0e810e678facb5281f1d0b20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let first = [1, 2]; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + [...first]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..bef2ae00da273f0630b6f93beb8ce8d963efac9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let first = [1, 2]; +let unionArray = [...first]; +for (;unionArray;) { + if (true) { + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..79e08ebbae3534118c4c3d16f2ed79e7c259544e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b3df5e87d9767d2dff8e61487d7271ebd5dc0f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.6 + * Identifier: + * IdentifierStart IdentifierPart* + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ad7f6ba5577b6dd215ace45acf82f06fce7d7f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = [...first, ...second]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..167dca73a6874dd0ac12e6fcf488ac1c5e0c4a9b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; +unionArray instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9feffa0966503c3a38ec3f25fb6e3c13524ce80c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; + +while(!unionArray) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8c3c4084446188489c2234e39638305f5c5ad74 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +let arr: number[] = [1, 2, 3]; +person.setName(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd6e967fd1ed269205aff18521768bed873fe2ad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = new number[5]; + unionArray = [...first, ...second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..44be6b91e37f2d87c289272f5dc2886fbb651ab6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..24b43e680e7b201ad344d73ec2592b3e4f9dc6a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..49417dec32326f2d0169c70ab8b6d2f2585e7009 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first] ?? [10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc6b027579352971a74908e357c056265878e99a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let first = [1, 2]; +let unionArray = ([...first]) ?? [10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..17e8a0dd5dce6cc659fbe5578771d58abcd33931 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..618f20a894fbff465f36b2ba8378d07b926dab81 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +let first = ['Alice']; +let unionArray = new string[5]; +unionArray = [...first]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cd43741c33aaa90817829c0a71e17bcf1da2361 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ExampleClass2 { + first = [1, 2]; + second = [3, 4]; + unionArray = [...this.first, ...this.second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..1574594090f80d60ff93cac3defb20ca707dddf6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; +a.methodTwo(unionArray) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5afcf3b30262f4a88712411906ccc40a65a9b968 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = new number[5]; + unionArray = [...first, ...second]; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e522164dc7dc7d39f4dd1f27c25a886559b1027 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; +typeof unionArray; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a1dc3ce65f67b85cfb525f8cd43e2c7cc8266b60 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let first = [1, 2]; + +while([...first]!) { + break; +}