From 846985cc9b0d8afb87a7a5f99cfcafcc734b2fc0 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Sun, 27 Apr 2025 11:01:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=A8=E8=BE=BE=E5=BC=8F?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=AD=A3=E4=BA=A4=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 --- ...dditiveExpression_assignmentExpression.ets | 29 ++++++++++++ .../additiveExpression_awaitExpression.ets | 31 ++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 31 ++++++++++++ .../additiveExpression_classInitializer.ets | 31 ++++++++++++ ...iveExpression_conditionalAndExpression.ets | 32 +++++++++++++ ...ditiveExpression_conditionalExpression.ets | 32 +++++++++++++ ...tiveExpression_conditionalOrExpression.ets | 32 +++++++++++++ .../additiveExpression_constantExpression.ets | 29 ++++++++++++ .../additiveExpression_equalityExpression.ets | 32 +++++++++++++ .../additiveExpression_finallyClause.ets | 39 +++++++++++++++ .../additiveExpression_forOfStatement.ets | 35 ++++++++++++++ .../additiveExpression_forStatement.ets | 36 ++++++++++++++ .../additiveExpression_ifStatement.ets | 36 ++++++++++++++ .../additiveExpression_initializerBlock.ets | 36 ++++++++++++++ .../additiveExpression_lambdaExpression.ets | 33 +++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 35 ++++++++++++++ .../additiveExpression_loopStatement.ets | 40 ++++++++++++++++ ...dditiveExpression_namespaceDeclaration.ets | 33 +++++++++++++ .../additiveExpression_newArrayInstance.ets | 30 ++++++++++++ ...dditiveExpression_relationalExpression.ets | 35 ++++++++++++++ .../additiveExpression_returnStatement.ets | 33 +++++++++++++ .../additiveExpression_shiftExpression.ets | 33 +++++++++++++ .../additiveExpression_statement.ets | 39 +++++++++++++++ ...additiveExpression_stringInterpolation.ets | 32 +++++++++++++ .../additiveExpression_switchStatement.ets | 34 ++++++++++++++ .../additiveExpression_topLevelStatements.ets | 29 ++++++++++++ .../additiveExpression_trailingLambdaCall.ets | 41 ++++++++++++++++ .../additiveExpression_tryStatement.ets | 36 ++++++++++++++ .../additiveExpression_whileStatement.ets | 37 +++++++++++++++ ...otNullishExpression_additiveExpression.ets | 32 +++++++++++++ ...NullishExpression_assignmentExpression.ets | 30 ++++++++++++ ...reNotNullishExpression_awaitExpression.ets | 35 ++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 33 +++++++++++++ ...eNotNullishExpression_classInitializer.ets | 32 +++++++++++++ ...ishExpression_conditionalAndExpression.ets | 31 ++++++++++++ ...ullishExpression_conditionalExpression.ets | 30 ++++++++++++ ...lishExpression_conditionalOrExpression.ets | 31 ++++++++++++ ...otNullishExpression_constantExpression.ets | 31 ++++++++++++ ...otNullishExpression_equalityExpression.ets | 31 ++++++++++++ ...sureNotNullishExpression_finallyClause.ets | 39 +++++++++++++++ ...ureNotNullishExpression_forOfStatement.ets | 33 +++++++++++++ ...nsureNotNullishExpression_forStatement.ets | 34 ++++++++++++++ ...ensureNotNullishExpression_ifStatement.ets | 34 ++++++++++++++ ...eNotNullishExpression_initializerBlock.ets | 35 ++++++++++++++ ...eNotNullishExpression_lambdaExpression.ets | 32 +++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 34 ++++++++++++++ ...sureNotNullishExpression_loopStatement.ets | 38 +++++++++++++++ ...ishExpression_multiplicativeExpression.ets | 33 +++++++++++++ ...NullishExpression_namespaceDeclaration.ets | 34 ++++++++++++++ ...eNotNullishExpression_newArrayInstance.ets | 30 ++++++++++++ ...Expression_nullishCoalescingExpression.ets | 31 ++++++++++++ ...NullishExpression_relationalExpression.ets | 34 ++++++++++++++ ...reNotNullishExpression_returnStatement.ets | 32 +++++++++++++ ...reNotNullishExpression_shiftExpression.ets | 33 +++++++++++++ .../ensureNotNullishExpression_statement.ets | 41 ++++++++++++++++ ...tNullishExpression_stringInterpolation.ets | 31 ++++++++++++ ...reNotNullishExpression_switchStatement.ets | 29 ++++++++++++ ...otNullishExpression_topLevelStatements.ets | 29 ++++++++++++ ...otNullishExpression_trailingLambdaCall.ets | 42 +++++++++++++++++ ...nsureNotNullishExpression_tryStatement.ets | 36 ++++++++++++++ ...reNotNullishExpression_unaryExpression.ets | 36 ++++++++++++++ ...ureNotNullishExpression_whileStatement.ets | 36 ++++++++++++++ .../instanceOfExpression-tryStatement.ets | 38 +++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 33 +++++++++++++ .../instanceOfExpression_classInitializer.ets | 35 ++++++++++++++ ...eOfExpression_conditionalAndExpression.ets | 31 ++++++++++++ ...anceOfExpression_conditionalExpression.ets | 31 ++++++++++++ ...ceOfExpression_conditionalOrExpression.ets | 31 ++++++++++++ ...nstanceOfExpression_constantExpression.ets | 31 ++++++++++++ ...fExpression_ensureNotNullishExpression.ets | 31 ++++++++++++ ...nstanceOfExpression_equalityExpression.ets | 31 ++++++++++++ .../instanceOfExpression_finallyClause.ets | 40 ++++++++++++++++ .../instanceOfExpression_forStatement.ets | 35 ++++++++++++++ .../instanceOfExpression_ifStatement.ets | 34 ++++++++++++++ .../instanceOfExpression_initializerBlock.ets | 35 ++++++++++++++ .../instanceOfExpression_loopStatement.ets | 38 +++++++++++++++ ...tanceOfExpression_namespaceDeclaration.ets | 34 ++++++++++++++ .../instanceOfExpression_newArrayInstance.ets | 30 ++++++++++++ ...Expression_nullishCoalescingExpression.ets | 31 ++++++++++++ ...tanceOfExpression_relationalExpression.ets | 34 ++++++++++++++ .../instanceOfExpression_statement.ets | 43 +++++++++++++++++ ...stanceOfExpression_stringInterpolation.ets | 29 ++++++++++++ .../instanceOfExpression_switchStatement.ets | 36 ++++++++++++++ .../instanceOfExpression_unaryExpression.ets | 38 +++++++++++++++ .../instanceOfExpression_whileStatement.ets | 38 +++++++++++++++ ...plicativeExpression_additiveExpression.ets | 31 ++++++++++++ ...icativeExpression_assignmentExpression.ets | 30 ++++++++++++ ...ltiplicativeExpression_awaitExpression.ets | 32 +++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 32 +++++++++++++ ...tiplicativeExpression_classInitializer.ets | 32 +++++++++++++ ...iveExpression_conditionalAndExpression.ets | 33 +++++++++++++ ...cativeExpression_conditionalExpression.ets | 33 +++++++++++++ ...tiveExpression_conditionalOrExpression.ets | 33 +++++++++++++ ...plicativeExpression_constantExpression.ets | 30 ++++++++++++ ...plicativeExpression_equalityExpression.ets | 33 +++++++++++++ ...multiplicativeExpression_finallyClause.ets | 40 ++++++++++++++++ ...ultiplicativeExpression_forOfStatement.ets | 36 ++++++++++++++ .../multiplicativeExpression_forStatement.ets | 37 +++++++++++++++ .../multiplicativeExpression_ifStatement.ets | 37 +++++++++++++++ ...tiplicativeExpression_initializerBlock.ets | 35 ++++++++++++++ ...tiplicativeExpression_lambdaExpression.ets | 34 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 36 ++++++++++++++ ...multiplicativeExpression_loopStatement.ets | 41 ++++++++++++++++ ...icativeExpression_namespaceDeclaration.ets | 34 ++++++++++++++ ...tiplicativeExpression_newArrayInstance.ets | 31 ++++++++++++ ...icativeExpression_relationalExpression.ets | 36 ++++++++++++++ ...ltiplicativeExpression_returnStatement.ets | 34 ++++++++++++++ ...ltiplicativeExpression_shiftExpression.ets | 34 ++++++++++++++ .../multiplicativeExpression_statement.ets | 41 ++++++++++++++++ ...licativeExpression_stringInterpolation.ets | 33 +++++++++++++ ...ltiplicativeExpression_switchStatement.ets | 35 ++++++++++++++ ...plicativeExpression_topLevelStatements.ets | 30 ++++++++++++ ...plicativeExpression_trailingLambdaCall.ets | 42 +++++++++++++++++ .../multiplicativeExpression_tryStatement.ets | 37 +++++++++++++++ ...ultiplicativeExpression_whileStatement.ets | 38 +++++++++++++++ ...oalescingExpression_additiveExpression.ets | 32 +++++++++++++ ...lescingExpression_assignmentExpression.ets | 31 ++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 33 +++++++++++++ ...hCoalescingExpression_classInitializer.ets | 31 ++++++++++++ ...ingExpression_conditionalAndExpression.ets | 31 ++++++++++++ ...escingExpression_conditionalExpression.ets | 31 ++++++++++++ ...cingExpression_conditionalOrExpression.ets | 31 ++++++++++++ ...oalescingExpression_constantExpression.ets | 31 ++++++++++++ ...oalescingExpression_equalityExpression.ets | 31 ++++++++++++ ...ishCoalescingExpression_forOfStatement.ets | 34 ++++++++++++++ ...llishCoalescingExpression_forStatement.ets | 35 ++++++++++++++ ...ullishCoalescingExpression_ifStatement.ets | 35 ++++++++++++++ ...hCoalescingExpression_initializerBlock.ets | 33 +++++++++++++ ...hCoalescingExpression_lambdaExpression.ets | 30 ++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 32 +++++++++++++ ...lishCoalescingExpression_loopStatement.ets | 36 ++++++++++++++ ...ingExpression_multiplicativeExpression.ets | 33 +++++++++++++ ...lescingExpression_namespaceDeclaration.ets | 32 +++++++++++++ ...hCoalescingExpression_newArrayInstance.ets | 31 ++++++++++++ ...lescingExpression_relationalExpression.ets | 34 ++++++++++++++ ...shCoalescingExpression_returnStatement.ets | 32 +++++++++++++ ...shCoalescingExpression_shiftExpression.ets | 33 +++++++++++++ .../nullishCoalescingExpression_statement.ets | 41 ++++++++++++++++ ...alescingExpression_stringInterpolation.ets | 29 ++++++++++++ ...shCoalescingExpression_switchStatement.ets | 34 ++++++++++++++ ...oalescingExpression_topLevelStatements.ets | 31 ++++++++++++ ...oalescingExpression_trailingLambdaCall.ets | 40 ++++++++++++++++ ...llishCoalescingExpression_tryStatement.ets | 36 ++++++++++++++ ...shCoalescingExpression_unaryExpression.ets | 36 ++++++++++++++ ...ishCoalescingExpression_whileStatement.ets | 32 +++++++++++++ .../shiftExpression_assignmentExpression.ets | 31 ++++++++++++ .../shiftExpression_awaitExpression.ets | 32 +++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 33 +++++++++++++ .../shiftExpression_classInitializer.ets | 32 +++++++++++++ ...iftExpression_conditionalAndExpression.ets | 33 +++++++++++++ .../shiftExpression_conditionalExpression.ets | 31 ++++++++++++ ...hiftExpression_conditionalOrExpression.ets | 33 +++++++++++++ .../shiftExpression_constantExpression.ets | 30 ++++++++++++ .../shiftExpression_equalityExpression.ets | 30 ++++++++++++ .../shiftExpression_finallyClause.ets | 40 ++++++++++++++++ .../shiftExpression_forOfStatement.ets | 36 ++++++++++++++ .../shiftExpression_forStatement.ets | 37 +++++++++++++++ .../shiftExpression_ifStatement.ets | 37 +++++++++++++++ .../shiftExpression_initializerBlock.ets | 37 +++++++++++++++ .../shiftExpression_lambdaExpression.ets | 34 ++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 36 ++++++++++++++ .../shiftExpression_loopStatement.ets | 41 ++++++++++++++++ .../shiftExpression_namespaceDeclaration.ets | 34 ++++++++++++++ .../shiftExpression_newArrayInstance.ets | 31 ++++++++++++ .../shiftExpression_relationalExpression.ets | 36 ++++++++++++++ .../shiftExpression_returnStatement.ets | 34 ++++++++++++++ .../shiftExpression_statement.ets | 40 ++++++++++++++++ .../shiftExpression_stringInterpolation.ets | 33 +++++++++++++ .../shiftExpression_switchStatement.ets | 35 ++++++++++++++ .../shiftExpression_topLevelStatements.ets | 30 ++++++++++++ .../shiftExpression_trailingLambdaCall.ets | 42 +++++++++++++++++ .../shiftExpression_tryStatement.ets | 38 +++++++++++++++ .../shiftExpression_whileStatement.ets | 38 +++++++++++++++ .../typeOfExpression_additiveExpression.ets | 30 ++++++++++++ .../typeOfExpression_assignmentExpression.ets | 29 ++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 31 ++++++++++++ .../typeOfExpression_classInitializer.ets | 31 ++++++++++++ ...eOfExpression_conditionalAndExpression.ets | 29 ++++++++++++ ...typeOfExpression_conditionalExpression.ets | 30 ++++++++++++ ...peOfExpression_conditionalOrExpression.ets | 29 ++++++++++++ .../typeOfExpression_constantExpression.ets | 29 ++++++++++++ ...fExpression_ensureNotNullishExpression.ets | 29 ++++++++++++ .../typeOfExpression_enumDeclaration.ets | 30 ++++++++++++ .../typeOfExpression_equalityExpression.ets | 29 ++++++++++++ .../typeOfExpression_finallyClause.ets | 40 ++++++++++++++++ .../typeOfExpression_forOfStatement.ets | 33 +++++++++++++ .../typeOfExpression_forStatement.ets | 33 +++++++++++++ ...eOfExpression_functionTypeWithReceiver.ets | 33 +++++++++++++ .../typeOfExpression_ifStatement.ets | 32 +++++++++++++ .../typeOfExpression_initializerBlock.ets | 33 +++++++++++++ .../typeOfExpression_lambdaExpression.ets | 31 ++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 35 ++++++++++++++ .../typeOfExpression_loopStatement.ets | 36 ++++++++++++++ .../typeOfExpression_methodCallExpression.ets | 37 +++++++++++++++ .../typeOfExpression_namespaceDeclaration.ets | 32 +++++++++++++ .../typeOfExpression_newArrayInstance.ets | 29 ++++++++++++ ...Expression_nullishCoalescingExpression.ets | 30 ++++++++++++ .../typeOfExpression_returnStatement.ets | 32 +++++++++++++ .../typeOfExpression_shiftExpression.ets | 31 ++++++++++++ .../typeOfExpression_statement.ets | 39 +++++++++++++++ .../typeOfExpression_stringInterpolation.ets | 29 ++++++++++++ .../typeOfExpression_switchStatement.ets | 33 +++++++++++++ .../typeOfExpression_topLevelStatements.ets | 29 ++++++++++++ .../typeOfExpression_trailingLambdaCall.ets | 39 +++++++++++++++ .../typeOfExpression_tryStatement.ets | 36 ++++++++++++++ .../typeOfExpression_unaryExpression.ets | 36 ++++++++++++++ .../typeOfExpression_whileStatement.ets | 36 ++++++++++++++ .../unaryExpression_additiveExpression.ets | 37 +++++++++++++++ .../unaryExpression_assignmentExpression.ets | 36 ++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 38 +++++++++++++++ .../unaryExpression_classInitializer.ets | 41 ++++++++++++++++ ...aryExpression_conditionalAndExpression.ets | 38 +++++++++++++++ .../unaryExpression_conditionalExpression.ets | 38 +++++++++++++++ ...naryExpression_conditionalOrExpression.ets | 38 +++++++++++++++ .../unaryExpression_constantExpression.ets | 35 ++++++++++++++ .../unaryExpression_equalityExpression.ets | 38 +++++++++++++++ .../unaryExpression_finallyClause.ets | 45 ++++++++++++++++++ .../unaryExpression_forOfStatement.ets | 41 ++++++++++++++++ .../unaryExpression_forStatement.ets | 42 +++++++++++++++++ .../unaryExpression_ifStatement.ets | 42 +++++++++++++++++ .../unaryExpression_initializerBlock.ets | 40 ++++++++++++++++ .../unaryExpression_lambdaExpression.ets | 39 +++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 41 ++++++++++++++++ .../unaryExpression_loopStatement.ets | 46 ++++++++++++++++++ ...aryExpression_multiplicativeExpression.ets | 38 +++++++++++++++ .../unaryExpression_namespaceDeclaration.ets | 39 +++++++++++++++ .../unaryExpression_newArrayInstance.ets | 36 ++++++++++++++ .../unaryExpression_relationalExpression.ets | 41 ++++++++++++++++ .../unaryExpression_returnStatement.ets | 39 +++++++++++++++ .../unaryExpression_shiftExpression.ets | 39 +++++++++++++++ .../unaryExpression_statement.ets | 46 ++++++++++++++++++ .../unaryExpression_stringInterpolation.ets | 38 +++++++++++++++ .../unaryExpression_switchStatement.ets | 40 ++++++++++++++++ .../unaryExpression_topLevelStatements.ets | 36 ++++++++++++++ .../unaryExpression_trailingLambdaCall.ets | 47 +++++++++++++++++++ .../unaryExpression_tryStatement.ets | 43 +++++++++++++++++ .../unaryExpression_whileStatement.ets | 43 +++++++++++++++++ .../ets/ThrowStatementCloneFunction.ets | 4 +- 238 files changed, 8177 insertions(+), 2 deletions(-) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets new file mode 100644 index 0000000000..6e9c5231c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets new file mode 100644 index 0000000000..e202549538 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_awaitExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 + 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..5b86a4e04f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = (1 + 2) & 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets new file mode 100644 index 0000000000..e5f5032cc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 + 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..9f8ddd6a48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalAndExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets new file mode 100644 index 0000000000..9059ac5e41 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..b3d40cd8b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_conditionalOrExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets new file mode 100644 index 0000000000..51538a06d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 3 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets new file mode 100644 index 0000000000..4a1de90063 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = a + 2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets new file mode 100644 index 0000000000..42a9aee1cc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_finallyClause.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = a + 3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets new file mode 100644 index 0000000000..8fabff01ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forOfStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = a + 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets new file mode 100644 index 0000000000..f4b24a9005 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_forStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = a + 3; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets new file mode 100644 index 0000000000..a3f2a9c961 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_ifStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5 + 2; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets new file mode 100644 index 0000000000..e0601572e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_initializerBlock.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let a = 1; + a = a + 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets new file mode 100644 index 0000000000..1fb51941cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..e1085af40f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets new file mode 100644 index 0000000000..aea2b3e367 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_loopStatement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = a + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..921aac3f23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a + 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets new file mode 100644 index 0000000000..300d98ed6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_newArrayInstance.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets new file mode 100644 index 0000000000..b0b7505733 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a + 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets new file mode 100644 index 0000000000..322fd709be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets new file mode 100644 index 0000000000..fd079b18fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a + 2) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets new file mode 100644 index 0000000000..a5c9dec155 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_statement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 2 + 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets new file mode 100644 index 0000000000..36cb5e5f16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_stringInterpolation.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a + 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets new file mode 100644 index 0000000000..ad3ca6f6a7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_switchStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = 3 + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets new file mode 100644 index 0000000000..84406977a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..b1889463ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_trailingLambdaCall.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a + 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets new file mode 100644 index 0000000000..66be2823f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 3 + 2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets new file mode 100644 index 0000000000..5ee5873f13 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/additiveExpression/additiveExpression_whileStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = 3 + 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets new file mode 100644 index 0000000000..04d3898104 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_additiveExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +let result1 = a! + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets new file mode 100644 index 0000000000..0a27e38f71 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_assignmentExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a: number | null = 10; + +let result1 = a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets new file mode 100644 index 0000000000..3d301a7460 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..9932e7ca6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a: number | null = 5; +let c: number = 7; + +let result1 = a! & c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets new file mode 100644 index 0000000000..09c58ac75c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x! + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..de45290849 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > 0 && c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets new file mode 100644 index 0000000000..9a7184a6c3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number | null = 5; + +let result1 = a! > 0 ? a : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..475c0c6b8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > 0 || c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets new file mode 100644 index 0000000000..9d95f0a695 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_constantExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +const result1 = a! + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets new file mode 100644 index 0000000000..d908508165 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 10; +let c: number = 30; + +let result1 = a! == c!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets new file mode 100644 index 0000000000..5a26d71eef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_finallyClause.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let a: number = 10; + let c: number = 30; + let result1 = a! == c!; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets new file mode 100644 index 0000000000..a336e56bfd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forOfStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr!) { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets new file mode 100644 index 0000000000..4449997c33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_forStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +for (; i! < 10; i++) { + if (true) { + let func1: () => void; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets new file mode 100644 index 0000000000..7dccd5febb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_ifStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets new file mode 100644 index 0000000000..bed2329059 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_initializerBlock.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let obj = new A(); + obj! instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets new file mode 100644 index 0000000000..64125adcaf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + const x = a!; + const y = b!; + return x + y; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..b81575e60e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + const x = a!; + const y = b!; + return x + y; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets new file mode 100644 index 0000000000..7055bb3af1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..cc53dd5662 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_multiplicativeExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a: number | null = 10; +let c: number = 30; + +let result1 = a! * c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..d9cca2014f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number | null = 10; + let c: number = 30; + + let result1 = a! * c; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets new file mode 100644 index 0000000000..15e3c1afa6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_newArrayInstance.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; +a! instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..10e8d7a928 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! ?? c > 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets new file mode 100644 index 0000000000..88b604dfc3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number | null = 5; +let c: number = 15; + +let result1 = a! > c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets new file mode 100644 index 0000000000..f91e6d887e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x! + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets new file mode 100644 index 0000000000..0cd4b78b27 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a: number | null = 8; +let c: number = 1; + +let result1 = a! << c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets new file mode 100644 index 0000000000..d51b91c13f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a: number | null = 8; +let c: number = 1; + +let result1 = a! << c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets new file mode 100644 index 0000000000..c7104e37bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name!, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets new file mode 100644 index 0000000000..107982c24d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets new file mode 100644 index 0000000000..d0d4d02359 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +typeof a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..191e71f0a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_trailingLambdaCall.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo2(x: T, y: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); + +a!.methodTwo2("Hi", "HELLO", (result) => { + console.log(result); +}); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets new file mode 100644 index 0000000000..0672f968e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = true; + typeof a!; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets new file mode 100644 index 0000000000..f8e42f3ef6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a: number | null = 1; +a!++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets new file mode 100644 index 0000000000..bf8d34f181 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/ensureNotNullishExpression/ensureNotNullishExpression_whileStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression'!' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets new file mode 100644 index 0000000000..19e2bdb08f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression-tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +class A {} + +function processTwo(a: number): number { + try { + let obj = new A(); + obj instanceof A; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..762ecff14a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) | (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets new file mode 100644 index 0000000000..83c88b7449 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number): number { + return x + 1; + } +} + +let instance1 = new ExampleClass2(); +instance1 instanceof ExampleClass2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..fb991699e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) && (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets new file mode 100644 index 0000000000..a9af5a4f8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) ? true : false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..606065a03c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) || (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets new file mode 100644 index 0000000000..72859d8ea9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_constantExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A {} + +let obj = new A(); +obj instanceof A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..b1e3a14ec8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ensureNotNullishExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A {} + +let obj = new A(); +obj! instanceof A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets new file mode 100644 index 0000000000..fe46b66ea4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) == (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets new file mode 100644 index 0000000000..a68eb16613 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_finallyClause.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A {} + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let obj = new A(); + obj instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets new file mode 100644 index 0000000000..efa0186d7f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A {} + +let obj = new A(); +for (let a = 1; obj instanceof A; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets new file mode 100644 index 0000000000..d39173ba3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_ifStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj instanceof A) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets new file mode 100644 index 0000000000..4537eb3d8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_initializerBlock.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let obj = new A(); + obj instanceof A; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets new file mode 100644 index 0000000000..62b581db2d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj instanceof A) { + let a = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..1d251e7e73 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + class A {} + + let obj = new A(); + obj instanceof A; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets new file mode 100644 index 0000000000..66c02cf48a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_newArrayInstance.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; +a instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..ae9238e513 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A {} + +let obj = new A(); +obj ?? (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets new file mode 100644 index 0000000000..67aff1a619 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A {} + +let obj = new A(); +(obj instanceof A) >= (obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets new file mode 100644 index 0000000000..f7df8c6f37 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_statement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A {} + +{ + let obj = new A(); + obj instanceof A; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets new file mode 100644 index 0000000000..fea63a57fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +name instanceof string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets new file mode 100644 index 0000000000..638b9141f3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_switchStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A {} + +let a = 0; +switch (a) { + case 0: + let obj = new A(); + (obj instanceof A) >= (obj instanceof A); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets new file mode 100644 index 0000000000..b10f87658c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A {} + +let obj = new A(); +!(obj instanceof A); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets new file mode 100644 index 0000000000..7934959c85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/instanceOfExpression/instanceOfExpression_whileStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj instanceof A) { + let $ = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets new file mode 100644 index 0000000000..e3a53d0159 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_additiveExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 2 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets new file mode 100644 index 0000000000..e475fff099 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_assignmentExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets new file mode 100644 index 0000000000..88a9370e4d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_awaitExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 * 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..8a3dd1a35d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = (2 * 3) & 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets new file mode 100644 index 0000000000..5056ce69bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 * 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..54ed43c670 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalAndExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets new file mode 100644 index 0000000000..dd08df244d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..e0b96d1d99 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_conditionalOrExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 3 > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets new file mode 100644 index 0000000000..977fa26101 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_constantExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 3 * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets new file mode 100644 index 0000000000..7e3585ad16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_equalityExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = a * 1.2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets new file mode 100644 index 0000000000..00e2f83a36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_finallyClause.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = 3 * 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets new file mode 100644 index 0000000000..ad2f2b3a96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forOfStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = 3 * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets new file mode 100644 index 0000000000..e668d3fba2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = 3 * 2; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets new file mode 100644 index 0000000000..b317c8a5f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_ifStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = a * 3; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets new file mode 100644 index 0000000000..3eb98e7196 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_initializerBlock.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 1; + a = a *3; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets new file mode 100644 index 0000000000..a6422eecb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a * b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..e6413f8538 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a / b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets new file mode 100644 index 0000000000..5c8c275563 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 10; + a = a % 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..4d16e89c07 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a * 3; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets new file mode 100644 index 0000000000..beff84d563 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets new file mode 100644 index 0000000000..9ab54a8736 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_relationalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (a * 2 > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets new file mode 100644 index 0000000000..c1ea20bbd2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_returnStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x * 2; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets new file mode 100644 index 0000000000..fac64b2dfc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a * 2) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets new file mode 100644 index 0000000000..f7c76b52ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 1; +a * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets new file mode 100644 index 0000000000..fceaa39129 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_stringInterpolation.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a * 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets new file mode 100644 index 0000000000..c1bef385ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = a * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets new file mode 100644 index 0000000000..9dcd7cc795 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_topLevelStatements.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 * 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..d203f8201c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_trailingLambdaCall.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a * 2, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets new file mode 100644 index 0000000000..8fcc44be8f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_tryStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 3 *2; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets new file mode 100644 index 0000000000..1fe9cfed1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/multiplicativeExpression/multiplicativeExpression_whileStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = a * 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets new file mode 100644 index 0000000000..1f554034e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_additiveExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets new file mode 100644 index 0000000000..9deb8b7505 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_assignmentExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..0d74f550da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) & c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets new file mode 100644 index 0000000000..e981233d44 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a: number | null = null; + result1 = this.a ?? 5; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..d6f0ace6ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) && (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets new file mode 100644 index 0000000000..7efb8c4e97 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) ? a : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..bfc799b104 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) || (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets new file mode 100644 index 0000000000..07bbf06eb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_constantExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +const result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets new file mode 100644 index 0000000000..423d1ef252 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = ((a ?? 5) > 0) == (c > 0); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets new file mode 100644 index 0000000000..4f691d811c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forOfStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let a: number | null = null; +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr!) { + let res = a ?? 5; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets new file mode 100644 index 0000000000..ea76c18552 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number | null = null; +for (; (a ?? 5) > 0; i++) { + if (true) { + let func1: () => void; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets new file mode 100644 index 0000000000..953af7e92c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_ifStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let a: number | null = null; +let obj = new A(); +if ((a ?? 5) > 0) { + a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets new file mode 100644 index 0000000000..9a3f4c35f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a: number | null = null; + let result1 = (a ?? 5) + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets new file mode 100644 index 0000000000..3b3c37c1fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + let result1 = (a ?? 5) + 1; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..26320bbbf1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number | null, b: number | undefined): number => { + let result1 = (a ?? 5) + 1; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets new file mode 100644 index 0000000000..737590d858 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_loopStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a: number | null = null; +while((a ?? -5) > 0) { + let a = -1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..01eae8f2eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_multiplicativeExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) * c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..4427091acb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_namespaceDeclaration.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number | null = null; + let result1 = (a ?? 5) + 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets new file mode 100644 index 0000000000..895a06aaa6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let index = 1; +let a = new string[index]; + +a ?? null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets new file mode 100644 index 0000000000..c04f4df797 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) > c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets new file mode 100644 index 0000000000..62ef5b709b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number | null, y?: number, ...numbers: number[]): number { + return x ?? 5; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets new file mode 100644 index 0000000000..c90902509b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a: number | null = 3 >> 2; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets new file mode 100644 index 0000000000..2dd127ab66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets new file mode 100644 index 0000000000..8690b800ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: string | null = 'Alice'; +let result3 = `Hi, ${a ?? "Anonymous"}!`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets new file mode 100644 index 0000000000..26ac9d5e5a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_switchStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let zero: int = 0; +switch (zero) { + case 0: + let a: number | null = 0; + let result1 = (a ?? 5) + 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets new file mode 100644 index 0000000000..61dac631a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_topLevelStatements.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a: number | null = null; +let c: number = 10; + +let result1 = (a ?? 5) + c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..ff3e41022c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +const calculator = new Calculator(); +let a: number | null = null; +let b: number | undefined = undefined; +const result1 = calculator.calculate(a ?? 5, b ?? 10, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets new file mode 100644 index 0000000000..12ec27d359 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a: number | null = null; + let result1 = (a ?? 5) + 1; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets new file mode 100644 index 0000000000..a05f19278f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a: number | null = 0; +let result1 = -(a ?? 5) + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets new file mode 100644 index 0000000000..87e454b9e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/nullishCoalescingExpression/nullishCoalescingExpression_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression'??'expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let a: number | null = null; +while((a ?? -5) > 0) { + let a = -1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets new file mode 100644 index 0000000000..90bb401d19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_assignmentExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1 << 2; +let b = a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets new file mode 100644 index 0000000000..2863bc8d5d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_awaitExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(x: number) {} + +await foo(3 >> 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..0ab5571f54 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 1 >> 2; +a & a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets new file mode 100644 index 0000000000..b165734fce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 >> 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..3599e3f1f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalAndExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result = (a >> 5) && (b << 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets new file mode 100644 index 0000000000..6188de5c1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let result = (a << 2) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..bedca438d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_conditionalOrExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result = (a >> 5) || (b << 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets new file mode 100644 index 0000000000..6baf2393cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_constantExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets new file mode 100644 index 0000000000..f5c79e1618 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_equalityExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let result = 1 >> 2 === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets new file mode 100644 index 0000000000..dfc6617458 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_finallyClause.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + 1 >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets new file mode 100644 index 0000000000..65cbe31330 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forOfStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = 1 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets new file mode 100644 index 0000000000..ccdb8ab85a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = 1 >> 2; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets new file mode 100644 index 0000000000..47fd6fbd33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_ifStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = a << 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets new file mode 100644 index 0000000000..9cb151217e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_initializerBlock.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class A {} + +class Test { + static { + let a = 1; + a = 1 >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets new file mode 100644 index 0000000000..119002f983 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = 1 >> 2; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..5a0215da5c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = 1 >> 2; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets new file mode 100644 index 0000000000..1003cdc3d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = 1 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..bc3b4c4b16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = a >> 2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets new file mode 100644 index 0000000000..cc71ba6510 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0] << 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets new file mode 100644 index 0000000000..5246f67899 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_relationalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ((a >> 2) > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets new file mode 100644 index 0000000000..131934d78c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_returnStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x << 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets new file mode 100644 index 0000000000..5302e9c0b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_statement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 3 >> 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets new file mode 100644 index 0000000000..82b7608335 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_stringInterpolation.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${a << 2}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets new file mode 100644 index 0000000000..1cd87fcfca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a = 3 >> 2; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets new file mode 100644 index 0000000000..fd9496cf09 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_topLevelStatements.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 >> 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..cac8be0617 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_trailingLambdaCall.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(a << 1, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets new file mode 100644 index 0000000000..1589df9f38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 0; + a = a << 3; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets new file mode 100644 index 0000000000..51a01654a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/shiftExpression/shiftExpression_whileStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a = a << 3; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets new file mode 100644 index 0000000000..73bcfbe6c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets new file mode 100644 index 0000000000..b94b227852 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..f2d3cbb2c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 2 & 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets new file mode 100644 index 0000000000..02a4c36772 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class TestClass { + value = 42; + typeOfValue = typeof this.value; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..bbb8732f79 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalAndExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = 2; +typeof a == "number" && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets new file mode 100644 index 0000000000..ccd552ee44 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 2; +let result = true; +typeof a == "number" ? result : result = false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..e632ba2cbd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a = 2; +typeof a == "number" || false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets new file mode 100644 index 0000000000..ccd7b01a26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..fdf081b41c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let a = 2 + 3; +typeof a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets new file mode 100644 index 0000000000..1f2c904ee4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_enumDeclaration.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum C { Red }; +let c: C = C.Red; +typeof c; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets new file mode 100644 index 0000000000..796f799eec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 2; +typeof a == "number" && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets new file mode 100644 index 0000000000..c53bd44706 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_finallyClause.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A {} + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let obj = new A(); + typeof obj; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets new file mode 100644 index 0000000000..a52b06e6f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forOfStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr) { + let a = 2 + 3; + typeof a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets new file mode 100644 index 0000000000..156c3c860b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_forStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let a = 2; +for (let a = 1; typeof a == "number"; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..8dd02b8c79 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_functionTypeWithReceiver.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +type ft = () => string; + +let myFunction: ft = (): string =>{ + return `string`; +}; +const functionType = typeof myFunction; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets new file mode 100644 index 0000000000..cd098adb13 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_ifStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 2; +if (typeof a == "number") { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets new file mode 100644 index 0000000000..c60e4596d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let a = 2 + 3; + typeof a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets new file mode 100644 index 0000000000..c5c3a5cc8a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number, z?: number): Promise => { + let a = 2 + 3; + typeof a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..288fcaa4ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let a = 2 + 3; + typeof a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets new file mode 100644 index 0000000000..1ee39a9d76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_loopStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets new file mode 100644 index 0000000000..fd3b424178 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_methodCallExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; + } +} + +let person = new Person2(); +let result = person.setName(1, 2, 3, 4); +typeof result; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..4c09e10c05 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_namespaceDeclaration.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 2 * 3; + typeof a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets new file mode 100644 index 0000000000..bc10c4a4b4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let b = new string[1]; +typeof b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..9de201eb1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_nullishCoalescingExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: number | null = null; +let resultA = a ?? 10; +typeof resultA === 'number'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets new file mode 100644 index 0000000000..bc66670312 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, $: number): string { + let a = 2 * 3; + let str = typeof a; + return str; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets new file mode 100644 index 0000000000..640de7e6b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 2 >> 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets new file mode 100644 index 0000000000..fce0c4afa5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_statement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 2 * 3; +let result = typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets new file mode 100644 index 0000000000..9fb8120dfa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +typeof name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets new file mode 100644 index 0000000000..d6476c2125 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a) { + case 0: + typeof a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets new file mode 100644 index 0000000000..a966e99011 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..8a8c5ca2cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +const calculator = new Calculator(); +const result = calculator.calculate(5, 10, (x, y) => x + y); +typeof result === 'number'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets new file mode 100644 index 0000000000..5f475d9e4c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = true; + typeof !a; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets new file mode 100644 index 0000000000..9e05d03b56 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = true; +typeof !a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets new file mode 100644 index 0000000000..1ee39a9d76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/typeOfExpression/typeOfExpression_whileStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a == "number") { + let func1: () => void; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets new file mode 100644 index 0000000000..f48fa8ca08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_additiveExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 2; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets new file mode 100644 index 0000000000..9098861fb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_assignmentExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 1; +let b = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..17906b950d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let a = 1 & 2; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets new file mode 100644 index 0000000000..b3b84cd16d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_classInitializer.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + a = 1 + 2; + + constructor() { + this.a++; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..b0da5dd646 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalAndExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets new file mode 100644 index 0000000000..84168b4f38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..2c4f552856 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_conditionalOrExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) || (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets new file mode 100644 index 0000000000..536559cbe1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_constantExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const LOGICAL_NOT_CONSTANT = !false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets new file mode 100644 index 0000000000..0990f112d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_equalityExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = ++a === 6; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets new file mode 100644 index 0000000000..51c19488ad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_finallyClause.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let a: number = 5; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + a = ~a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets new file mode 100644 index 0000000000..97d010f0d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forOfStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +let a: number = 5; +for (item of arr!) { + a = ~a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets new file mode 100644 index 0000000000..4f9f3e826c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_forStatement.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +let a: number = 5; +for (; i! < 10; i++) { + if (true) { + a = ~a; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets new file mode 100644 index 0000000000..554ba6cf8d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_ifStatement.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +let obj = new A(); +if (obj!) { + let a: number = 5; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets new file mode 100644 index 0000000000..82dc22aa0b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_initializerBlock.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 1; + a = ~a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets new file mode 100644 index 0000000000..d53b02d176 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..ee0624d9e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +const processNumbers = (a: number, b: number): number => { + a++; + b = ~b; + return a + b; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets new file mode 100644 index 0000000000..d9656a7340 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_loopStatement.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +let obj = new A(); +while(obj!) { + let a = 1; + a = ~a; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..aeb3f15238 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_multiplicativeExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +let a = 1; +let res = ++a * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..3b4eeab6ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_namespaceDeclaration.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a = 1; + a = ~a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets new file mode 100644 index 0000000000..1dc47a2064 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_newArrayInstance.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let arr: number[] = new Array(5).fill(0); +arr[0]++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets new file mode 100644 index 0000000000..e48d99ee79 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_relationalExpression.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = (++a > 5) && (--b < 10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets new file mode 100644 index 0000000000..845e4da110 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_returnStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return x++; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets new file mode 100644 index 0000000000..b40ff750d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_shiftExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + + +let a = 5; +let res = (a++) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets new file mode 100644 index 0000000000..0373674570 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_statement.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let a = 1; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets new file mode 100644 index 0000000000..6b797e42e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_stringInterpolation.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a: number = 5; +let b: number = 10; + +let result1 = `The value of a after increment is ${++a}`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets new file mode 100644 index 0000000000..806ad71594 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_switchStatement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a!) { + case 0 : + a++; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets new file mode 100644 index 0000000000..988545e746 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_topLevelStatements.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 2 + 3; +a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..0841a478a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_trailingLambdaCall.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class Calculator { + calculate(a: number, b: number, operation: (x: number, y: number) => number): number { + return operation(a, b); + } +} + +let a: number = 5; +let b: number = 10; +const calculator = new Calculator(); +const result1 = calculator.calculate(++a, --b, (x, y) => x + y); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets new file mode 100644 index 0000000000..439d6fc22e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_tryStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a = 0; + a++; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets new file mode 100644 index 0000000000..13473c0a3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/unaryExpression/unaryExpression_whileStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 2; +while(typeof a! == "number") { + a++; + break; +} diff --git a/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets b/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets index dc16545ec6..a17d795587 100644 --- a/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets +++ b/ets2panda/test/runtime/ets/ThrowStatementCloneFunction.ets @@ -14,13 +14,13 @@ */ let error = new Error(); -let p = new Promise((resolve: (value: string) => void, reject: (error: Object) => void) => { +let p = new Promise((resolve: (value: string) => void, reject: (error: Error) => void) => { throw error; }); p.then((value: string): void => { console.log("Test failed. The promise should not be fulfilled."); -}, (err: Object): void => { +}, (err: Error): void => { if (err !== error) { return; } -- Gitee