diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..66e032eff2947ef06ec774e74ffd27a9b6081b0d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +const a = 1 + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..476ba3cb4329a39bd42e41ee35d1026fe26a3219 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +const a: number[] = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f75d1d28bea3b6006406581757e84562fbe7ec91 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let a = 5; +const test = a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8fa30b7cdab680816547c333185fbe0cc9f84d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} +const res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3ed8168e08673075088662a9d27f3cb953cc34fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +const test = 1 & 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..af7fede22dec8d7913b7627a6cd2bdb7b9108107 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +const test: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d21e48e84376fbfd61336a60a848e680a65cd5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +const a = 1 && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9afa3143344126b10902f252fd23c17543fccf0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +const a = 1 > 0 ? 1 : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d041228ab505d2400802329090e4533d6f5b1f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +const a = 0 || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0952b27c75ad8b6b6554ab901f4ec962656ff570 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let test: string | null = "Hello"; +const a = test!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f77c0278b58c417f034707191e3ad9b296e02d27 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +const a = 1 == 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1d16fab7644dfb88a18943bec29455d5b46813b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const test = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..55ae4dc53b1ae986d6b7ae28bc6f08b546bf5830 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let test = new Person(); +test.name = "Alice"; +const a = test.name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa862ea66ca9e7af6d139573f00e045e08f5f4a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b82091622b0d7ac1685f64c2a2beafb740e11ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (const a of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1cb03e9d19eb3ca2f5984234845e074e61e59ea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1; a < 10; a++) { + const b = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8ef65fa0903df38ecb02cfa970dfe55d632ea12 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let a: Person | null = null; +const test = a?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..10c44236f4959888ab6548ad3261bea8b6054b77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6eff4b386585c2625ca6ebee23beea7a33518d29 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const test: number[] | null = null; +const a = test?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d1d88a664b96627be744d1c820abeea2d797746 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + const a = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a5da30062b20780afc17eff010f806be11fa8f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +const test: string = new String("Hello"); +test instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f26593e8cf48d39f1e2f23c21c0f864897050e83 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const a = (test: number): number => { return Math.sin(test) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2ffdfac8901ee0b26dd3d7f4316ca6b97a345cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +const result1 = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9cbe473467bd45b222f5d347f101120266ec7bc3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + const test = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6173d06863ffc4c4e5b5cfcd23bc67bc3aaac04e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): string { + return `Hello, ${a}`; + } +} +let a = new MyClass(); +const test = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd83712f5b0b634299fccbf24236368ea87df5fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +const test = 1 * 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf1c7420f362dc59df7bbad3b67494aeb7d36b03 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace test { + const a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..adbf0e48dab65397cb2f95f34086b5084d48aa2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let test = 1; +const a = new string[test]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..984b090039b93947047bf7f006f8d10c9136dbde --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class A { + constructor(p: number) {} +} +const instance = new A(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..baa0392303fd4ba1f96cfd04082eba3a74fb237c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +const test = a ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff3e9e04fe4cafb934d113cc019424ad6790f6de --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +const test: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b8ff69ff9fcccdb33298cb2065601561e72f834 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class A extends BaseClass { + constructor() { + super(); + } +} + +const test = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..be7ca7aab1af14aa86efc9d6f85aa01c2ecbe8fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +const test = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..50a1a5125c2ff36e4972487d7badef939e4419f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +const test: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b5b96306d7ea6e210cc4548a1abe23020820aa8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +const test = 5 < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..0be5faf02af9b1ddf314b545ecccf993fea47c00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +function test() { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ea3a5863b3fa1c932ff1c4151ae330590b63b95 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +const test = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e4db6106c235174b47847e5b3731b37eeaa17e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +const test = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f390c7c53522c4844ad728c4d8663b50f247df1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +const test = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9dc2f14b077607e6c8659f57431057088b5f40b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = "Alice"; +const test = `Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf10a17460d397b36921d3f5b5cf66cff51f891c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch (1) { + case 1: { + const res = 1; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8cbdfe4d7a1881556339fa903d001a7286a3e63d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + const s = this.name; + } +} +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bbff99dc5a9e7eb0f809f1fd2d5df95a79221f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +const a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..c108fc20ffef4adbfdbf96a508399cae25934179 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + add(arg: T, callback: (result: T) => void): number { + return 0; + } +} +let a = new A(); +const test = a.add("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..939e22f06077cd865d154640f25cd079d0cf269b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const test = 1; + return test; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3ff8e59f9f4f00f62a0bae69c18065c27b89021 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +let a: Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..59fa0953029f7768aaeae539ec11dcbc8380ce3a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +const test = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..876fa18f79968d006f9a601b9d8a61db50842b74 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd072e5a5e0fb70cd1a2ad2dab4536cdd9055ed1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * 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/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..642efa8974d8b8e3a1f1d6fa3c9a4f07a4deb17c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +type Handler = (s: string, ...numbers: number[]) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..d39ffb89b3d842419e54a195accdfc6a36206289 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +type Matrix = number[][]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfc953fe251e25c6cd36c1509d2b194453aa21a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +type Handler = (s: string, no: number) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd84e6c37ac992806d2f4548f0a966d5a7b9c96f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +type Handler = (s: string, no: number) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..76bb6ae6a93652f97c891a103288ef91a6c7f5a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type A = number | string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4dbf8052077921fa0492ee7c5cf10a6362a0734 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +type Dictionary = Map; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..55e35c435d3939ad01fe22aac92508eda9fdd658 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +type Predicate = (x: T) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d00d79822b554ad29dc410e0f6f6085ebd5617fc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b9448ecc576087b8dc74feb9c13e1399de0e073 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let a: number[] = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fe9d2a128d8c4bae595e9051897f0b0412dcaaa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; +let test = a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..24b121886129961596ed9e2973c442991aecbb8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} +let res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1236528c76338b28baa3987fb2ef4e3f604c033a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let test = 1 & 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..416f960f63c9a55f384ddf8f227b59263f5a9537 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +let test: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf10f99e479e3a02cdf193ce80e7fe272cf6fb19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = 1 && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..702e96e01307861cc93df78498c5e77c663bd10f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 1 > 0 ? 1 : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b67dea89694ac1b000596f13c2a5c7cb2068ccec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a = 0 || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..02272f37bf367b065c5eaaca77107fd13de3e792 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let test: string | null = "Hello"; +let a = test!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..228191c644da846e734e6a4f623bc4b05360b7ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 1 == 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c0d7eec174017a1bee3f7dd76330e2a22b3840b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +let test = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1679508d50f829585db0fe047b3ccc560237daae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let test = new Person(); +test.name = "Alice"; +let a = test.name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..a0b470f47df99e1591687f72aafb85fcae7cadff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..65902e0c0012395dc7cc296fdb57648859dea0f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2feb04c609915e44d21ab8b2b7756bf618702fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..88e1efe5e2bde0324656e43cc381d31faeef1137 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let a: Person | null = null; +let test = a?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d120efd87b63ba9dc81c8c82105541d1da03a809 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e42ce88eb0a8a17f37c681c12bf3f86e83b9ea48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const test: number[] | null = null; +let a = test?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ca1849bb985e6e2c88c5b6f1c04d60741244a03 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ba7253f5921a35ad38201cdfa58ab93f6b19dfa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let test: string = new String("Hello"); +let a = test instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..163db2429ffdf86ff217b0afcb9e56636876fc49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let a = (test: number): number => { return Math.sin(test) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb705dc4159d7f8887c14f3b67dfeb52ce91d098 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result1 = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..141f48b927e368ce990ae284fd9f592e52037bbf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let test = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..59324fa6b18675633b421f67d453177deb0e2552 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): string { + return `Hello, ${a}`; + } +} +let a = new MyClass(); +let test = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f38a10bb9ed2d8d3ebb25a5c3594ea901e5370a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let test = 1 * 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..8bf774c584a5593a3518d54741752067e49de178 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace test { + let a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..5895924f77ac34da273dddc663c354c351e09702 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let test = 1; +let a = new string[test]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7c81c1a7b918961c50237317741f0e7a7c67e25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class A { + constructor(p: number) {} +} +let instance = new A(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce473e7d6a721fe038c85c7ec3b0c27c6a0b5b42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +let test = a ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..60081f327afc6632ef642d1f163abdc09eedb8fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +let test: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4b0a509c6faea84593883375323b62b7ca5a039 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} +class A extends BaseClass { + constructor() { + super(); + } +} +let test = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..141d5a41392145dad58b8fb03bffcb01ccd3a228 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let test = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f886edd59e3318a1e6bd3e521a7fc53cd330950 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let test: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..97dcf80db683c31ad74bf7499e7d34795f88825b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let test = 5 < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c5775742bf0b36773e0a02d2024e523f7978509 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +function test() { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f470356909a7578e173afc3d6ce78aa3afb9309 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let test = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..410c8576b9e35e2593f44754983d032ce8ca57f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let test = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..821d44aa48003b445c1f218b0435d81f29973489 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let test = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..17032a6bef60b7ead75e52721492d6e75f8f0ef2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = "Alice"; +let test = `Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c1c734613fbc41eb8ba52b8f047514c05375c20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch (1) { + case 1: { + let res = 1; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9997d7ba8a4bbe5baf802302c5409dbb1fd2cbe1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + let s = this.name; + } +} +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..45b6883fbb821128b521d65c9e8fa5cf1c128ac6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..4492c2545047b54701b0b347babe292ce4278b0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + add(arg: T, callback: (result: T) => void): number { + return 0; + } +} +let a = new A(); +let test = a.add("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..93a94b148a915d2a54c856f983ffe1e1e2fa0257 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let test = 1; + return test; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c15295b3e5b85ea378fd2570f067a58fb6968dbd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +let test = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e90349ee94ba0b15076711044d610fdd3ab3a78 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd3567b6cf56a5ce18b0a0ae35bb366e995280bc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..71bc4c411570b0583da16a56e7d4a9cea2d14ae2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class GenericBox {} +new GenericBox() && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecad1f59a637f12eec35fb9f5aaded2762507678 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class GenericBox {} +new GenericBox() || true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1df6107efad7436027e0d457b2a6da26c63c3c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc0db5a9e02dc044cdc4428178db2a00ffab583d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class GenericBox {} +new GenericBox()!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..be43b0346717042f532fc669b018877fd233c8e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class GenericBox {} +new GenericBox() != 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..336f0cd50196ccd839fe7199be18da69ebb52f3d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0450951269fceda1e09da1c051b10a72a6947047 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +for (let arr of Array()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b28a20fccca82e5a8f55286647dd114a390bf22d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +new Person()?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0db744e2f15226d5116de53743f309c4c531547 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class GenericBox {} +new GenericBox() instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1bdb67415754ad31f148563a86b290ea990284af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: Array): Array => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..e74aaafe5db9c6e671977141ed4f0864f7d46097 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result = (this: A, a: Array): Array => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a9b09a3d42930d21de4eecf990e03d11e390e4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class GenericBox {} +while(new GenericBox()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f2d3e21f83586277b5830ef26384118b91fc448 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number) {} +} +new MyClass().sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce92efa952f97e7fc64cfd6c54453a05677d74c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: Array; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a55ccd7d0ad04e84e563fc546defd035c8f94397 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..02ce840f9696c000c9c041b5a88c2694bc053ad8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class GenericBox {} +new GenericBox() ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..55740f71e1357bb77da8d538ceb4e5cec3e526c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +let a: Person = { + name: "Alice", + age: 25, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..32ec5290b69810fe862920d6e382666a2897d796 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() {} +} +class A extends BaseClass { + constructor() { + super(); + } +} +new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd993a63afc0a81caa89f4025d8ac12849df117a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +class GenericBox { + private value: T; + constructor(value: T) { + this.value = value; + } +} +const intBox = new GenericBox(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bfcba09327a465cea9b400756ec5bb3279938f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let a: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..44f17fa49e49d42e0e1afca80be8f56a8de41880 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +class Person { + name: string; + age: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4fb483d71c723a07e1567722abbb36f6d973ba6b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class GenericBox {} +while(new GenericBox()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..832a7d326719ddca9a6b849916613d6ac93ac5a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class Person { + name: string; + age: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..cfa86b977f1599e911ae5c1cc5dfae77fdf0932e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a: Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc2db399e98e82a1c6340252c1e2799553006335 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + B(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +let a = new A(); +a.B("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cde097fc78f664c8ee3e8ab72a0dd969ba77c8b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a: Array; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d522ab1fabf06f8cbdcae8330696c9bc53b75da3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +typeof Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..565452feb584c71305f3fe5bbfa04e4fa32ca313 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4454925227c1b7e354a0abef466d438b61f0cae1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(Array().length < 3) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0d5dd5c51fafb56fbfd5b9a2457827d18e7eafe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8272658f2c92a69682185f07354b6b081b901baf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function createDictionary(key: K, value: V) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..148173f4ac03b02c1d5468c67b26722e870be28d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +class Person { + name: string = "name"; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..908c492e03fae7b60f05cd80ff95ff3babea737a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..853d58b5a0124ca4ae23055d177d7ea01c83d037 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age + instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..935b8c59c4af4a9fccb158e5cfdadf53e21dab20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.age = 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..de8edafe486dd3eabbb402b663503ab982bcc34b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + name: string = "Alice"; + age: Promise = Promise.resolve(25); +} +const instance = new A(); +const result = await instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2714e49a125a3baac244b68460a5ddb9a323bb9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age & 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf1bb1502c68facfc7ec2d76e35aedc67705d93b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +const result = instance.name as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0638792a11ee8fe3db22a86c7b430d1e2c6ba667 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dae79d8382c624aa6ddab4f89f6e652e7c7daa98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +(instance.age > 5) ? 6 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..73beafd98d4dd96c7c08bace49d59a2dad0707d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ed433b1b3ec25d27b625d1e2c9b8b62f5d68239 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bce04d5a660277cce6644d6ecb7e60a676225b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..95581351482b55829e810e97ef3bd0f059d76ad6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..537f3a3c7b265b2ce3379ae095cadcea403f4706 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c75736c4933b8b27fba9f0f61d5ddb7be78190a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +if (instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5460629b1782afd85fea28312f8e441cb4154c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bdc731df20d095799674a36df977a2fd69c79d53 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c3ecbe61cbd5ced0a5da0c0c9531ca5579ffdb6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a44f98fc82084d15aab4d3a84f16fa541ece4770 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age * instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..00f35a5412b16061ad01a067b9313bb6dc3a4841 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +null ?? instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6d7aaa1954e814fb5ec9af06e6488d4ab73181f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age < instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..22df5ef8ecd598c37c2b4a7af6d2fa6bfbea6c59 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +function add() { + return instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6cef955aad04532d6fc0f2f006e95708a81b85b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age << instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..703c12512f2ebacadeaa873d5fa33f212a4eaf2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..bee53d386a355aa66a6ddb37af2d36aaa45b17e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.name = `Hello, my name is ${a}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..859c3e5f6a940462eff32995ee3be19502cf3653 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + name: string = "Alice"; + age: int = 25; +} +const instance = new A(); +switch (instance.age) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..6406c117a129c00c53f61de6c1da13f21b93ed66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES 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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +export default const result = instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4a08821b52505363410bdb63ff154a152ee2970 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..34f55be209e991949c5b035d4dbce9cdc5db6980 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +typeof instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e226a6abb2b5907a7e5e3ef545a3a2f1d7660f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +!instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae81fe6bc2fcede0186f4141a11d6d6dd83c4c98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5084c4c7d31b3e40e638879191420def8e8d5d34 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") + instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..77405092c5bff5039ccb5b42664fe63e1455479b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +let a = 1; +instance.method([1, 2, 3], a += 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f8f97309c8a82688ae46de0a2bc2f1171c71f29 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + async method(arg1: number[], arg2: string): Promise { + return new Promise((resolve) => { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + resolve("Done"); + }); + } +} +const instance = new A(); +await instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d472dc674c1d5f8b4f100548958d2f6758ab0e6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +let a = 1; +const instance = new A(); +instance.method([1, 2, 3], a & 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8eeb866ee5cabab6e40d3dc7285d301e086f01aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +const result = instance.method([1, 2, 3], "Hello") as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbd152373ee3b81d5951dea65e3217bbcf3bc783 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], 1 && 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..19908ff6732179a08a221e612a381f3666b1b836 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], (6 > 5) ? 6 : 5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9c22f5830e443f31fd9b249eaefb76d688141ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], 1 || 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cb89a38009e67c1b9791494fb44c2f5775ec4c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +const result = instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e57b84d74e23a5cebc44ef4c014f107fc355b7fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello")!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..245011735c937cda41b0b29da657dd4677e3955d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..933704c1fdc3fe77b3abcc18a14ea7ae8e18ab4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.method([1, 2, 3], "Hello"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d937d82706885d43962822caa007f9c50edfd1bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +if (instance.method([1, 2, 3], "Hello")) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..685a6815a3626553df7713c0b7837b69a0ab4a14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello")?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ece1bfe5d2240595f5669efca97bdee8066be107 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2dd9fe5ef1403fe4d556008212dbf865b9e40e13 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7459ecd7d4e0d17fe741b3d8cdd15fc448de2299 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") * instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..15d8c4dbff201b54ac1558d59659b3672950bf8c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +null ?? instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8295ad3da5c8f8a4d52adb8dcc3e8197395c3331 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") < instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6353120fdb0a8fdb70f59e37efb320c83b4d2d39 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +function add() { + return instance.method([1, 2, 3], "Hello"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5170fefccd08c5b0bc08ba6851b30bd29628fb44 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") << instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a6c0353fc3ed1d55f56f2ef32caedb99c9e209a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..42f666b6ceec4436a3539d93e78a4b345ac731dc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +let a = 1; +const instance = new A(); +instance.method([1, 2, 3], `Hello, my name is ${a}.`); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b18a554a14abaccaf0e15b9ce3f6835d5bab0a31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + method(arg1: number[], arg2: string): int { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +switch (instance.method([1, 2, 3], "Hello")) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f4bf543c2aa64329b21143ecc8bfd8acdf7c9f6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES 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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +export default const result = instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..be7ba0f8998ac329f96d97f52c277a06f8a175ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + method(arg1: number[], arg2: string, callback: () => void): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + callback(); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") { + console.log("Inside trailing lambda"); +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..afaac8e4bf83458fd6e4a6249b74ace0d334f44c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +typeof instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6969605fab9d15f07f7c3f41b5b02b6482c8734 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES 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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +!instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..203104db22653b7cfa9ff68f221f5aaf5f384cc9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5d11109ba6e36a4cf809fb510a3052ffd29b8f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age + instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c09e1715dbc75dad43332729bf38a82800f72059 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7da6ed1ff089450f75ad98adbffcc0699ada865 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.age = 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..21ad2cd54114eb9922787d969affad53695b90a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + name: string = "Alice"; + age: Promise = Promise.resolve(25); +} +const instance = new A(); +const result = await instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dad5e99c74ab860706e0a9f48d86a3c857d02fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age & 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4b4c35844537b257fc9c77862c0684407700b154 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +const result = instance.name as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7207538d536bcf5d56599458edbff639a2cc5e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ddd096e42ae2244f9feba2ced15ec18f4d93e18 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +(instance.age > 5) ? 6 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b751169038d9c6a212de737b2569ec61dde13acb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f311d084cf523c810ec15ef44e9223615c0a79c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf2dad3614df64aea1ab9324bc6ab54da97936e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c106e48efe8779ae00ff758dbcfeb693ba9e02f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a5ebec3695705e4181325c87593c0713bbadc2b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let instance = new Person(); +instance.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec0a611c521cb5cab94ecce664740cd94952fe71 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..493723b1590fb5c71c151a0653946648c3fa3e97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +if (instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..191061fd3906e7db947a7f016475cb69ad9950db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..400187fe382be17cdba664e375c399eba40ed57b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf003b82b9db2e4724e9099b8dbc22f27ffe2961 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..82a9e898fa55cbc3fcd51b17dac708dfc87a9155 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age * instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6485031764e5afa2e0f7eb9060ccf46b762de192 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +null ?? instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0dc3cedfa6f36227f8fa41fe587b683113f69dc7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 1; +} +const instance = new A(); +instance.age = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..165a470e9f2a4d73f0f8918a129ef6dc81f5f78f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +class A { + name: string = "Alice"; + rec: Record = { + "John": 25, + "Mary": 21, + }; +} +const instance = new A(); +instance.rec = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f9da626675824e9485b9811b523142d668eef35 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age < instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d01b9cf4883874a7303bca7c0e322e1c79638a87 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +function add() { + return instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..785eb06e4b3379cdcd31322295c82c1af471d10f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age << instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..de7281858db553ba9186e4f82b52ff7fe23778e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3baecdbf1fd261ae174608441ac3781aac5ffe9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..abd85a5ae2c9fc857b02bd3bf03c8184f1f2f790 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.name = `Hello, my name is ${a}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..50437a19c431ea58541136abd12da45a372b90d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + name: string = "Alice"; + age: int = 25; +} +const instance = new A(); +switch (instance.age) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e99569196d10648a36bac2449effcb961b7cf0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES 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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +export default const result = instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4af564854d5c1ea3b116ca26ad198bda1f2e8d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbc220a354694aaa0e9fdcaf318a4f559b848b49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +typeof instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2565394bb998ef38eedb0bac9e2d4ee498971a1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES 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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +!instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae81fe6bc2fcede0186f4141a11d6d6dd83c4c98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) {}