diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e9c5231c167b2c2f34a8f80f7277101370ca8a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e2025495385382a203ceed33130da23ae2b6a93f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 + 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b86a4e04f949380250eac27600bf4e9b441685b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = (1 + 2) & 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..e5f5032cc27c52f75cd7427b5dcfda1a426fd774 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 + 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9f8ddd6a4821da40fef9eab4b46127c333925eae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9059ac5e4158a8611e9d546be694f82bd142b701 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3d40cd8b7cdedd5f275be6e253007b575eb7077 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..51538a06d3a983b0379f8b2014ab8af5d45fdc02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 3 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..4a1de90063c71d709ec6008472375c5945f40f14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = a + 2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..42a9aee1cc999e8aeed4592fd76f0691c6526c3d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = a + 3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fabff01edb8f6781a47a6de1252ebc56731e9fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = a + 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f4b24a9005ead8b6b6c3e6c8417b7541d0f1f401 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = a + 3; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3f2a9c96154a4227892db79e740c6d5f546992a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5 + 2; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0601572e59a1f86cd9ab68ba27403e9c7a2bc8c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let a = 1; + a = a + 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fb51941cdfc40aa41aeec8adfaf3655766ddfaa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1085af40fba8a8c4a5a591031a0c9f1779266ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..aea2b3e367472281e36ce29e1ee7a9abc7ce56f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = a + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..921aac3f2363e162565b1e562238194d4773b1ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a + 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..300d98ed6ae51e1d2d782045925754546eb97535 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0b75057332679301954e5470da4bca4a8a491ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..322fd709be5d69167e29bf5bc7a30f2b1765be26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd079b18fb60de664f150aeade382a9183ac4b7d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a + 2) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5c9dec1558025af863969a1886a29d2c7de5562 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 2 + 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..36cb5e5f16bb61b92b401edd1fc87021879f12f3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a + 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad3ca6f6a790c36f153fe5f0fa3c28a9b4bac354 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = 3 + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..84406977a2b42a81e9668ed8b135fb7c72b0669c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1889463ca2612c8c5d6dc145ca53125cfb4b1b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a + 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..66be2823f25e582c9e672ecf4866f57372e33f90 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_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.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 3 + 2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ee5873f1305bc0f8486f351ae71baac591b5196 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = 3 + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..04d38981043a2f04035838631b3401dbbd53134b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +let result1 = a! + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a27e38f71383ac5cd2a41bfc4a7851ec2708421 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a: number | null = 10; + +let result1 = a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d301a74608fad4100438c3e82efc7ec19bfe9e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9932e7ca6e242b494b653ab3dd9b5731017d2dc0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a: number | null = 5; +let c: number = 7; + +let result1 = a! & c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..09c58ac75cc9a2026756d1f753ff9e042672daa6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x! + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..de45290849088a078c0f76d75a276402a704ddb4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > 0 && c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a7184a6c3e41cd3efb8e7027b45dd27a7c5f05f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number | null = 5; + +let result1 = a! > 0 ? a : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..475c0c6b8e4fadc0d459d427f12331fbffd4533e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > 0 || c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d95f0a6950673c1328137b1a0c5212a97b375d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +const result1 = a! + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d908508165c9b44891ac60b885c01ef192e72195 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 10; +let c: number = 30; + +let result1 = a! == c!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a26d71eefc7d9f8028031057f169ead8fcadacd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let a: number = 10; + let c: number = 30; + let result1 = a! == c!; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a336e56bfd5afaffe6d8a2da301016bae992042d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr!) { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4449997c33220952bb1806b79f405efd9c220cbf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +for (; i! < 10; i++) { + if (true) { + let func1: () => void; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7dccd5febbcd44b16c7fe1e5f1e3ec74ef1a28ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..bed2329059a60d5a7cb4e7cae883985ded531eb4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let obj = new A(); + obj! instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..64125adcafccf877208a9318d7dc2a68957bf7a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + const x = a!; + const y = b!; + return x + y; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..b81575e60e8138b04718ab5ff4de15c69c1b13e1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + const x = a!; + const y = b!; + return x + y; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7055bb3af100ac8c38f28cf80bd5a34515749a5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc53dd566232487590b0013357a0ed74f46fcacb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +let result1 = a! * c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9cca2014f1defe9ca42da9a18f341ce54612572 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number | null = 10; + let c: number = 30; + + let result1 = a! * c; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..15e3c1afa608036e62a779aa87a167b3485e157e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; +a! instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..10e8d7a928c04084005945ff509dcf12fb4ed43b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! ?? c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..88b604dfc3abe27865f281c938e7891ede233ecf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f91e6d887e7f144b6e1d8818686f91aebe0cb7da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x! + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cd4b78b272a867179cf10da000260aa51a8a4e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a: number | null = 8; +let c: number = 1; + +let result1 = a! << c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d51b91c13f2e544f1cecb694ddfe737aab57fb0f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a: number | null = 8; +let c: number = 1; + +let result1 = a! << c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7104e37bf462cb512f45bbe7c8eec89f1d3b744 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name!, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..107982c24d5078bf7423b75579e9d3f4ceadeb6c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..d0d4d02359c7dd09ca6ca8e702e7412dfa9fbd04 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +typeof a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..191e71f0a4059f543e8855e70f882d21ee02a940 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo2(x: T, y: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); + +a!.methodTwo2("Hi", "HELLO", (result) => { + console.log(result); +}); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0672f968e28e174aba04fb746abcc83a9517111f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = true; + typeof a!; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8e42f3ef6a16b152c960cb36dd1cda8a3dfac80 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a: number | null = 1; +a!++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf8d34f1816b72e4e46b7fd2134fc0757040935b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_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.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..19e2bdb08f267d2618a783e4faf8ce74dec57232 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +class A {} + +function processTwo(a: number): number { + try { + let obj = new A(); + obj instanceof A; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..762ecff14aba10a71fece0667a28387727a0566d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) | (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..83c88b7449619e78b33dd2103ad6ad89c5bfe28a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number): number { + return x + 1; + } +} + +let instance1 = new ExampleClass2(); +instance1 instanceof ExampleClass2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb991699e50b43315a8bc4f19adcf85580e1936d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) && (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9af5a4f8e82de7a79e3e27abca2ab72b6ff8168 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) ? true : false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..606065a03cc1008ffcda510e51c2c4fba9b9e9af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) || (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..72859d8ea91d636b3719b77695bb5bda163868af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A {} + +let obj = new A(); +obj instanceof A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1e3a14ec8b4f3f62f11cca82502441f9fb03b73 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A {} + +let obj = new A(); +obj! instanceof A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe46b66ea4a5dbcdca62fd82db227bc70b8aaa8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) == (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..a68eb166130c95723cb6005a4297c7a4cf6b7dd1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A {} + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let obj = new A(); + obj instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..efa0186d7f2c5ac55f3df7f4e11c0cc3b92959a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A {} + +let obj = new A(); +for (let a = 1; obj instanceof A; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d39173ba3bc5cb8c1a9fdcafa28ddccb962e201c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj instanceof A) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..4537eb3d8b3b10a55827d232a2e083d1f8b224d7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let obj = new A(); + obj instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..62b581db2d47c2118bf225f93964e49e2f40c86f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj instanceof A) { + let a = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..1d251e7e73da784fcfeaec98e552904d076a14cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + class A {} + + let obj = new A(); + obj instanceof A; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..66c02cf48ac7b3e779d61b106a8026ea626702c8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; +a instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae9238e5133211282a4f2c0973f2bc8687a7aeb8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A {} + +let obj = new A(); +obj ?? (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..67aff1a619c388ac82f7f21356222513838dbfd3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) >= (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7df8c6f371fc1aaf20ef4c7554560227935c63a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A {} + +{ + let obj = new A(); + obj instanceof A; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..fea63a57fa560c7ac4885af2773efa76d355f18f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +name instanceof string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..638b9141f38e07d8deadbd984e5745a68d6653a1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A {} + +let a = 0; +switch (a) { + case 0: + let obj = new A(); + (obj instanceof A) >= (obj instanceof A); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b10f87658cca6fed7c406ab0ff1f6edc0d0d6fb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A {} + +let obj = new A(); +!(obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7934959c85dea317e40a078adb181a2feaf06a29 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.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.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj instanceof A) { + let $ = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3a53d0159476533396a41b7e3b5c506f500e95b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 2 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e475fff09910a90514e520a1ce942ff876aba087 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..88a9370e4dab40f4702bfe033fc39d57f62209d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 * 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a3dd1a35d0a8d123538037fe5dda313362e6841 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = (2 * 3) & 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..5056ce69bf5241830948c1d0c12f4e205c00ce17 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 * 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..54ed43c67036510bef5bd42446c0e58986ccb4c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd08df244dd0d4d8122a7dd0269875c376b1be0f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0b96d1d99ae190c9d2367a4e18df401a27d13e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..977fa261014e167d352bf71355c0cdb36d0542f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 3 * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7e3585ad16f4307f5d5eef79d54d3ab465357dde --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = a * 1.2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..00e2f83a3616dcda4e7f28ba8e9858cf3f69a882 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = 3 * 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad2f2b3a9693a8cefe3c5a60859c5ed61d4eec32 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = 3 * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e668d3fba2e5f7cb28166e31c2e9b778ba95738a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = 3 * 2; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b317c8a5f039904a43475df8f994a1f3a0f98c3a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = a * 3; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..3eb98e7196831afae2b899326d4293e812d728be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 1; + a = a *3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a6422eecb1d10fe679e047e9366fb7534fee3237 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a * b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6413f85381ed7b79eb7087ea3179954acbe6650 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a / b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c8c2755630475c1da5b318732fc8dda508dbce0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 10; + a = a % 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d16e89c0771d7bd77ec62972eb3f7698ba73a14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a * 3; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..beff84d5630a47725331e2539986601655890089 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ab54a8736452585696e38e0893d47346d6a361b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 2 > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1ea20bbd255eb461b9619efee5b8634eb582281 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x * 2; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fac64b2dfc4e0e87b8720b6291e19686cd517cd4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a * 2) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7c76b52aef3c492fb2ec1bfe838817786cae7a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 1; +a * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..fceaa391299a47d4ad1327d0280e6a33cca0e149 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a * 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1bef385acbafc6c2c1c102b4502e374c24a6bda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = a * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dcd7cc795fa99dcfcbbfad7ec14b396bc80a9e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..d203f8201cfd8ad838588c164339e894d5217fba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a * 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fcc44be8f359a18a27dec78c7c59fcc4bd715b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 3 *2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1fe9cfed1be51151745bd36c429b55b90f8540c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.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.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = a * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f554034e8b70a0f851ed431b713022b0b5b48b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9deb8b7505e76d90d0da46d2fa8a2baf82fde881 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d74f550da633160645a69e7f46a5edc6a3c03e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) & c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..e981233d446a5a8a09b746bf4d23a807097b3b9a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a: number | null = null; + result1 = this.a ?? 5; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6f0ace6cebb4434b59ab47fb340c2d5aba75bdf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) && (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7efb8c4e9798b07b405acb10e95bcfc6e1774f4d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) ? a : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfc799b1041e0280ceda4192c95be9b962c0c380 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) || (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..07bbf06eb145adf6f2af628f2461f0912c8abea9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +const result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..423d1ef25205d080eb9ba1163309cf2ffd910138 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) == (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f691d811c91bfd30d5fe2d97f9579a9beae7e45 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let a: number | null = null; +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr!) { + let res = a ?? 5; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea76c1855209a9499ac47f8e9bd8c142d161176c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number | null = null; +for (; (a ?? 5) > 0; i++) { + if (true) { + let func1: () => void; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..953af7e92c80522e09de78c76f8d3ce19cef85af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let a: number | null = null; +let obj = new A(); +if ((a ?? 5) > 0) { + a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a3f4c35f88ef2e1a483e09adf2accf88e1c9267 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a: number | null = null; + let result1 = (a ?? 5) + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b3c37c1fdfe2ab01a08c180e130476ce322bc08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + let result1 = (a ?? 5) + 1; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..26320bbbf1ad34c80768e80f8a6f84076a4fd21d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + let result1 = (a ?? 5) + 1; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..737590d85890bc3ff525e721be248a698f44797e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a: number | null = null; +while((a ?? -5) > 0) { + let a = -1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..01eae8f2ebbbf9f733a7aec1f2e249574ff16add --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) * c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..4427091acbaa79ffe70d8b27d04e8be6deae5b3e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number | null = null; + let result1 = (a ?? 5) + 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..895a06aaa619b1de99c555dd7d41779081b7d6ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; + +a ?? null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c04f4df79746a36ade33bdb7afc50e5b3205a9e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) > c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..62ef5b709b442338ce3363de9a1a1a5a9db5d126 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number | null, y?: number, ...numbers: number[]): number { + return x ?? 5; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c90902509b5fce875fed994eafc43e2b8fccf48a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a: number | null = 3 >> 2; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2dd127ab66523eb16da0e5797acd0c4606326c1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..8690b800ecd148818cf9d46581e0332754438410 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: string | null = 'Alice'; +let result3 = `Hi, ${a ?? "Anonymous"}!`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..26ac9d5e5ad9f78e675fabe663c3c112eca69bc7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let zero: int = 0; +switch (zero) { + case 0: + let a: number | null = 0; + let result1 = (a ?? 5) + 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..61dac631a8b2c85f0e76e6c722c9e46ba36bfc1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff3e41022c9930842c3686517e2b14d9ea9d09e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +const calculator = new Calculator(); +let a: number | null = null; +let b: number | undefined = undefined; +const result1 = calculator.calculate(a ?? 5, b ?? 10, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..12ec27d3598dd16342a5a0f177e28ff843223c1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a: number | null = null; + let result1 = (a ?? 5) + 1; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a05f19278f838b854876980b08513e68caad86d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a: number | null = 0; +let result1 = -(a ?? 5) + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..87e454b9e30b23942d0e4034e8e3e59f3ec2aefd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_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.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let a: number | null = null; +while((a ?? -5) > 0) { + let a = -1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..90bb401d1937cb96a5da68fa07cd85eb35195186 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 << 2; +let b = a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2863bc8d5d1838eacc05d0234c38bf41a8365445 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 >> 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ab5571f543f5d30a8f00eee6316578dca855bd3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 1 >> 2; +a & a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..b165734fce444f54fae6db7dd57b74b632cedd07 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 >> 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3599e3f1f4f5ae7264c2603d75a179cec0803c89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result = (a >> 5) && (b << 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6188de5c1b136dd6114bcf32a2b03418f5a0ea5b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let result = (a << 2) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bedca438d3151f5ec05c1ed4eaa5750256d0f02e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result = (a >> 5) || (b << 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6baf2393cb8d95327e9a537e4b2881ae93dbd664 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5c79e16185322de56b8bab7dd31ec1193ee3e8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let result = 1 >> 2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfc6617458cffec678952391d277bac04b4bd704 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + 1 >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..65cbe31330e958b9f57da1664ae542376e269ce2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = 1 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccdb8ab85a501c6f154237d9556f9bdde7d36d16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = 1 >> 2; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..47fd6fbd33ef63c9416a5385ecbe18494cb2dec4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = a << 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..9cb151217ecdd2280182b70d9db7ec8c6cfc5bea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let a = 1; + a = 1 >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..119002f983edac692c9389bca073539c433b41e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = 1 >> 2; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a0215da5c418b60bf91c88aa17a07ebcd70c603 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = 1 >> 2; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1003cdc3d4235a3c085541a14c5f96b8ee14d8b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = 1 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc3b4c4b16325c0a945777583464c337a399634c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a >> 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc71ba651079e0c62628d32a6edfc7a08c032636 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] << 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5246f678993aca29cd20d8dec8de0e636f166155 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a >> 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..131934d78caa8732c6d0f32f8e470720837f9ae4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x << 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5302e9c0b045e8edced1b89196880b49ecea351c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 3 >> 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..82b7608335d4edc3cd99ccfb6e2921174ced8a5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a << 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1cd87fcfca7b81df0f372f9c43386425549373f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = 3 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd9496cf09b41855f868ce26f2658f6f72a688bc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 >> 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..cac8be06175d69d545a4451d20799dbf48dae63c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a << 1, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1589df9f38f365e835fb6c4d218955bf30f6ba3e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 0; + a = a << 3; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..51a01654a89fcde45dcaffc5202bd2693689752b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.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.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = a << 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..73bcfbe6c1051ab71123a5eda489b5f92f421941 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b94b22785260a2537e8b42a9b9b574bf6645fbe0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2d3cbb2c27f6b3c8ec6c9e26946ae2163f7244d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 2 & 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..02a4c367725f6af497f7c92101e052a168b0330b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class TestClass { + value = 42; + typeOfValue = typeof this.value; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bbb8732f794be88632374baa3ad549c8cd085bf8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = 2; +typeof a == "number" && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccd552ee44aa649bd043fbdcef95adef0b6a029f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 2; +let result = true; +typeof a == "number" ? result : result = false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e632ba2cbd793e9155da410cf164018aa74e4f51 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a = 2; +typeof a == "number" || false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccd7b01a26c5b1289e6adc63893dda252d539d28 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdf081b41cdc306cd83fedcf986f4cb599ea8387 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let a = 2 + 3; +typeof a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f2c904ee4c28aaddb84d774830895bbe5122dd4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum C { Red }; +let c: C = C.Red; +typeof c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..796f799eecf80120ef46ddda2f66f88f24f8480b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 2; +typeof a == "number" && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..c53bd44706e565454221d4f35bb6cdac83ddd509 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A {} + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let obj = new A(); + typeof obj; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..a52b06e6f5930d87d6a34b6fb6fcf33136444a6b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr) { + let a = 2 + 3; + typeof a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..156c3c860bab87917831ac6a8199f025f335559a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let a = 2; +for (let a = 1; typeof a == "number"; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..8dd02b8c7905f55fae2344ca444631f289a06e6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +type ft = () => string; + +let myFunction: ft = (): string =>{ + return `string`; +}; +const functionType = typeof myFunction; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd098adb13c68b04f35b7688b402e8ba4d79217c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 2; +if (typeof a == "number") { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..c60e4596d3d330c6f73c8e470cf9c37a49980331 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let a = 2 + 3; + typeof a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5c3a5cc8ad73daafd6200eb2fa7532e51489dc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number, z?: number): Promise => { + let a = 2 + 3; + typeof a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..288fcaa4ba1d5769bfdb66837d635ba96c44f07f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let a = 2 + 3; + typeof a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ee39a9d762657b7bf43c30b7bf133b09191f3ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd3b4241786c4d12a2b1798228dd264cd417fd0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; + } +} + +let person = new Person2(); +let result = person.setName(1, 2, 3, 4); +typeof result; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c09e10c05b25b3ba1bf3faa07b15a6d7154939c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 2 * 3; + typeof a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc10c4a4b4a9c409762579fb4e9a9a9a17285019 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let b = new string[1]; +typeof b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9de201eb1f82cc4da8e86bbbd4c790136380e4b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: number | null = null; +let resultA = a ?? 10; +typeof resultA === 'number'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc666703128a588931c36260b1105c0da340425c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, $: number): string { + let a = 2 * 3; + let str = typeof a; + return str; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..640de7e6b15f08de99564f2167eeaf52b2d82eba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 2 >> 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..fce0c4afa5a893385567aa94bc9cdcf1e8f164f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 2 * 3; +let result = typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9fb8120dfa597a94227707884c9b7561380db260 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +typeof name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6476c2125502cf01d466d03be4f122dec0f136e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a) { + case 0: + typeof a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..a966e99011e761b5ef6c502cb49a94f017429e95 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a8c5ca2cf6b463272ecc52083c3d7f3b8b470ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +const calculator = new Calculator(); +const result = calculator.calculate(5, 10, (x, y) => x + y); +typeof result === 'number'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f475d9e4c70f13fad107861d35eaf7adf777cd5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = true; + typeof !a; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e05d03b5612a70c69c20ff0c1b3e5b8af0ba6ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = true; +typeof !a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ee39a9d762657b7bf43c30b7bf133b09191f3ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_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.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f48fa8ca08d2be65f49043dac230fee860233bd4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 2; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9098861fb1028bedba9fc39fe0e510a2ed9affda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1; +let b = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..17906b950d01f4dd2e96034459381a82c0d3e425 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 1 & 2; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3b84cd16da3ead93257ad34d5021ca8eb1bf691 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 + 2; + + constructor() { + this.a++; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0da5dd646a5568c5247ad73192d57fc0908c606 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..84168b4f38f1cf5c36919c121b012043f07d96df --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c4f552856ccafcc83effddc9c8386a9955cccc0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..536559cbe1075e4eb2521a7306cd130bce647bc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = !false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0990f112d3109cfd1c2a09f31b4595c20c947d8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ++a === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..51c19488ad480b5197be745881c1b78921451baa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = ~a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..97d010f0d10778e832f6da91cf33380c41a31e5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = ~a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4f9f3e826c9a41013216b1a6923e1dede74da209 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = ~a; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..554ba6cf8d6473f8cdb3be206f3825efac3cf78c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..82dc22aa0b9250646e0f2953f73a6313f7237478 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 1; + a = ~a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d53b02d176f65a7d3e13e70b6fe6b34a3d9b70d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee0624d9e6163b7dbf23a62e5b2774a76b5d0f21 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d9656a73404928d7808a59b05f7589a1a2666960 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = ~a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..aeb3f152385c4d9296b5122c890bec449775a704 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a = 1; +let res = ++a * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b4eeab6ba97e02532f295f8fffac0463e860174 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dc47a2064ee93ef5104c32567825026208f4bdc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0]++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e48d99ee79faa2f1a1da9dde241832df4ba4dd50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..845e4da110321115139d072f4aa2653e2d8f1bfe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x++; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b40ff750d4bf6f722238aec2ce2db290ed90f38d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a++) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0373674570eb58df3a1c50ac95a353c83a19e98e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 1; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b797e42e4dbfb46605b0e9d3d91a4c3ccc239a7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${++a}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..806ad71594255fdf479af19e5658745725693c85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a++; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..988545e746344944c86ed97adcb49a283297004b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..0841a478a88f321ed3e61d2ad8102b40b6c80754 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(++a, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..439d6fc22e4852047968261251772a7be51fe450 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 0; + a++; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..13473c0a3f37a71f95b329470e0e9294421ff1d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.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.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a++; + break; +} diff --git a/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets b/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets index dc16545ec60a3c941400de496711b7157ac915ea..a17d795587f54e95ae613de33144a5a1333bd8f6 100644 --- a/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets +++ b/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets @@ -14,13 +14,13 @@ */ let error = new Error(); -let p = new Promise((resolve: (value: string) => void, reject: (error: Object) => void) => { +let p = new Promise((resolve: (value: string) => void, reject: (error: Error) => void) => { throw error; }); p.then((value: string): void => { console.log("Test failed. The promise should not be fulfilled."); -}, (err: Object): void => { +}, (err: Error): void => { if (err !== error) { return; }