diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..d805ee30e5af3ab5b58d152f5973a4e7de6c89ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.4 + * BigIntLiteral: + * '0n' + * | [1-9] ('_'? [0-9])* 'n' + * ; + */ + +let a = 153n; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..42f909954da776cd029c627b35938d5b408cce09 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.5 + * BooleanLiteral: + * 'true' | 'false' + * ; + */ + +let a = true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c23784557f0d6467e044eca146a099a9368d62c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.3 + * FloatLiteral: + * DecimalIntegerLiteral '.' FractionalPart? ExponentPart? FloatTypeSuffix? + * | '.'FractionalPart ExponentPart? FloatTypeSuffix? + * | DecimalIntegerLiteral ExponentPart FloatTypeSuffix? + * ; + */ + +let x = 1.1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..21b0f7c5017d3a4523d447aff2d97eddaaad67e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets new file mode 100644 index 0000000000000000000000000000000000000000..c862ea9992740085a40ef672f2a263b12284e829 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + */ + +let x = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..91842ae991fd42f014a239f4d3bdf14010603c67 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * '`' (BacktickCharacter)* '`' + * ; + */ + +let x = `This is a multi-line string literal.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c18eda745862f381aaa16bc543c5f301864b3ed6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + */ + +let x = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..d8059d2b1e7d8645b17555f9c0766e259f760e48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + */ + +let x = "Hello, ArkTS!"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3582dd853e61ce550370c3c83054c1438f5ee06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let x = undefined; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e7be79a83d090636fcaca1be98d1a20229e05dc3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +1 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..2566a36dfddba6be5f497e8e078bb9624c44c241 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + name: string; + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..85077870895d0df2c63b44353e7dc778930b2af3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..3f406c674adee8376338007b3db9fe1c6260c04f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let a = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets new file mode 100644 index 0000000000000000000000000000000000000000..42b6d38d0794a87c0e58283ae8bcb928bf3d275d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let a: number[] = [0, 0, 0, 0, 0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3cab3c1e38b3f961d6a3b98ad7baaa1b3166d509 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; +a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d17177b82c81a0db3289c50007305a64ec859f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function fetchData(): Promise { + return new Promise((resolve) => { + setTimeout(() => resolve(42), 100); + }); +} + +async function processData() { + const result = await fetchData(); + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3d33ca80538035b0dd653397535bf3207b2a57d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +1 & 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c28ba02d54a32b479b3565d9fca5fe4ace5e9b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let x1: X = new X(); +let a: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..11db111655f9c3f40852ea4d50b701f2fa39af38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = false; + static initializerBlock() { + if (!A.initialized) { + A.initialized = true; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..103fb960d366cbcc1570539aad31abb7264fe721 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = true; +a && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c80db93462374310c6db648040b0c784b43e23e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 5; +(a > 5) ? a : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7df774b501d46203deec4c53f00f09dbc98a2668 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x = true; +x || false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..1be6bdc4384a4ecb7aa75ee40fc21ad4f2c5464c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const x: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc952ef9f9f58a2a2a073dee5ccf240d32b5b69b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 5; +const x = a + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..06cc0d3c9b36c7fe8f3596b1897eb26e95a37d7b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let x: string | null = "Hello"; +x!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f4af9e9b01b593600ea2a1325087f5d60b73bad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum Color { Red = 0, Green = 1, Blue = 2 } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a779ae16c50cfbf77d6a607255825b01cbb9be9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let x = 5; +x == 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..688497c9efa01b3b71c9eb9790c3a2f0cf92eb70 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +export let version = "1.0.0"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..5703f8df2ca8aaa10a9c47f115ca0edbc2595d62 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} +export type MyA = A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..605199d3ddf6f48df6a275b6e4a1b89226b833c8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +let x = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f64a6a29b0aeb8e0766e4d03a2efcf854d29db9a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let x = new Person(); +x.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..4077a6935c62c8ca391b3cfd4d85a494aaefd10f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..56da9cbc237971f5e000cc95d5abe27dfa63651a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let x of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c32a904cecaffd90691b0d7046dabeed249bb9c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = 1; x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f216daac50a17dfbbbd9d220443486a7030cd4c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let x: Person | null = null; +x?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..6c2565834ca8e48f767718843ba4a3154ceb38ea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.19 + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + */ + +let x: (x: number, y: number) => number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bd2a1af3a6d4c082c8d7aa0d2be92999a5a440c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class x {} +type FA = (this: x) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f503c965849de209c40ed3d7fa4995ff8d00a43 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..af0049acdf03f60c97f3dc98dedbd1aa219304c7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './expressionList_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b5ac3390f0eb9ee2a7dbd303fe5c7d09f9ec0f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const x: number[] | null = null; +x?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..072873de7afd7167d09fd4c7101f8c84c4118996 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let x = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..21a02d5655c4536936da8a9d9cb9b2511073abb7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let x: string = new String("Hello"); +x instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..41dd8e00dd6c64013d06aafe657dc58ad4df319c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(x: number): number => { return Math.sin(x) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..dae05e414f147c89c7a453ff0bc81be2078ff6d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class x {} +let result1 = (this: x) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9be6b692cbe9147ebe62da59a97e5d6754e8abf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let x = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..55644781c721def6737671a569b474b72189517e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number) {} +} + +let x = new MyClass(); +x.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..35bc2e26eb75af63dc6d76d12080ddb22c94bbe2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x = 5; +x * 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..041b42a5f4d86ca4cd8abb5abe18495181b1cd9d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace x { + let a: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..dab7744817420681295ee7084f5e5de49ac91d51 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let x = 1; +let a = new string[x]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd5464bb7ce081584494ae15ef1f0d6941b4b065 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class x { + constructor(p: number) {} +} + +let instance = new x(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..63036772914942f169774d58af0aed19817e6007 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let x: string | null = "Hello"; +x ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3910155d0f6eec15a35884b69958edd39b9c6eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} + +let x: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..da5cf8dbb9b058f22996b31a983ce5d50a8fe855 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class x extends BaseClass { + constructor() { + super(); + } +} + +let instance = new x(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe1cf1cd5aa5c9d9005bcbd9a3ed39706f146e97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier'?' ':' type + * ; + */ + +function x(x: number, y: number = 7) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets new file mode 100644 index 0000000000000000000000000000000000000000..1df668b494a9a564e2bf4e29bd1647f210484c77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function x(name: string = ""): string { + return "name"; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca3463ce8a3dd10ae5729311b5b53a992bb7c67e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let x = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..8509190b2e4e5df07c894a8c56bc6d987d76bb21 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9.4 + * reExportDirective: + * 'export' ('*' | selectiveBindings) 'from' importPath + * ; + */ + +export { version } from "./expressionList_exportDirective"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..562184b3096d11696c1e77d10f9d98e978a68137 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let x: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a7277cdf51b77bcf16aff47b44563814f54c16f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x = 5; +x < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e04313492cf8bed98d48775aee5a16e25213258e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return number1 + x; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7d6b0cc646afd4b78d037259bdfc4741d8910ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..94df4fc49a9c40b1e3a2b665c11bcd27049376a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let x = 5; +x << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3ae48a0d9401b2189eac4449c8eb441364a18b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +function test(x: number, y: number = 1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc4ba52ddf853ddac2fda4ac0568470282afb082 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let x = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..77fdf3197e29862b5ad5109bd1f264364bf9ad83 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a983d53d998d50c01d7d0727d868320dc78c2f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let x = "Alice"; +`Hello, my name is ${x}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d552ea8e617fb64736b56395c4dac56e6cc84ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 0; +switch (x) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa7e98200abbf274cafa1614b51671439f4cda67 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class x { + name: string; + constructor(name: string) { + this.name = "name"; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..273b49f45a7fdf3ece26f7c7fdc7f7096aa09969 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let x = new Error("err"); +throw x; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..04f62eb660d3d0efcaab0f6c55f27d64723f5c1c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..b56c7096161080217522bfd6b3fba510fb770805 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type x = number | string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bc17e50b6822fbd671ba69507518bfb608fd965 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.x("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..88e5ebd9c2b3160f4418c77c503bf295c9e71cc5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = 1; + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa3304112595ea4838e219ae15e7e2f99e191873 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let x: [number, number, string, boolean, Object] = [6, 7, "abc", true, 666]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets new file mode 100644 index 0000000000000000000000000000000000000000..871680d0a4437e225b9ceac32d4782c173e9fa7c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters? '=' type + * ; + */ + +type x = string | number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..57ecd2db39974c10235473792ea51189c3a1be36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +let a = new Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f359063221f4a3910fcd36cc7be170bd1d78272c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let x: number = 1; +typeof x; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fa8548e2caa772265c026f73b299150bda744ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let x = 5; +x++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..d49757b2fb45ac3d78dc7bd76a05816cbeeef237 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +type x = int | double; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..5233838874472da8cb052218d72f737292e7b2d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let x: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5fc8c538ff819dfa560c2bd49a4de1ee4067f531 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_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 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let x = 5; +let n = 3; +while(x < n) { + x--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fcb2d7f1890f159595013a5d2494d0e012ad3922 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let x1 = 1.0; +x1 as number + x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..e517eae869bf32e2e8938a80445c51bf06316eff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface X { + name: string; + value: number = 10 as number; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..06852d947a7013f9684c15acdfded4c7e897a2de --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_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 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let x1 = 1.0; +x1 += x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b5934cd726561b06b30aeb37153236eae588769 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_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.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function testAwait() { + let x1 = 1.0; + let promise = Promise.resolve(x1); + let result = await promise as Promise; + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..87e27e2c6ead5d9339cd24194fbced87e3d1c7b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let x1 = 1.0; +x1 as number & x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..4244f87fd2ec7aacc8743ef68a0733daea44a05f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = 1.0 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..955a131a5e866a41195c0f57bc52234546633858 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_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 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let x1 = 1.0; +x1 as number && x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..114f0daf3ac9c3130a6c13c20e14fe6c90698e6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let x1 = 1.0; +(6 > 5) ? x1 as number : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9859391327e1711d85e7211052bb731e312ea41e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x1 = 1.0; +x1 as number || x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..849cc16b70148db03650f63d39cfe8d25ef7433a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const a = 5 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..98033086013a11640580bdbe57fde446be9ea01a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let nullable: number | null = 5; +let nonNull = nullable!; +let castedNonNull = (nullable as number)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3604d45f1990ec1bc48a65896b7a3900a5a44a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 5; +a != 10 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d43d3245b80ba6ed48a6c86bc407b7d14c5be25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..d23d3f0d826c5165fdbf5e3f5852e2749fb7a1b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} +export type { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c7f77362f893c461d8f29e5c123993c1dd64b62 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e64dc83fdd7d0b3d620672a988f5d5de5b3c3ba2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr as Array) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..59e472a72bde779715af187bf53c48bb831b39ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1 as number; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b61744de577956ac575dde50569d24a40cd4f30c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1.0; +if (a as number) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..ef7194bc980abd2540318f02b14ee746076972b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './castExpression_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..95a1d82af6f55fcda30e28902ed7e53344ea1347 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0 as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..85156a164435ddc15fe2ecf2e6cbdfa76c3ecf88 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.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.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Base {} + +class Derived extends Base {} + +let obj = new Derived(); +let baseObj = obj as Base; +let isBase = baseObj instanceof Base; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bb6ca40cd72a2ba8b27b887c90c1da3ae021a96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: number): number => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac59a52ead169d7c5689c61331a6b3f11e19739c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b896162d521d7e51e076ae1f51173b24230a6ad5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..00fed51a9cb3c5a667769e8f9607bc6e8ea3111f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x1 = 1.0; +x1 as number * x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc9717ec60175a7faab2a24c596d0678e3c7b2f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a = 10 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..580bfad89caa302808f30b426386c93f3576e5ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +new number[2][2] as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4f7120ee75da2ad418a892d112e0e4b7a73a8e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +a ?? "0" as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0234c5827940a0aa04eedcc9fefce4fa7989666d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x1 = 1.0; +x1 as number <= x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2f7e684f25fc7698eb03b7dd4de747338ac52599 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +let a = 1; +function add(number1: number, number2: number) { + return a as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d12c9219ce818450c423578a471eac7eebf9cd6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9.1 + * selectiveExportDirective: + * 'export' selectiveBindings + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fd7cbf3853ecb0a8ef7a52745622f41102839b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..168e24ca40f867d94bf53f435eb2458f6a876c0a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 5; +(a as number) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8e2e31c5cfc6e17509308a424d6ba5b852583c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..258af8bf5e0792c6a8fd27b94a8f8ca7c417a1de --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a = "Alice"; +`Hello, my name is ${a}.` as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc62722f0f4d3ac770d747d687a26a186ba1edfb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a as int) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4361e25418043c3e3b1993e1ac3b5a10754aade4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let a = new Error(); +throw a as Error; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..9391d524be37a01df9839f3d4dfcbcaced03dcb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const a = 3 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e8a226cb3fa9cd1979b8c72ef1e1b5ed548eb23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..04776fcf63bcbce0b4742d97cf4122e32094a9cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test("Hi" as string) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9fb0919cc2733719c70716096fc347e2eed4ac3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = 1 as number; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd856d764c480100efa6a0a15a6747676cd4dd02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let a = 1.0; +typeof (a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e41ad018f5213b45cb7c08f0e440f16966b34134 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_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 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +!(a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2975246cb4276ac2f7c880ef955e788e75db2aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let n = 3; +while((1 as number) < n) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6608202a4fe48b3f6991a5aebd449f4c679298ad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let x1 = 1.0; +x1 as number + x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..73f6ed1696660cece94d00eab18e4d4ffc4748ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface X { + name: string; + value: number = 10 as number; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..789501b7faa3e2153839636ae1f497068ba7efc0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..95824e534763c7b75b52e4eabde4e7070dc377eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let arr1 = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..809ad5bd66815e5a498fc445e1b601b4cfa36f8f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let x1 = 1.0; +x1 += x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..55bc5cbd83a3630aaac2ac55099f04535629c014 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function testAwait() { + let x1 = 1.0; + let promise = Promise.resolve(x1); + let result = await promise as Promise; + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0745a723616f5a25ed9348407f3626fc96016ea6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let x1 = 1.0; +x1 as number & x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f537e701ac75e7097401653a5470005c576c4db1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let x1: X = new X(); +let a: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..646942d0a227ee398de0edd8d35fb4ffc9bdc1b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = 1.0 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..65f39451f1257471752381a45a6e061c22f7eeab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let x1 = 1.0; +x1 as number && x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ab20808072ae8bacc51b4cc94d00e2e05933e5c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let x1 = 1.0; +(6 > 5) ? x1 as number : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b04107b8c48bdb2e31deeb6f26b54f16592f69ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x1 = 1.0; +x1 as number || x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6b94e2b96b1afac79df01d8c792ed68204a96b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const a = 5 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..05e5ba36063f8ffd360d822da58d61c5b7ca4a94 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let nullable: number | null = 5; +let nonNull = nullable!; +let castedNonNull = (nullable as number)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ffa1c2161d94384b37e3cdffd3506f774ee2249 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 5; +a != 10 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1457225218378ea5eb8cdb29d8d5b3610c6cf88 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ed01d7cef4ac9bad9bfe1d11311478abdba68cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} + +export type { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..03f90c10321370ef7d7232a3ff31767d79f41afa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} + +let a = new Person(); +a.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..9fe182ba61bd6738f818e590e5aca0d123856f85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d62c3eebc862b1267c4d96442e70ebf42aa7291d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr as Array) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..968243fb66739f164f94ab3b71cb174e17452c34 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1 as number; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..205a652781af126f32e9256b1127d3a2b19735a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} + +let p: Person | null = null; +let a = p?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..60d1dfb511622f37213252b58aa194ec0126edcf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} + +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b164b397ac39437f102d70dbb314c4c2a3f92c63 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1.0; +if (a as number) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..036e7ad4706cdd70f55674d373141e50c0ee34fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './expression_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a26fdf98d7b9d2972e1a0fea6a01a6e744b99366 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const a: number[] | null = null; +let value = a?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf735de084292c3800c7034ed53d56229611e91b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0 as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..849992d0c8948d332fc3dc9e504ae5f1320d046e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Base {} + +class Derived extends Base {} + +let obj = new Derived(); +let baseObj = obj as Base; +let isBase = baseObj instanceof Base; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f7eed87e9323cbb31387ef9d6c38fbdda452f00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: number): number => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..05298b40f15313196b9e1976d7f6a8be7c2c720e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result = (this: A) => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..357befacaf439e0365aedac0eec8ea6db73fb134 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb739971757eb8c47a314820b36572e0ad01cb58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): number { + return 0; + } +} + +let a = new MyClass(); +let value = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..060b9aca98db95f4e7b05439b45ab076a26ee5c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x1 = 1.0; +x1 as number * x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfb07aa09fc5847b59336e9fc1a22b3ee3404d7c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a = 10 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..d18c99a9193f5f3dc66658cd1c39e91710f10eb0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +new number[2][2] as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b3a515d1bf048764bc91076385e7f9d72e1b0a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * 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/7_expressions/expression/expression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d113daf8a4f7dd0a5452457f8f46bdc965e51f8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +a ?? "0" as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f0c936d43d33e62c9050620323a6d358f9eaad2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} + +let a: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..62f8637bf25d42d7f88d3117ae6bfe00954fb8d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class A extends BaseClass { + constructor() { + super(); + } +} + +let instance = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a146a6bb4283c344adecfc4ee1f36377a9bf8dc5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let a = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce8866e75a7899a297502a7fb56815b34ae99608 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let a: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..15a9e9b895afa30cf33a3b1368ad25ad0446c814 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x1 = 1.0; +x1 as number <= x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c17add520989287f753796da160acb4d82354dcd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +let a = 1; +function add(number1: number, number2: number) { + return a as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab47925bdda483092b41131e81cdbb85af85254c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9.1 + * selectiveExportDirective: + * 'export' selectiveBindings + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cb8111028bd4ed14616b01f526af8156bf5d04b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb446b3636ba2a207fbe99553b17e658457fd608 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 5; +(a as number) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..80992f14d2404e001c51831e0a3353e85fc05ff0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let a = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..65c5174614d2b4476ad1830a72bbde1895925b98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3f23e807b7588e717f56efaa5bd50907e481aad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a = "Alice"; +`Hello, my name is ${a}.` as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c19f4faa016980c03274834ae177d4d28b02e85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a as int) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1d8d6e3841dd1e0175f424384a5222da2d0c65a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + } +} + +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..dce43d2f0766b41c8864998560014129c0be59d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let a = new Error(); +throw a as Error; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..724c6dea1bb19468e70b5325397150519490f272 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const a = 3 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..a16d0805f9b9e18410272416ee8967c8baf20b07 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..b61c79076a9ca67142ed26a6d2592228011643b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test("Hi" as string) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..42c211cd9a88cd8acd795ba8fa5f2d5985c3a3d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = 1 as number; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..884f9752be93dbe14ba4efab516d2657b6c52d3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let a = 1.0; +typeof (a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bd4cf8f8b2193699e13546261b0b500a8b3858ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +!(a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8d19648a1f1fa1130656ba353a72ae736603e25b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.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 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let n = 3; +while((1 as number) < n) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d1057616f71485d920d8f9f6b12a12f733a036d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +let secondNumber = numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b094ee3483bcf73ea8ef016ffb10e4a9627ef31a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] += numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..aacb2824c70a87bbffabda0796943a51091a4e5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +await Promise.resolve(numbers[1 + 1]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..47b8041fa76429e3101f10c1f93cc48b1c3790d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] & numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4651aada9be9d1f6361e40ed1921ae77f4d8b86 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..e510323ad6f1802b8a46dab1905e11136d99ff74 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static numbers = [10, 20, 30, 40, 50]; + static initialized = A.numbers[1 + 1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..66434ab7628f5e0bc51d5e3b853cce8bd9941d15 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] && numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..19d3e6a0895326743db25a5b0d657deb275c94b4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] ? numbers[1 + 1] : numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c69ef619133e327f677cd99ecdeacdcc4eab4b1c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] || numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0d981c5301e8d789f98c1d0cfab1e0f17dde262 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +const value = numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..be448f431a7c6f87cc7cc39f51a997983dad3caf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1]!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e021612ecbff3295382353b009f4b515d284256 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] == 30; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..c381e56536e4971e0e8efd9c50fc5ae65b67a146 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +try { +} catch (error) { +} finally { + numbers[1 + 1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7820392dc50059c6ee018af78c3a420a9eb76ee4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let nestedNumbers = [[1, 2], [3, 4], [5, 6]]; +for (let subArray of nestedNumbers[1]) { // nestedNumbers[1]是[3, 4] + console.log(subArray); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..28a6d8b52709d0aa31137d2463770c4aef4bf95c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +for (let value = numbers[1 + 1]; value < 60; value++) { + console.log(value); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba288e5ca8f806e8d88fa30a605abd858e457949 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +if (numbers[1 + 1] == 30) { + console.log("The value is 30"); +} else { + console.log("The value is not 30"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..20156596bead6121fee9ddf452dfe5208779335f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let numbers = [10, 20, 30, 40, 50]; + numbers[1 + 1] == 30; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba24d374903fe99258c41a666c6f02eaa09226b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let numbers = ["name", "age"]; +numbers[1 + 0] instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec594c32d2218addac9ca4d0752e2521094d5ca4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(test: number): number => { + let numbers = [0, 1]; + return numbers[1 + 0]; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..5937e8feb29bd1bbc4950349687a10ef10d82ff6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let numbers = [0, 1]; + return numbers[1 + 0]; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ece07eec81a2578393d673906b287695c6d4940 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let numbers = [0, 1]; + let value = numbers[1 + 0]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a63d6da853defc2ad4f07536b6811f9cc491fed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let numbers = [0, 1]; +let value = numbers[1 + 0] * numbers[1 + 0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..92ff9a23c2a31902164598fa1906ed23cfc0d585 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let numbers = [10, 20, 30, 40, 50]; + let value = numbers[1 + 1] * numbers[0]; + console.log(value); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..d97d0c25d9231cc4f48d71e6cfe0b2c555c011dd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let value = 1; +let a = new string[value + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..118553c6713ee0764bfe62d609f2c5799e456977 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let test: string | null = "Hello"; +let numbers = [10, 20, 30, 40, 50]; +test ?? numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0947dea0b30877b0af6f31f4461df6e21625680e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1] < numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e263f8b91e443dac16895f129f1cec8f42f8f72f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add() { + let numbers = [10, 20, 30, 40, 50]; + return numbers[0] + numbers[1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..348830b6d98e51a75e4b456b96d4eeca793a0fe7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = new string[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..08a7da8b7600dbd56e30a9f8e56bffb9c61156a1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1] << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..25657035fda27079070c7a59f0b2da3ab0f22521 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let numbers = [0, 1]; + let value = numbers[1 + 0]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..c559763b9df4228c07e3ecce9319f502dfb0f92a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let numbers = ["0", "1"]; +numbers[1] = `Hello, my name is ${numbers[1]}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5bb780cd2c8f50f28e0297c4b1a658cf6ce9546d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.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.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a) { + case 0: + let numbers = [0, 1]; + let value = numbers[1 + 0]; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b957c5fac58b0f0aae9add2b26cac244c2e59a28 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let numbers = [0, 1]; +let test = new Error("An error occurred" + numbers[1 + 0]); +throw test; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf7c692b80ec629e85d9c61860920b1f705ec49b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let a = new string[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..3233ef61be072b7bc443143d612ae09980a73db4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.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.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +let numbers = [0, 1]; +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test(numbers[1 + 0]) { + (result: number) => { + console.log(result); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..adb04b9b4681835c64eed5e758374fd3eb4aa0f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let numbers = [0, 1]; + return numbers[1]; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c973f32c5d4cbd1012ad42dd0526830c598f465 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let numbers = [0, 1]; +typeof numbers[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ffb65b360580ec7b79f3b11afc4e193e78f19457 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_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 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let numbers = [0, 1]; +++numbers[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2d4ab6818ac94f3278c3a00317e2b71e2a19396f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let numbers = [0, 1]; +let n = 3; +while(numbers[1] < n) { + numbers[1]--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..848e7a596a622aa9e2c6af55faeec29cc6d99dda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..94851a38ac7c752c485c0e4849799000389b3fe8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a67597bdbecb767bfa9481ef8034c3341c4b267 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +async function test() { + const a = await new Promise((resolve) => resolve(new A(5 + 6))); + return a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb2b9b9c778555065875050ccb14f48e5098e00f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let test: Object = new X() as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9b572352ae941c4bb4372f78a1b21e3ae66d33b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3aea4b64e9c11de1a2221cc7b8b3f43e43d47fe3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A {} + +new A && new A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff1f3af1a9b3cea413459e8321d1687fea7439f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A {} + +(6 > 5) ? new A : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e21c1359f0c6714315a7a7d100f5349cc82f2623 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A {} + +new A || new A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..76eb41293f917d7cb898b040d51db39547b55ebc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..078645088282fd565d34a5a1ac4ed005a23397fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + constructor(p: number) {} +} + +new A(5 + 6)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..75bdfaa25153eab3faa5bca1f785cbf82baf5dad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + constructor(p: number) {} +} + +let b = 1; +b != new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..139e7056ed0b89b1fc2a1bebd6ded5a4d1ddab4d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A { + constructor(p: number) {} +} + +try { +} catch (error) { +} finally { + let a = new A(5 + 6); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b6ce073e7cca713ac659161ab6e3e63ea4764ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +if (new A()) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..72bc69c87806e50a1e1f28c1c8cd2126360a6917 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = new Test(); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a099f35665bf5f76bc618315c1e873cc3aced1f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A {} +new A() instanceof Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..89576e44ba994e98dce6b039ab1d3592f0853231 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +class A {} +(a: number): number => { const b = new A() }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..eaa8c206a8ac15284c3afc7126863e7dcb43982b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { const c = new A(); }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4d8dd2004ea0d8730b2848d9af8cb86e0fcca72 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +while(true) { + const c = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..77770d277cab13486545a7b27de4f9e8d8b97e25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 * 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..69f5df07d2f140c80858fbe5397e58ee21038690 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +class A {} + +namespace X { + let a = new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3fa2d87ec8ce59c07011cbbaa5bde3bdefffee3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A {} + +let a: string | null = "Hello"; +a ?? new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8e61cb4ac51cc54692417e310f4d0e11b0bae4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A {} + +function add(number: number, number1: number) { + return new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7b1d6acbd782fe9f65e0cdfb11002dea5d9cdf1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A {} + +while(true) { + const c = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..d829bbe1585e98b2e67844908b21ecc0976b34d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.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.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + constructor(p: string) {} +} + +const a = new A(`Hello, my name is tom`); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7be2ddf008048fa2febb2e58d47391ee71cda58c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A {} + +switch (1) { + case 1: + let a = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..6bf2a6af64e907545fb3ae861440f4ac0485e6b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +new Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f02cba79f6d9b219f1b89e6146a3e6c5f35d605 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type a = Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..1113725c3107a52efc7010533585877c2178b667 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +new A().test("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..94f6a56cee6a26c2aabe0eaa205a02299908dc82 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = new Array(); + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..db9321e9cade7ea3cfad2f30dad9e8f5d7026278 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +typeof new Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..109526ac9ef70fe3c6b62c5cbc2508daa6bac4e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_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 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!new Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..af19b6ac661581c36bd52b4d4fa1ecd4b726d954 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(1 < 2) { + const a = new Array; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6015b44cb020df9689bff1bf411b5f72cf092676 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value + n; + } + + increment(): void { + this.value = this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9de5e96b4b0c108c1fe32f84abbdba36fbfaa724 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value += this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..eadc19f405bd78748566dfed239f234bc6106d2f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class Counter { + value: number = 5; + + async increment(): Promise { + this.value += 1; + } + + async getDelayedValue(): Promise { + await this.increment(); + return this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a89f62c26e18844c1fae5198a8cb60afd6f8f4fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value & n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce301f6ffb70106fbde6d9e4475ba2de12c80360 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + + +class Counter { + value: number = 5; + + increment(): void { + this.value = this.value as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bcbd8a9c12d1cd8a615077583eea024a41a3701 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value && this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2e513656608ef8a775567ddee494a731740c5bf5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return (2 > 1) ? this.value : this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f088e2f05f8963ac7b1ad7631bc680ddd930af5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value || this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..576098572a7a07166f35e45a68b3ae6dc6d9ec2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + const a = this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d58bb0a779bc3a13e6b7e284ac3a321274ba31b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value!; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f536a6bd72954fe7ee6617b88168539d74d7901 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value != 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..10739c1ffda7034c09555ef8a4fb8bf4a212ac25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + let a = new Counter(); + a.value = this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..58763e0c8754c7a5f2b979aedc789b93550df08a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let a = 1; +class Counter { + value: number = 1; + arr = [1, 2, 3]; + increment(): void { + for (let a of this.arr) { + this.value++; + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c5f20dae48f691ee8e19f166bf9e3a0c6b1e071 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + for (let i = 0; i < 5; i++) { + this.value = this.value + 1; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..63575e88a55ac34395eee49865ecdbcdf74a6ede --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} + +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd7034399d38ce8f7a777cd871a01c7edbd4ce31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + if (this.value < 6) { + console.log("Value is less than 6"); + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..302a164efc1f4f1d54e620b9c8138301cce14d4e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + let arr: number[] = [1, 2]; + this.value = arr[0]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..00675d2fb8ebc53ff4c57424dd91760b1b195389 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Counter { + value: string = "name"; + + add(n: number): boolean { + return this.value instanceof string; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b508640542b74dc81f8997a470f2cb0d1be0b551 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +class A {} + +(this: A): number => { return 0 }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d9ae5d40f17fd83b9ba981b33a0f2e50c339d04 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..644be14a4862e228dad913d5bacf66900f0bf4cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + while (this.value < 10) { + this.value = this.value + 1; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..71a23ce8565c70c25ccf3aa4fdb0a5fa27efff3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value = this.value * this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c4b0d3f626186faaf02141d274873ee20ed0aa76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ce824a18f3f012ea60442d9e3bcd742c28d6f48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value >= this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..982397a5d927bb8c88cf5f13a05e2139b72fa80a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..01513763b9b0f078625a25debd7788ca9950d78d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..31cf2559d3b26e1abf4388d259f2bd1d62f73ebd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9120bc66b2c243156b3fc1915de6b1fe91a6b75d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class Counter { + value: string = "name"; + + increment(): void { + this.value = `Hello, my name is tom.`; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..04dbd155480887ecf9420bbe1d563ec688220564 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + switch (1) { + case 1: + this.value++; + break; + default: + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c15fa2b7d88255068a93b067bcfef54cef3c590b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +class Counter { + value: string = "name"; + + increment(): void { + let a = new Error("err" + this.value); + throw a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..698394799b6cb9d931b812b8578138aaef6c3b4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + try { + this.value++; + } catch (error) { + console.error("An error occurred during increment:", error); + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4b41fb825e6a2296ffd80d650f0ae2f7f341cd4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + typeof this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..28ead0e4b8cac0b5e80684e1dd7f2a2eee7c28b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + switch (1) { + case 1: + this.value++; + break; + default: + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf4cd4704661504b476b99335ca41065e103fe4b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.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.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class Counter { + value: number = 1; + + increment(): void { + while(this.value) { + console.log(this.value); + } + } +}