diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..52f3ef9343a660eeceee6d6d9481f6ae6e2c140a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationDeclaration.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + name: string; + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bfe8b8c486add481f32437e8bc63383b73558ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_annotationUsage.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..57e036d7e4b91866add5c1e3a73031e8e8cebd09 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(): Promise { + return 42.0; +} + +async function main() { + let x = foo(); + let result = await x; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..61c44c81424b9624afa95b4b057b4403f036a657 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_classInitializer.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class X { + static initialized = false; + static initializerBlock() { + if (!X.initialized) { + X.initialized = true; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b85c43f72708a1061317b9b25da9a3106b27826 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_conditionalExpression.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let x = 5; +((x += 1) > 5) ? x : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..adb900b89c8c3a0791ba82bc16db04593d07847b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 5; +const x = a + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_enumDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..c01e32c5bf5b27107ba966df24fd06c61fa7b9e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_enumDeclaration.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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum x { Red = 1, Green = 2, Blue = 3 } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..795fe8fd68ad2d821243556193573eeeea513391 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportDirective.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} +export type MyA = A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportTypeDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..091b1971ee547d54f559fdfda0a94b36923e6575 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_exportTypeDirective.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} +export type MyA = A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ff1b3a33397e8028a2a9e3f977cef87ffc18719 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_finallyClause.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e348727106a3c5e801f3a533a68b034883346c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let x of arr = [0]) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3839adf5dadc4450f9bb4f619e77e37a059da4eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_forStatement.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = 1; x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..b123fd15f38b2addf0ac4572f5a08fbb6bdb3cca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a48c2f6bb19594754f9a57ae6b5de29193283055 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_ifStatement.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1; +if (a &= 1) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7d86fbddfa16863b2b9808beac9ddc6fcc41ee3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let x = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..db8a6694fb196fb8f263ce8bf4e6ca490c705a24 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_lambdaExpression.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(x: number): number => { let a = 1; return a }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..1510adf7aa861b5a1c065ff14e5061e63f3ce957 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let b = 2; + return b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..78d7b24b94a6a534c2fdd991c96ef75a906b7590 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_loopStatement.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let x = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..5586e74da8f0a36b276571aafbf881a3997726a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_namespaceDeclaration.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd227753c63529988c02090a846c0c7a98a61202 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let x = 1; +let a = new string[x]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..84a0df6b71b32ef59c1fff2a2e9266f972b93ee5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_returnStatement.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return number1 += x; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..4cc8a1fb42d7e730ba9d45fc060e050aa69a35ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_separateModuleDeclaration.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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b2680159bdc50cef5f7888beeb3b4369a0c275e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..95c2df461bd70e4ec21ff26c1392965a346ec9a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_stringInterpolation.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let x = "Alice"; +let s = `Hello, my name is ${x}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..33f36f960bfeddf8438ceda84208fff430c2526e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 0; +switch (x = 1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..00955d389f72700fc8b8b98cbb120403196dc14e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let x = new Error("1"); +throw (x = new Error("2")); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..23a48e61d1d2d2fdc4b6d871ea99186bce441e68 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topDeclaration.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..905fa6da2558add8c96e8a3e8b7f30df5f29a8e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_topLevelStatements.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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..9df2dd250be39f8fc9b6f1a836c3978c048232e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): number { + const result = arg; + callback(result); + return 0; + } +} + +let a = new A(); +let test = a.x("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..572c36cb7547d19edb23e1951babc79f13eebbed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_tryStatement.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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = 1; + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a854b76c903d2c0849350c99601ba0b55b484c8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/assignmentExpression/assignmentExpression_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.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let x = 5; +let n = 3; +while(x &= n) { + x--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbede86cfdee251d8ba4ea9bf862886ff235130f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationDeclaration.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + name: string; + value: number = (5 > 4 ? 1 : 0); +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8bce7e01cd9b08b40a4e1b508701293011ec9a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_annotationUsage.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = (5 > 4 ? 1 : 0); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..81dd7bb8ae73cb7bd745b91fe36fb74d99025096 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_awaitExpression.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(): Promise { + return 42.0; +} + +async function bar(): Promise { + return 10.0; +} + +async function main() { + let promise = 5 > 4 ? foo() : bar(); + let result = await promise; + let anotherResult = await (Math.random() > 0.5 ? foo() : bar()); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..2b391382073f896ca4dc7e5386057f9acd5280f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_classInitializer.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class X { + static initialized = 1; + static initializerBlock() { + if (!X.initialized) { + X.initialized = (5 > 4 ? 1 : 0); + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..19bb6d414f20976938491fc2beab3c9797687316 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 5; +const x = a + (5 > 4 ? 1 : 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_enumDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..375fb0447265d9fbd996e06e0d29d38c4794ee3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_enumDeclaration.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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum x { Red = (5 > 4 ? 1 : 0), Green = 2, Blue = 3 } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..0edd269395c95e3ac6e745c59199cfbe05ec1893 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_exportDirective.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +let a = (5 > 4 ? 1 : 0); +export default a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..d82f9ad011a310e3682d0e5b1a96cd48a46e1aca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_finallyClause.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = (5 > 4 ? 1 : 0); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9c12ab3a69554a9b2915860cb4f9154ebbe02e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1.0, 2.0, 3.0]; +for (let x of arr = (5 > 4 ? [1.0] : [0.0])) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..300743afdf08ee16bc15e1677ab8078b7ba50194 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_forStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = (5 > 4 ? 1 : 0); x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..17ff3f2cf8b1239b8a548430d5b443b51fb89c96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_ifStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1; +if (a = (5 > 4 ? 1 : 0)) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa9dec8033ef6b465b1b37f1cee09276a05bd7cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let x = (5 > 4 ? 1 : 0); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d02e9fd7496bb74849ba27b5da376be5622c3f3d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_lambdaExpression.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(x: number): number => { + let a = (5 > 4 ? 1 : 0); + return a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..a64839941d06e56ba698319f0d4196cfb23604c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let b = (5 > 4 ? 1 : 0); + return b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cfbcab2b31bb026a3ec5da9b4b40442c0482aac3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_loopStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let x = (5 > 4 ? 1 : 0); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..d35a85b55b5ad91fbb13d7af4e56cdbcb5a04e54 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_namespaceDeclaration.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: number = (5 > 4 ? 1 : 0); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..edf6b10ddc559be872ad488a661a693ba6cb89c8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_newArrayInstance.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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new string[(5 > 4 ? 1 : 0)]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6db8614ed730920e4876f97ddce858454b461171 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_returnStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return (5 > 4 ? 1 : 0); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..aefd3196e8b2ba604ed8935c43ba400d15ef4c74 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_separateModuleDeclaration.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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +export default const x = (5 > 4 ? 1 : 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..50be2f6c43a796af86044e0e7c63e1d207eb555b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = (5 > 4 ? 1 : 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc7ad51c4e7ab36854bb874f9031d40c91a1fb33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_stringInterpolation.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let x = (5 > 4 ? 1 : 0); +let s = `Hello, my name is ${x}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e69674b713c3ce63d3544e09b10048babcaa50a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 0; +switch (x = (5 > 4 ? 1 : 0)) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..837906a07fe56491df3572281fad94bd6c61e95a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topDeclaration.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = (5 > 4 ? 1 : 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..648fac77abcbd45250bb0d5032aecea335748f9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_topLevelStatements.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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = (5 > 4 ? 1 : 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..dccc7f699fd564651d52aa29be27ec0c2372dd24 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_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 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): number { + const result = arg; + callback(result); + return 0; + } +} + +let a = new A(); +let test = a.x(5 > 4 ? 1 : 0) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5dc7957909fd35e9307e360c835918b1403d8209 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_tryStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = (5 > 4 ? 1 : 0); + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b5586152623012260849277f4e25bd5264cbab17 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalExpression/conditionalExpression_whileStatement.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.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let x = 5; +while(x &= (5 > 4 ? 1 : 0)) { + x--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f0f803f4392c1176c494575e3aa13308479c289 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationDeclaration.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + name: string; + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed266e107069dee12eb5ccbd586992c847ecaa26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_annotationUsage.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0fb58bc9cacd4b6eab08d60e33e8ada148713f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(): Promise { + return 42.0; +} + +async function main() { + let x = foo(); + let result = await x; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..04179e9577d6e3e4668bd3a904b09cf0f69cb7be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_classInitializer.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class X { + static initialized = false; + static initializerBlock() { + if (!X.initialized) { + X.initialized = true; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_enumDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d90ac4572b007aa34929295ab1fa4125836f1f7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_enumDeclaration.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum x { Red = 1, Green = 2, Blue = 3 } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..8535ca7d8d1b8d119a5238351a78cf86d55220c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_finallyClause.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c034f900db2a1501dc2a594b2abd3a748a6b905a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forOfStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +for (let x of [0]) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0d7ba31538283e0fd18e774b615d93aa1f3a2bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_forStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = 1; x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2e85828388032074cda57596be989b0bc12a361 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_ifStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1; +if (a &= 1) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2249ae75ee04439a73679b979ffeba9755f6640 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let x = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1ff546432978fe3a51e57203a4434e76d08d7fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let b = 2; + return b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c55c7197997d5c2fa2c0903632512552ba1b1b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_loopStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let x = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c749aac233945e2fd27e06b804eb7f60326b00e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_namespaceDeclaration.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2411f7dcc878e27c9fab4b29c8b3fe76836b571 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_newArrayInstance.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new string[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b205aa743d5509a52172d0f0d645c6d91ff05c04 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_returnStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..8067b98d54f9101e51915199c840bb14646edb1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_separateModuleDeclaration.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c99afd0c62439a608422b1901ef1a821e50dde97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..032ca4a459c752eef20f4744dc978224086fb40e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 0; +switch (x = 1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7286d72a007822c324f667b1a460972285118b50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_throwStatement.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error("2" + 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7c556ed7d0d86818f1913b7a54716802cf63fee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topDeclaration.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c216117dd7dca4ec41e87705a053b9c18c74083 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_topLevelStatements.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5270bcbf1c4093e53941ff02d884bd3650714aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): number { + const result = arg; + callback(result); + return 0; + } +} + +let a = new A(); +let test = a.x(1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e0d75e868ca988cb8a918950d74bd0165232f58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_tryStatement.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.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = 1; + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0dd6423997dd82512dce194b018a483c92675ee3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/constantExpression/constantExpression_whileStatement.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 7.33 + * constantExpression: + * expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ed9139237ea5a88c90ff746ba5c77a39d47da1d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_awaitExpression.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +const bar = async (): Promise => { + return 24.0; +}; +let result2 = await bar(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..99f19db1d6d25c0af55d2005a2260596d48b00fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_classInitializer.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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class X { + static initialized = (a: number, b: number): number => a + b; + static initializerBlock() { + if (!X.initialized) { + X.initialized = (a: number, b: number): number => a + b; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4e634be05d9b1ef96bae192b8bf3421b0ffccaec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const x = (a: number, b: number): number => a + b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ab4758d3f65137b1df8005b7a0da758af71331b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_exportDirective.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +let x = (a: number, b: number): number => a + b; +export default x; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..9867d66a9334a997a8ccc36452691d2fa7a456e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_finallyClause.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = (a: number, b: number): number => a + b; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6330ca65d85604313c9e991e3508996935ef1354 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +for (let x of (() => [4.0, 5.0, 6.0])()) { + console.log(x); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..aae9d124a974701cf3a52911acff7ad26f70d1e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = (() => 1 + 1)(); x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..f52811512d4929176d9e3524cd93e0c651d668bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} + +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c2c5f8cb4d40fff53f973a4636c845c1e3b1e80 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_ifStatement.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1; +if (a = (() => 1 + 1)()) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d2a6421760d3c23e0c7c907a7db5e1eaa3dde49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = (() => 1 + 1)(); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..c59277ca1a8fdb0b703e7c4817adfd7045cbf085 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_lambdaExpressionWithReceiver.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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let b = 2; + return b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e81f66e8afa11d501a6dc93d7545ba96e57e8698 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_loopStatement.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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while((() => 1 + 1)()) { + let x = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..be918918bed1fd606546ad2f30b6898439366f70 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_namespaceDeclaration.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: number = (() => 1 + 1)(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..de8ffa60a81386c31be20f5c68d54cb1642183bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new string[(() => 1 + 1)()]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca0e59f0ceb80b58bd88992981098893b5f9f7f6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_returnStatement.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return (() => 1 + 1)(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..2bdfcc11e139391237347388a627388907289139 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_separateModuleDeclaration.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +export default const x = (() => 1 + 1)(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3cfa1af12465b107fda49be1136d87f44b1b1ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_statement.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = (() => 1 + 1)(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9c4cf24af1e0408de85c9c9e9dcbf413738b6ee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch ((() => 1 + 1)()) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..f97cda569542ceabda5755a3d6f525b20154171b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topDeclaration.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = (() => 1 + 1)(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..b28291e74a53703b06d42644fc4b3676acdb4abb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_topLevelStatements.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = (() => 1 + 1)(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..a961b11cfb762332811e58c8ab5c56be885532fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_trailingLambdaCall.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): number { + const result = arg; + callback(result); + return 0; + } +} + +let a = new A(); +let test1 = a.x(42) { + (result: number) => { + console.log(`Result: ${result}`); + } +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..28959876e31f6be7cf2bf41be367322fb47f2a9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_tryStatement.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 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = (() => 1 + 1)(); + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e2ee79d321ed8c427720cf654d777b7307aaa7c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/lambdaExpression/lambdaExpression_whileStatement.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.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while((() => 1 + 1)()) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..f03cc9cfd73df0fc24ca79f0ca4aae4d41544a02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_classInitializer.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +let name = "World"; + +class X { + static initialized = '1'; + static initializerBlock() { + if (!X.initialized) { + X.initialized = `Hello, ${name}!`; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..37e387181fe03cdc1bf13b6dcbfcce2b7a9503ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let name = "World"; +const x = `Hello, ${name}!`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a74b746c2748ae58fba14559df7647f9a97d527 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_finallyClause.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let name = "World"; + const x = `Hello, ${name}!`; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f5ecd7e28646b39b00d1b4edc92216584f222ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_ifStatement.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1; +if (a &= 1) { + let name = "World"; + let greeting = `Hello, ${name}!`; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..dcdb840c03ba29c13cc0f20c516209f3e92589f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let name = "World"; + let greeting = `Hello, ${name}!`; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd81bd4aad5a36b0fc9a7edcaad3db3c5839376e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_lambdaExpression.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(x: number): number => { + let name = "World"; + let greeting = `Hello, ${name}!`; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..f005af7854d59c404339e4c0a2f4a91dd6b98a56 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let name = "World"; + let greeting = `Hello, ${name}!`; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3bf4f1ddb8585fcd953fdc9f0a3ebc8deb812b96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_loopStatement.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let name = "World"; + let greeting = `Hello, ${name}!`; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..286f0bdb317f431b340fb2e06fde65c5083fb7d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_namespaceDeclaration.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let name = "World"; + let greeting = `Hello, ${name}!`; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d58e7db2a14e101ec6d91a2fcef0ad9a3f97a159 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_returnStatement.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(name: string) { + let name1 = "World"; + return `Hello, ${name1}!`; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d876957818d6396265094a30be39b578e4741b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_separateModuleDeclaration.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let complexExample = `Result: ${2 * 3 + 4}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d4095d39764187b342235abc8e9635a578ca9e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let complexExample = `Result: ${2 * 3 + 4}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6881da766dd337677a2e4b3ef171ce772eb7a057 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_switchStatement.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch (`Result: ${2 * 3 + 4}`) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..06613157ea73d82f61ad5ec05e6876eba555de9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_throwStatement.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error(`Result: ${2 * 3 + 4}`); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..9b857360e8cc03a1a1274716796f7f6e8661f072 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topDeclaration.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let complexExample = `Result: ${2 * 3 + 4}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ff0dd80d69f6439eef3f54ac0e05ff6687c6df6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_topLevelStatements.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let complexExample = `Result: ${2 * 3 + 4}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..012f7b5c7556f596a4f5f76dbbc5b025180c9bb0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): number { + const result = arg; + callback(result); + return 0; + } +} + +let a = new A(); +let test = a.x(`Result: ${2 * 3 + 4}`) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b018e69108e1852e03a51be81cf7a1a73cf9348 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_tryStatement.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.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let complexExample = `Result: ${2 * 3 + 4}`; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c8b6e66381f44a5f9592249ba5d6d43dd37a5fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/stringInterpolation/stringInterpolation_whileStatement.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 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(`Result: ${2 * 3 + 4}`) {}