diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..aac6cfc36643c6a0c1862419a60e65dd879620ee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3341c383c1a4a1282e08bb9b7a71122f3cb9c97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3d7eca1cf70a0c3f584b81be19c9ab668d2baa5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f68d3b7ac52c54a8a02d9474ce662230eebd3a8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb62a1e744a35c8466502a0c040c3cd976e64087 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e468405a9d11ce22b1eba17accb248d0565fdfb4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..12f23620f5a9aaeae1d2d1c8e6c85f85d2489c0f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..daebe5832ba099bbf688447a5a30285570ddb4cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 ^ 3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccc34e79125eca56b7de94bc064848d37c6876d7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 & 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c2f5adbf5241a98935511621ab025e85c8acadc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 & 3; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..941389f683312a3721f2a8ee475ec5db991fa1b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 ^ 2; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..43712ff7128a8921cf59562fa4bd72a7d130978e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c490e886a8cafc76af5be6549e11f68e699a5f01 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b71efec904e5b7f8aa135fc2effb8310cbdfcc0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpressionWithReceiver.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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A { + public a: number; + public b: number; + constructor() { + this.a = 0; + this.b = 1; + } +} + +const processNumbers = (this: A, b: number): number => { + return this.a ^ this.b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1dd59285624d402487a8ad99d34319a47bd4a29e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 ^ 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf391bd1a495cb1a93f63a0ad96fdb9bba1c47ad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..cc1367cd36e703c154a607ca7a2ac3b27b5aa299 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5 ^ 2).fill(0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ede2b1682436b9cc288d6777b51886c80a889d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8a1281520a1c3d62d1dc61a1ed83d828fc42493 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..08f768d1db93c250c3aaf88802e6a7ac382e7aa8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8a7dd29684af5a9097b2741a9e95b2f680abef9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..f110ce1e471ad5f4af5c10a97e3162f65368c932 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b4b4aa1e593dba8bcfe59da61b8b521a639d092 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * 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 ^ 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c18b55fee1a3163babeb06938d4a3c1f7408f249 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..2625d53a10ad8e35247847c296e61732d97d772c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_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.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | 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/conditionalAndExpression/conditionalAndExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..48301cfe1a6e733cb2ac3d9a8d2e1227c5693ab9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..912aa7537f201c54e457a1cf44504eadd9e4526a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_awaitExpression.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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..e3ebe5e05b0c7f64a08b7aaa3053060f71ed0f0d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_classInitializer.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 && 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb54aff14eee6d76ae090597eb371cafc6600e58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..644931f9dcf3d46455e7d7bf446c571c20329f1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f08bd314abef04c91ccab66519e581c2e79f2590 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf1b1b95792331319853998ac5a386dc798d193f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..621e9c275ee8611fc512de50d81dc66e6a3500ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..eccdb5299d575a9269eff574b629521c58c478f3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9251d498c26502149fba28e095e3d23ce8fde301 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..ce6ea3604e9cab3fb7548d7523479dc55496a2a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..95b25eb0cd85c8b5aaa764513404e4aff69a0fd7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfe40e7d0b496db13243c089c911bc1dd54228d8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A { + public a: number; + public b: number; + constructor() { + this.a = 0; + this.b = 1; + } +} + +const processNumbers = (this: A, b: number): number => { + return this.a && this.b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..f60451f513ba48ad5fe2505e7f6246a7a99ba86d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_loopStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a4a0553a0aa8a26fb0fb877eb04611f688aa577 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..6f6f94b7acdc295cbd654591ece3d2c96c7224fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_newArrayInstance.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5 && 2).fill(0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5d4c51ac0abb6453848b2c37c1581f015f586ba4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..821f53e357ffd6a83149fb8f86ed9cd37393033b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..632906a2b8f4f31763a6a8e3196d5710c9179df8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0bbe96069c636178aa589d83b8263d55611d6e4f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..60bd371a99e2034bc34fee485be93bd706e9fb02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 && 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..8fa142a0223839902b636691911220301432935f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f8c289aa90f0ffc7f1a94a1df53da35e353bf1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.27 + * conditionalAndExpression: + * 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/conditionalAndExpression/conditionalAndExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..405ca5f208025e35e33bcbf386120d8891249177 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_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.27 + * conditionalAndExpression: + * 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/conditionalOrExpression/conditionalOrExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f22c1c4a5a943df725b1b66b0bac8be78e3338e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f49da6a4273c4f3a62383d0143c039218fdfc49c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_awaitExpression.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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa61b3d22d2bcf39395f68765d098f79fc628dc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_classInitializer.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 || 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..889c5668e8b75df251cd8780f823edc5393d457e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdf6bf4eb80e6cf6aa7a87587447d406300b349e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..ec76eefba89ab7c868f63b832030522785118120 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3854c992f458925380c7757ef1a1031c8a3c9b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff3a27c73d9a539c1f85302ab31907525a6f448d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..91592221cbbfce2c48569e0248e9f414a9de1ab5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..2015f88464afe2a49a06e283049c0e82d7cc240a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d484fc0b4b3d5c071bb9a0541d577483b2b81c58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..de4f23fb97fee12087c65c3675712951ecc4a8cc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * expression '||' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A { + public a: number; + public b: number; + constructor() { + this.a = 0; + this.b = 1; + } +} + +const processNumbers = (this: A, b: number): number => { + return this.a || this.b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5e9025d06e6096b149784fbffc95a9efbc988c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_loopStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a84c4702ff9b4721ec7fdd4a6bcabcaf8248d26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..2cd3fd3d9c8fb28f9817e42a98a02eb3c4ec2ddc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_newArrayInstance.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5 || 2).fill(0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7512c302c959769db95c45bb0bf6894e9b616b1c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0bbef01613bb49e9177f332206df99939e99fa0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2a465689b4e8e64fee79a5e742ed088d3dc3d65 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..25a9fba734b0a0f721a59d815abe54aa370bfce4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ea7800ca5e99a6bc0341473a21dd673852c1050 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 || 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f242d950b6ae777e6a6dbcfb9427358e65b6b69 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e170afcb302ed84070f90c805ddee7e730bb6443 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.28 + * conditionalOrExpression: + * 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/conditionalOrExpression/conditionalOrExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d8d3c71dcfe3c8ec3717a5384c9a8979301577cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_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.28 + * conditionalOrExpression: + * 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/equalityExpression/equalityExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3db617a8d184dc508c6626ef7ab3ef5bc6b95313 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let x = 1; +let y = 2; +let result = (x += y) == 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b0bc884d871da9f04fb271f7c2996e2135f9b91e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_awaitExpression.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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: boolean) {} + +await foo(3 == 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d05d058bb13af65046950df5db508f63de0c7648 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..5c03a76f68401a1eeb1d78598010fee7621d9a82 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_classInitializer.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 == 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..41232882bdac2484560ac68c173f79a5b5f47c4c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ad2eee6bf590510fc505e9f9a47a381b1527a31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8392c450a511c179804a7a7d265fb8eaf7e45862 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..196ca3ca1d27ca6bc680d55415c165a412ea225a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..37731e81f6933c30b13a64ec424a25896f299a95 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * 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 == 3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d361dd5addb742d14355d42f9b52d4b5443eed90 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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 == 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..7b2bb45466cbd301aace390e131a87dd45ccdd8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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) { + 1 == 3; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b25de3ae2a3c2922488250c88bb9c718d6df5212 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (1 == 3) { + let a: number = 5 + 2; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..814e89cb65f4b93b4ee2ba202e8f5136fe1b8267 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_initializerBlock.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + 1 == 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7598454dd18d5dcf601902d37731d6a5df2d0bf2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + 1 == 2; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b32e590924ba89edef89f8c332d56def7f0bbc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A { + public a: number; + public b: number; + constructor() { + this.a = 0; + this.b = 1; + } +} + +const processNumbers = (this: A, b: number): boolean => { + return this.a == this.b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5054cd03a9d0c7b4547872e123bfc6675ef64e50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_loopStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +let a = 1; +while(a == 1) { + a = a + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..39b199add6272e8d71ad0c332268c3077d4b554c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + 3 == 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..3352b44681fd336600b702b9a056a416225afb73 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_newArrayInstance.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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let array1: Array = new Array(3).fill(1); +let array2: Array = new Array(3).fill(1); + +console.log(array1 == array2); +console.log(array1 === array2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..af0e91e4165c57aac597d5c93da6e767b663787a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): boolean { + return x == 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..899ca2a466ef468ff9829572ab1a3552ac7249dc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..93e908d855cca37ed9fdd95f1b1f04ad0845081c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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/equalityExpression/equalityExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..12e8093a69828a62660328b82d1aedf724c2c3bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a) { + case 0: + let b = 3 == 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..3631d496754725dfdb83e5b9ed56b78cae9d1514 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 == 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..201aa788076e123d8cf93dd53b74f27dee8b527f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: boolean, b: number, operation: (x: number, y: number) => number): number { + return operation(1, b); + } +} + +let a: number = 1; +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/equalityExpression/equalityExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..48931687ae7e0ee337e885ac196b44a7ca337a7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + 3 == 2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..b28ff107aa32cd60eeb5bac304d560240b851703 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_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.25 + * equalityExpression: + * 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/relationalExpression/relationalExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b6273b938f326fc6df68545b6bb4d3c6df3bb4e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | 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/relationalExpression/relationalExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..cd4588c372e5e5b4f82c3c21534c51d543ac5139 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: boolean) {} + +await foo(3 > 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..92dcc5b3fafc187accce7d42d4806973d40dc98f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | 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/relationalExpression/relationalExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..05521c6f469c74401bd3aff24ef316b7d46012e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_classInitializer.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | 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/relationalExpression/relationalExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..77db0bc4e5b488d9b210dccc3be7d159d81a0ef9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * 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 + 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..219b37df8cb223967c878c2105b1c08be1f30e59 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * 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 + 2) > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..06bbc860daf475325b03ab467264158e896f3f76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * 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 + 2) > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b6b7650f5ddff9c15cf55ca784b99eff438de97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = (3 + 2) > 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9c5abb09134630fe449b9f803d7a4a8d6bc4838b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_equalityExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * 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 < 3) === (b > 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..93f8dc5d583d1de0e7046461f800e2b117ad8097 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_finallyClause.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.24 + * relationalExpression: + * 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 > 3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5dc1579569c3ab555a7cac4d824115b595044f52 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forOfStatement.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.24 + * relationalExpression: + * 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: boolean = true; +for (item of arr!) { + a = 3 > 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..abaf8f0457ad924bf56f8d25b3a0e28f85971c42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forStatement.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.24 + * relationalExpression: + * 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 + 3; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6a8fabd179232e8be6f19cfcaaacde27e3ef2911 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_ifStatement.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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (2 < 3) { + let a: number = 5 + 2; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..249579aa941a7fe5953b1d076e95305dac0ab3ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_initializerBlock.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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let a = true; + a = 3 < 4; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..07fe48b7e776fbd89e6cd4b76c69be226ec5c4bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpression.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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): boolean => { + a++; + b = ~b; + return 3 < 2; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..56cfb31aa7698648a85d088b9c23d45accc2138e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A { + public a: number; + public b: number; + constructor() { + this.a = 0; + this.b = 1; + } +} + +const processNumbers = (this: A, b: number): boolean => { + return this.a < this.b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..77e07ef479b51342985b08346f310325eda6b730 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_loopStatement.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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +let a = 1; +while(a > 0) { + a--; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee945ebb78ce84c3c63eeb8d0b8c885711345245 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1 < 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f3660245410574c9ea251f61ad32c9a645115f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_newArrayInstance.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.24 + * relationalExpression: + * 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] > 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cffd7908943dab20fee598ebab60a70a83b2d6b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_returnStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): boolean { + return x > 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..155ebc48a077b4c84241beb9f432ca8f59715d4e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | 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/relationalExpression/relationalExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab7c5cdbc6f2d0bf85b0c7d9e9847dd80d15d6e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_stringInterpolation.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * 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 > 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..388c2db9f02acd237df7018d65cb58cd2b3a1130 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0: + 3 > 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..185b8f16966f0d25b2e0de2b4e511fc707c1d446 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | 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/relationalExpression/relationalExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..5e0c9f0cff31b1f5906507f3b748c7ef37603150 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_trailingLambdaCall.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: boolean, b: number, operation: (x: number, y: number) => number): number { + return operation(1, b); + } +} + +let a1: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a1 > 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..ccb80f6e02866fa445c74483ba4290c28d6b294f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + 3 > 2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ae9142e54f9164aad7bea8f9b40be305ebab240 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_whileStatement.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.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(a > 0) { + a--; + break; +}