From 6a43a3a8186d1699f5684c8471309ea581102e18 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Mon, 28 Apr 2025 16:32:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E5=88=86=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E7=9B=B8=E5=85=B3=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujia178 --- ...LogicalExpression_assignmentExpression.ets | 30 +++++++++++++ ...seAndLogicalExpression_awaitExpression.ets | 32 ++++++++++++++ ...eAndLogicalExpression_classInitializer.ets | 32 ++++++++++++++ ...calExpression_conditionalAndExpression.ets | 33 ++++++++++++++ ...ogicalExpression_conditionalExpression.ets | 33 ++++++++++++++ ...icalExpression_conditionalOrExpression.ets | 33 ++++++++++++++ ...ndLogicalExpression_constantExpression.ets | 30 +++++++++++++ ...wiseAndLogicalExpression_finallyClause.ets | 40 +++++++++++++++++ ...iseAndLogicalExpression_forOfStatement.ets | 36 +++++++++++++++ ...twiseAndLogicalExpression_forStatement.ets | 37 ++++++++++++++++ ...itwiseAndLogicalExpression_ifStatement.ets | 37 ++++++++++++++++ ...eAndLogicalExpression_initializerBlock.ets | 37 ++++++++++++++++ ...eAndLogicalExpression_lambdaExpression.ets | 34 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 43 ++++++++++++++++++ ...wiseAndLogicalExpression_loopStatement.ets | 41 +++++++++++++++++ ...LogicalExpression_namespaceDeclaration.ets | 34 ++++++++++++++ ...eAndLogicalExpression_newArrayInstance.ets | 30 +++++++++++++ ...seAndLogicalExpression_returnStatement.ets | 34 ++++++++++++++ .../bitwiseAndLogicalExpression_statement.ets | 40 +++++++++++++++++ ...dLogicalExpression_stringInterpolation.ets | 33 ++++++++++++++ ...seAndLogicalExpression_switchStatement.ets | 35 +++++++++++++++ ...ndLogicalExpression_topLevelStatements.ets | 30 +++++++++++++ ...ndLogicalExpression_trailingLambdaCall.ets | 42 ++++++++++++++++++ ...twiseAndLogicalExpression_tryStatement.ets | 37 ++++++++++++++++ ...iseAndLogicalExpression_whileStatement.ets | 38 ++++++++++++++++ ...onalAndExpression_assignmentExpression.ets | 28 ++++++++++++ ...nditionalAndExpression_awaitExpression.ets | 30 +++++++++++++ ...ditionalAndExpression_classInitializer.ets | 30 +++++++++++++ ...nalAndExpression_conditionalExpression.ets | 31 +++++++++++++ ...lAndExpression_conditionalOrExpression.ets | 31 +++++++++++++ ...tionalAndExpression_constantExpression.ets | 28 ++++++++++++ ...conditionalAndExpression_finallyClause.ets | 38 ++++++++++++++++ ...onditionalAndExpression_forOfStatement.ets | 34 ++++++++++++++ .../conditionalAndExpression_forStatement.ets | 35 +++++++++++++++ .../conditionalAndExpression_ifStatement.ets | 35 +++++++++++++++ ...ditionalAndExpression_initializerBlock.ets | 35 +++++++++++++++ ...ditionalAndExpression_lambdaExpression.ets | 32 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 41 +++++++++++++++++ ...conditionalAndExpression_loopStatement.ets | 39 ++++++++++++++++ ...onalAndExpression_namespaceDeclaration.ets | 32 ++++++++++++++ ...ditionalAndExpression_newArrayInstance.ets | 28 ++++++++++++ ...nditionalAndExpression_returnStatement.ets | 32 ++++++++++++++ .../conditionalAndExpression_statement.ets | 38 ++++++++++++++++ ...ionalAndExpression_stringInterpolation.ets | 31 +++++++++++++ ...nditionalAndExpression_switchStatement.ets | 33 ++++++++++++++ ...tionalAndExpression_topLevelStatements.ets | 28 ++++++++++++ ...tionalAndExpression_trailingLambdaCall.ets | 40 +++++++++++++++++ .../conditionalAndExpression_tryStatement.ets | 35 +++++++++++++++ ...onditionalAndExpression_whileStatement.ets | 36 +++++++++++++++ ...ionalOrExpression_assignmentExpression.ets | 28 ++++++++++++ ...onditionalOrExpression_awaitExpression.ets | 30 +++++++++++++ ...nditionalOrExpression_classInitializer.ets | 30 +++++++++++++ ...onalOrExpression_conditionalExpression.ets | 31 +++++++++++++ ...itionalOrExpression_constantExpression.ets | 28 ++++++++++++ .../conditionalOrExpression_finallyClause.ets | 38 ++++++++++++++++ ...conditionalOrExpression_forOfStatement.ets | 34 ++++++++++++++ .../conditionalOrExpression_forStatement.ets | 35 +++++++++++++++ .../conditionalOrExpression_ifStatement.ets | 35 +++++++++++++++ ...nditionalOrExpression_initializerBlock.ets | 35 +++++++++++++++ ...nditionalOrExpression_lambdaExpression.ets | 32 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 41 +++++++++++++++++ .../conditionalOrExpression_loopStatement.ets | 39 ++++++++++++++++ ...ionalOrExpression_namespaceDeclaration.ets | 32 ++++++++++++++ ...nditionalOrExpression_newArrayInstance.ets | 28 ++++++++++++ ...onditionalOrExpression_returnStatement.ets | 32 ++++++++++++++ .../conditionalOrExpression_statement.ets | 38 ++++++++++++++++ ...tionalOrExpression_stringInterpolation.ets | 31 +++++++++++++ ...onditionalOrExpression_switchStatement.ets | 33 ++++++++++++++ ...itionalOrExpression_topLevelStatements.ets | 28 ++++++++++++ ...itionalOrExpression_trailingLambdaCall.ets | 40 +++++++++++++++++ .../conditionalOrExpression_tryStatement.ets | 35 +++++++++++++++ ...conditionalOrExpression_whileStatement.ets | 36 +++++++++++++++ ...qualityExpression_assignmentExpression.ets | 30 +++++++++++++ .../equalityExpression_awaitExpression.ets | 30 +++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 30 +++++++++++++ .../equalityExpression_classInitializer.ets | 30 +++++++++++++ ...ityExpression_conditionalAndExpression.ets | 31 +++++++++++++ ...ualityExpression_conditionalExpression.ets | 31 +++++++++++++ ...lityExpression_conditionalOrExpression.ets | 31 +++++++++++++ .../equalityExpression_constantExpression.ets | 28 ++++++++++++ .../equalityExpression_finallyClause.ets | 38 ++++++++++++++++ .../equalityExpression_forOfStatement.ets | 34 ++++++++++++++ .../equalityExpression_forStatement.ets | 35 +++++++++++++++ .../equalityExpression_ifStatement.ets | 35 +++++++++++++++ .../equalityExpression_initializerBlock.ets | 34 ++++++++++++++ .../equalityExpression_lambdaExpression.ets | 32 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 41 +++++++++++++++++ .../equalityExpression_loopStatement.ets | 39 ++++++++++++++++ ...qualityExpression_namespaceDeclaration.ets | 31 +++++++++++++ .../equalityExpression_newArrayInstance.ets | 32 ++++++++++++++ .../equalityExpression_returnStatement.ets | 32 ++++++++++++++ .../equalityExpression_statement.ets | 38 ++++++++++++++++ ...equalityExpression_stringInterpolation.ets | 31 +++++++++++++ .../equalityExpression_switchStatement.ets | 33 ++++++++++++++ .../equalityExpression_topLevelStatements.ets | 28 ++++++++++++ .../equalityExpression_trailingLambdaCall.ets | 40 +++++++++++++++++ .../equalityExpression_tryStatement.ets | 35 +++++++++++++++ .../equalityExpression_whileStatement.ets | 36 +++++++++++++++ ...ationalExpression_assignmentExpression.ets | 31 +++++++++++++ .../relationalExpression_awaitExpression.ets | 33 ++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 33 ++++++++++++++ .../relationalExpression_classInitializer.ets | 33 ++++++++++++++ ...nalExpression_conditionalAndExpression.ets | 34 ++++++++++++++ ...tionalExpression_conditionalExpression.ets | 34 ++++++++++++++ ...onalExpression_conditionalOrExpression.ets | 34 ++++++++++++++ ...elationalExpression_constantExpression.ets | 31 +++++++++++++ ...elationalExpression_equalityExpression.ets | 34 ++++++++++++++ .../relationalExpression_finallyClause.ets | 41 +++++++++++++++++ .../relationalExpression_forOfStatement.ets | 37 ++++++++++++++++ .../relationalExpression_forStatement.ets | 38 ++++++++++++++++ .../relationalExpression_ifStatement.ets | 38 ++++++++++++++++ .../relationalExpression_initializerBlock.ets | 38 ++++++++++++++++ .../relationalExpression_lambdaExpression.ets | 35 +++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 44 +++++++++++++++++++ .../relationalExpression_loopStatement.ets | 42 ++++++++++++++++++ ...ationalExpression_namespaceDeclaration.ets | 34 ++++++++++++++ .../relationalExpression_newArrayInstance.ets | 32 ++++++++++++++ .../relationalExpression_returnStatement.ets | 35 +++++++++++++++ .../relationalExpression_statement.ets | 41 +++++++++++++++++ ...lationalExpression_stringInterpolation.ets | 34 ++++++++++++++ .../relationalExpression_switchStatement.ets | 33 ++++++++++++++ ...elationalExpression_topLevelStatements.ets | 31 +++++++++++++ ...elationalExpression_trailingLambdaCall.ets | 43 ++++++++++++++++++ .../relationalExpression_tryStatement.ets | 38 ++++++++++++++++ .../relationalExpression_whileStatement.ets | 39 ++++++++++++++++ 125 files changed, 4285 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/bitwiseAndLogicalExpression/bitwiseAndLogicalExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalAndExpression/conditionalAndExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/conditionalOrExpression/conditionalOrExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/equalityExpression/equalityExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/relationalExpression/relationalExpression_whileStatement.ets 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 0000000000..aac6cfc366 --- /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 0000000000..d3341c383c --- /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 0000000000..d3d7eca1cf --- /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 0000000000..f68d3b7ac5 --- /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 0000000000..fb62a1e744 --- /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 0000000000..e468405a9d --- /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 0000000000..12f23620f5 --- /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 0000000000..daebe5832b --- /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 0000000000..ccc34e7912 --- /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 0000000000..7c2f5adbf5 --- /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 0000000000..941389f683 --- /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 0000000000..43712ff712 --- /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 0000000000..c490e886a8 --- /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 0000000000..3b71efec90 --- /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 0000000000..1dd5928562 --- /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 0000000000..cf391bd1a4 --- /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 0000000000..cc1367cd36 --- /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 0000000000..7ede2b1682 --- /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 0000000000..c8a1281520 --- /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 0000000000..08f768d1db --- /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 0000000000..b8a7dd2968 --- /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 0000000000..f110ce1e47 --- /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 0000000000..0b4b4aa1e5 --- /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 0000000000..c18b55fee1 --- /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 0000000000..2625d53a10 --- /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 0000000000..48301cfe1a --- /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 0000000000..912aa7537f --- /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 0000000000..e3ebe5e05b --- /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 0000000000..bb54aff14e --- /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 0000000000..644931f9dc --- /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 0000000000..f08bd314ab --- /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 0000000000..bf1b1b9579 --- /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 0000000000..621e9c275e --- /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 0000000000..eccdb5299d --- /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 0000000000..9251d498c2 --- /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 0000000000..ce6ea3604e --- /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 0000000000..95b25eb0cd --- /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 0000000000..bfe40e7d0b --- /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 0000000000..f60451f513 --- /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 0000000000..3a4a0553a0 --- /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 0000000000..6f6f94b7ac --- /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 0000000000..5d4c51ac0a --- /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 0000000000..821f53e357 --- /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 0000000000..632906a2b8 --- /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 0000000000..0bbe96069c --- /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 0000000000..60bd371a99 --- /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 0000000000..8fa142a022 --- /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 0000000000..5f8c289aa9 --- /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 0000000000..405ca5f208 --- /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 0000000000..5f22c1c4a5 --- /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 0000000000..f49da6a427 --- /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 0000000000..fa61b3d22d --- /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 0000000000..889c5668e8 --- /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 0000000000..fdf6bf4eb8 --- /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 0000000000..ec76eefba8 --- /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 0000000000..b3854c992f --- /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 0000000000..ff3a27c73d --- /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 0000000000..91592221cb --- /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 0000000000..2015f88464 --- /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 0000000000..d484fc0b4b --- /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 0000000000..de4f23fb97 --- /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 0000000000..d5e9025d06 --- /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 0000000000..7a84c4702f --- /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 0000000000..2cd3fd3d9c --- /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 0000000000..7512c302c9 --- /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 0000000000..b0bbef0161 --- /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 0000000000..d2a465689b --- /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 0000000000..25a9fba734 --- /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 0000000000..0ea7800ca5 --- /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 0000000000..8f242d950b --- /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 0000000000..e170afcb30 --- /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 0000000000..d8d3c71dcf --- /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 0000000000..3db617a8d1 --- /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 0000000000..b0bc884d87 --- /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 0000000000..d05d058bb1 --- /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 0000000000..5c03a76f68 --- /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 0000000000..41232882bd --- /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 0000000000..5ad2eee6bf --- /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 0000000000..8392c450a5 --- /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 0000000000..196ca3ca1d --- /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 0000000000..37731e81f6 --- /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 0000000000..d361dd5add --- /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 0000000000..7b2bb45466 --- /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 0000000000..b25de3ae2a --- /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 0000000000..814e89cb65 --- /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 0000000000..7598454dd1 --- /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 0000000000..5b32e59092 --- /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 0000000000..5054cd03a9 --- /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 0000000000..39b199add6 --- /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 0000000000..3352b44681 --- /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 0000000000..af0e91e416 --- /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 0000000000..899ca2a466 --- /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 0000000000..93e908d855 --- /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 0000000000..12e8093a69 --- /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 0000000000..3631d49675 --- /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 0000000000..201aa78807 --- /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 0000000000..48931687ae --- /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 0000000000..b28ff107aa --- /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 0000000000..b6273b938f --- /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 0000000000..cd4588c372 --- /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 0000000000..92dcc5b3fa --- /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 0000000000..05521c6f46 --- /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 0000000000..77db0bc4e5 --- /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 0000000000..219b37df8c --- /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 0000000000..06bbc860da --- /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 0000000000..1b6b7650f5 --- /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 0000000000..9c5abb0913 --- /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 0000000000..93f8dc5d58 --- /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 0000000000..5dc1579569 --- /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 0000000000..abaf8f0457 --- /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 0000000000..6a8fabd179 --- /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 0000000000..249579aa94 --- /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 0000000000..07fe48b7e7 --- /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 0000000000..56cfb31aa7 --- /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 0000000000..77e07ef479 --- /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 0000000000..ee945ebb78 --- /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 0000000000..1f36602454 --- /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 0000000000..cffd790894 --- /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 0000000000..155ebc48a0 --- /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 0000000000..ab7c5cdbc6 --- /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 0000000000..388c2db9f0 --- /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 0000000000..185b8f1696 --- /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 0000000000..5e0c9f0cff --- /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 0000000000..ccb80f6e02 --- /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 0000000000..5ae9142e54 --- /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; +} -- Gitee