From 03208046dfae885a74cedeea905c53c4371843e9 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Sun, 27 Apr 2025 11:32:41 +0800 Subject: [PATCH] Submit test cases related to expression characteristics Signed-off-by: liujia178 --- .../expressionList_BigIntLiteral.ets | 29 ++++++++++ .../expressionList_BooleanLiteral.ets | 28 ++++++++++ .../expressionList_FloatLiteral.ets | 30 +++++++++++ .../expressionList_IntegerLiteral.ets | 31 +++++++++++ .../expressionList/expressionList_Literal.ets | 36 +++++++++++++ .../expressionList_MultilineStringLiteral.ets | 28 ++++++++++ .../expressionList_NullLiteral.ets | 28 ++++++++++ .../expressionList_StringLiteral.ets | 29 ++++++++++ .../expressionList_UndefinedLiteral.ets | 28 ++++++++++ .../expressionList_additiveExpression.ets | 29 ++++++++++ .../expressionList_annotationDeclaration.ets | 31 +++++++++++ .../expressionList_annotationUsage.ets | 31 +++++++++++ .../expressionList_arrayLiteral.ets | 28 ++++++++++ .../expressionList_arrayType.ets | 28 ++++++++++ .../expressionList_assignmentExpression.ets | 29 ++++++++++ .../expressionList_awaitExpression.ets | 37 +++++++++++++ ...essionList_bitwiseAndLogicalExpression.ets | 30 +++++++++++ .../expressionList_castExpression.ets | 31 +++++++++++ .../expressionList_classInitializer.ets | 35 ++++++++++++ ...xpressionList_conditionalAndExpression.ets | 29 ++++++++++ .../expressionList_conditionalExpression.ets | 29 ++++++++++ ...expressionList_conditionalOrExpression.ets | 29 ++++++++++ .../expressionList_constantDeclarations.ets | 28 ++++++++++ .../expressionList_constantExpression.ets | 29 ++++++++++ ...ressionList_ensureNotNullishExpression.ets | 29 ++++++++++ .../expressionList_enumDeclaration.ets | 28 ++++++++++ .../expressionList_equalityExpression.ets | 29 ++++++++++ .../expressionList_exportDirective.ets | 31 +++++++++++ .../expressionList_exportTypeDirective.ets | 29 ++++++++++ .../expressionList_expression.ets | 42 +++++++++++++++ .../expressionList_fieldAccessExpression.ets | 32 +++++++++++ .../expressionList_finallyClause.ets | 32 +++++++++++ .../expressionList_forOfStatement.ets | 31 +++++++++++ .../expressionList_forStatement.ets | 32 +++++++++++ .../expressionList_functionCallExpression.ets | 32 +++++++++++ .../expressionList_functionType.ets | 28 ++++++++++ ...xpressionList_functionTypeWithReceiver.ets | 29 ++++++++++ .../expressionList_ifStatement.ets | 31 +++++++++++ .../expressionList_importDirective.ets | 29 ++++++++++ .../expressionList_indexingExpression.ets | 29 ++++++++++ .../expressionList_initializerBlock.ets | 32 +++++++++++ .../expressionList_instanceOfExpression.ets | 29 ++++++++++ .../expressionList_lambdaExpression.ets | 29 ++++++++++ ...ssionList_lambdaExpressionWithReceiver.ets | 31 +++++++++++ .../expressionList_loopStatement.ets | 35 ++++++++++++ .../expressionList_methodCallExpression.ets | 33 ++++++++++++ ...xpressionList_multiplicativeExpression.ets | 31 +++++++++++ .../expressionList_namespaceDeclaration.ets | 31 +++++++++++ .../expressionList_newArrayInstance.ets | 29 ++++++++++ .../expressionList_newExpression.ets | 33 ++++++++++++ ...essionList_nullishCoalescingExpression.ets | 29 ++++++++++ .../expressionList_objectLiteral.ets | 33 ++++++++++++ .../expressionList_objectReference.ets | 41 ++++++++++++++ .../expressionList_optionalParameter.ets | 29 ++++++++++ .../expressionList_parameterList.ets | 31 +++++++++++ ...expressionList_parenthesizedExpression.ets | 28 ++++++++++ .../expressionList_reExportDirective.ets | 28 ++++++++++ .../expressionList_recordLiteral.ets | 31 +++++++++++ .../expressionList_relationalExpression.ets | 32 +++++++++++ .../expressionList_returnStatement.ets | 30 +++++++++++ ...pressionList_separateModuleDeclaration.ets | 28 ++++++++++ .../expressionList_shiftExpression.ets | 31 +++++++++++ .../expressionList_signature.ets | 28 ++++++++++ .../expressionList_spreadExpression.ets | 30 +++++++++++ .../expressionList_statement.ets | 38 +++++++++++++ .../expressionList_stringInterpolation.ets | 29 ++++++++++ .../expressionList_switchStatement.ets | 29 ++++++++++ .../expressionList_thisExpression.ets | 33 ++++++++++++ .../expressionList_throwStatement.ets | 29 ++++++++++ .../expressionList_topDeclaration.ets | 37 +++++++++++++ .../expressionList_topLevelStatements.ets | 28 ++++++++++ .../expressionList_trailingLambdaCall.ets | 39 ++++++++++++++ .../expressionList_tryStatement.ets | 35 ++++++++++++ .../expressionList_tupleType.ets | 28 ++++++++++ .../expressionList_typeAlias.ets | 28 ++++++++++ .../expressionList_typeArguments.ets | 28 ++++++++++ .../expressionList_typeOfExpression.ets | 29 ++++++++++ .../expressionList_unaryExpression.ets | 36 +++++++++++++ .../expressionList_unionType.ets | 28 ++++++++++ .../expressionList_variableDeclarations.ets | 28 ++++++++++ .../expressionList_whileStatement.ets | 32 +++++++++++ .../castExpression_additiveExpression.ets | 30 +++++++++++ .../castExpression_annotationDeclaration.ets | 31 +++++++++++ .../castExpression_assignmentExpression.ets | 30 +++++++++++ .../castExpression_awaitExpression.ets | 33 ++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 31 +++++++++++ .../castExpression_classInitializer.ets | 30 +++++++++++ ...astExpression_conditionalAndExpression.ets | 29 ++++++++++ .../castExpression_conditionalExpression.ets | 29 ++++++++++ ...castExpression_conditionalOrExpression.ets | 29 ++++++++++ .../castExpression_constantExpression.ets | 28 ++++++++++ ...tExpression_ensureNotNullishExpression.ets | 30 +++++++++++ .../castExpression_equalityExpression.ets | 29 ++++++++++ .../castExpression_exportDirective.ets | 33 ++++++++++++ .../castExpression_exportTypeDirective.ets | 29 ++++++++++ .../castExpression_finallyClause.ets | 32 +++++++++++ .../castExpression_forOfStatement.ets | 31 +++++++++++ .../castExpression_forStatement.ets | 32 +++++++++++ .../castExpression_ifStatement.ets | 30 +++++++++++ .../castExpression_importDirective.ets | 29 ++++++++++ .../castExpression_initializerBlock.ets | 32 +++++++++++ .../castExpression_instanceOfExpression.ets | 34 ++++++++++++ .../castExpression_lambdaExpression.ets | 29 ++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 32 +++++++++++ .../castExpression_loopStatement.ets | 35 ++++++++++++ ...astExpression_multiplicativeExpression.ets | 31 +++++++++++ .../castExpression_namespaceDeclaration.ets | 31 +++++++++++ .../castExpression_newArrayInstance.ets | 28 ++++++++++ ...Expression_nullishCoalescingExpression.ets | 29 ++++++++++ .../castExpression_relationalExpression.ets | 32 +++++++++++ .../castExpression_returnStatement.ets | 31 +++++++++++ ...astExpression_selectiveExportDirective.ets | 30 +++++++++++ ...stExpression_separateModuleDeclaration.ets | 28 ++++++++++ .../castExpression_shiftExpression.ets | 31 +++++++++++ .../castExpression_statement.ets | 41 ++++++++++++++ .../castExpression_stringInterpolation.ets | 29 ++++++++++ .../castExpression_switchStatement.ets | 29 ++++++++++ .../castExpression_throwStatement.ets | 29 ++++++++++ .../castExpression_topDeclaration.ets | 37 +++++++++++++ .../castExpression_topLevelStatements.ets | 28 ++++++++++ .../castExpression_trailingLambdaCall.ets | 39 ++++++++++++++ .../castExpression_tryStatement.ets | 35 ++++++++++++ .../castExpression_typeOfExpression.ets | 29 ++++++++++ .../castExpression_unaryExpression.ets | 36 +++++++++++++ .../castExpression_whileStatement.ets | 29 ++++++++++ .../expression_additiveExpression.ets | 43 +++++++++++++++ .../expression_annotationDeclaration.ets | 44 +++++++++++++++ .../expression/expression_annotationUsage.ets | 44 +++++++++++++++ .../expression/expression_arrayLiteral.ets | 41 ++++++++++++++ .../expression_assignmentExpression.ets | 43 +++++++++++++++ .../expression/expression_awaitExpression.ets | 46 ++++++++++++++++ ...expression_bitwiseAndLogicalExpression.ets | 44 +++++++++++++++ .../expression/expression_castExpression.ets | 44 +++++++++++++++ .../expression_classInitializer.ets | 43 +++++++++++++++ .../expression_conditionalAndExpression.ets | 42 +++++++++++++++ .../expression_conditionalExpression.ets | 42 +++++++++++++++ .../expression_conditionalOrExpression.ets | 42 +++++++++++++++ .../expression_constantExpression.ets | 41 ++++++++++++++ .../expression_ensureNotNullishExpression.ets | 43 +++++++++++++++ .../expression_equalityExpression.ets | 42 +++++++++++++++ .../expression/expression_exportDirective.ets | 46 ++++++++++++++++ .../expression_exportTypeDirective.ets | 43 +++++++++++++++ .../expression_fieldAccessExpression.ets | 46 ++++++++++++++++ .../expression/expression_finallyClause.ets | 45 ++++++++++++++++ .../expression/expression_forOfStatement.ets | 44 +++++++++++++++ .../expression/expression_forStatement.ets | 45 ++++++++++++++++ .../expression_functionCallExpression.ets | 46 ++++++++++++++++ .../expression_functionTypeWithReceiver.ets | 43 +++++++++++++++ .../expression/expression_ifStatement.ets | 43 +++++++++++++++ .../expression/expression_importDirective.ets | 42 +++++++++++++++ .../expression_indexingExpression.ets | 42 +++++++++++++++ .../expression_initializerBlock.ets | 45 ++++++++++++++++ .../expression_instanceOfExpression.ets | 47 ++++++++++++++++ .../expression_lambdaExpression.ets | 42 +++++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 44 +++++++++++++++ .../expression/expression_loopStatement.ets | 48 +++++++++++++++++ .../expression_methodCallExpression.ets | 48 +++++++++++++++++ .../expression_multiplicativeExpression.ets | 44 +++++++++++++++ .../expression_namespaceDeclaration.ets | 44 +++++++++++++++ .../expression_newArrayInstance.ets | 41 ++++++++++++++ .../expression/expression_newExpression.ets | 46 ++++++++++++++++ ...expression_nullishCoalescingExpression.ets | 42 +++++++++++++++ .../expression/expression_objectLiteral.ets | 46 ++++++++++++++++ .../expression/expression_objectReference.ets | 54 +++++++++++++++++++ .../expression_parenthesizedExpression.ets | 41 ++++++++++++++ .../expression/expression_recordLiteral.ets | 44 +++++++++++++++ .../expression_relationalExpression.ets | 45 ++++++++++++++++ .../expression/expression_returnStatement.ets | 44 +++++++++++++++ .../expression_selectiveExportDirective.ets | 43 +++++++++++++++ .../expression_separateModuleDeclaration.ets | 41 ++++++++++++++ .../expression/expression_shiftExpression.ets | 44 +++++++++++++++ .../expression_spreadExpression.ets | 43 +++++++++++++++ .../expression/expression_statement.ets | 54 +++++++++++++++++++ .../expression_stringInterpolation.ets | 42 +++++++++++++++ .../expression/expression_switchStatement.ets | 42 +++++++++++++++ .../expression/expression_thisExpression.ets | 48 +++++++++++++++++ .../expression/expression_throwStatement.ets | 42 +++++++++++++++ .../expression/expression_topDeclaration.ets | 50 +++++++++++++++++ .../expression_topLevelStatements.ets | 41 ++++++++++++++ .../expression_trailingLambdaCall.ets | 52 ++++++++++++++++++ .../expression/expression_tryStatement.ets | 48 +++++++++++++++++ .../expression_typeOfExpression.ets | 42 +++++++++++++++ .../expression/expression_unaryExpression.ets | 49 +++++++++++++++++ .../expression/expression_whileStatement.ets | 42 +++++++++++++++ .../indexingExpression_additiveExpression.ets | 30 +++++++++++ ...ndexingExpression_assignmentExpression.ets | 30 +++++++++++ .../indexingExpression_awaitExpression.ets | 29 ++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 31 +++++++++++ .../indexingExpression_castExpression.ets | 29 ++++++++++ .../indexingExpression_classInitializer.ets | 31 +++++++++++ ...ingExpression_conditionalAndExpression.ets | 29 ++++++++++ ...dexingExpression_conditionalExpression.ets | 29 ++++++++++ ...xingExpression_conditionalOrExpression.ets | 29 ++++++++++ .../indexingExpression_constantExpression.ets | 29 ++++++++++ ...gExpression_ensureNotNullishExpression.ets | 29 ++++++++++ .../indexingExpression_equalityExpression.ets | 29 ++++++++++ .../indexingExpression_finallyClause.ets | 33 ++++++++++++ .../indexingExpression_forOfStatement.ets | 32 +++++++++++ .../indexingExpression_forStatement.ets | 31 +++++++++++ .../indexingExpression_ifStatement.ets | 34 ++++++++++++ .../indexingExpression_initializerBlock.ets | 33 ++++++++++++ ...ndexingExpression_instanceOfExpression.ets | 29 ++++++++++ .../indexingExpression_lambdaExpression.ets | 32 +++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 35 ++++++++++++ .../indexingExpression_loopStatement.ets | 35 ++++++++++++ ...ingExpression_multiplicativeExpression.ets | 31 +++++++++++ ...ndexingExpression_namespaceDeclaration.ets | 33 ++++++++++++ .../indexingExpression_newArrayInstance.ets | 29 ++++++++++ ...Expression_nullishCoalescingExpression.ets | 30 +++++++++++ ...ndexingExpression_relationalExpression.ets | 32 +++++++++++ .../indexingExpression_returnStatement.ets | 31 +++++++++++ ...ngExpression_separateModuleDeclaration.ets | 28 ++++++++++ .../indexingExpression_shiftExpression.ets | 31 +++++++++++ .../indexingExpression_statement.ets | 41 ++++++++++++++ ...indexingExpression_stringInterpolation.ets | 29 ++++++++++ .../indexingExpression_switchStatement.ets | 34 ++++++++++++ .../indexingExpression_throwStatement.ets | 30 +++++++++++ .../indexingExpression_topDeclaration.ets | 37 +++++++++++++ .../indexingExpression_trailingLambdaCall.ets | 44 +++++++++++++++ .../indexingExpression_tryStatement.ets | 35 ++++++++++++ .../indexingExpression_typeOfExpression.ets | 29 ++++++++++ .../indexingExpression_unaryExpression.ets | 36 +++++++++++++ .../indexingExpression_whileStatement.ets | 32 +++++++++++ .../newExpression_additiveExpression.ets | 33 ++++++++++++ .../newExpression_assignmentExpression.ets | 34 ++++++++++++ .../newExpression_awaitExpression.ets | 36 +++++++++++++ .../newExpression_castExpression.ets | 31 +++++++++++ .../newExpression_classInitializer.ets | 31 +++++++++++ ...newExpression_conditionalAndExpression.ets | 31 +++++++++++ .../newExpression_conditionalExpression.ets | 31 +++++++++++ .../newExpression_conditionalOrExpression.ets | 31 +++++++++++ .../newExpression_constantExpression.ets | 33 ++++++++++++ ...wExpression_ensureNotNullishExpression.ets | 33 ++++++++++++ .../newExpression_equalityExpression.ets | 34 ++++++++++++ .../newExpression_finallyClause.ets | 37 +++++++++++++ .../newExpression_ifStatement.ets | 32 +++++++++++ .../newExpression_initializerBlock.ets | 33 ++++++++++++ .../newExpression_instanceOfExpression.ets | 30 +++++++++++ .../newExpression_lambdaExpression.ets | 31 +++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 33 ++++++++++++ .../newExpression_loopStatement.ets | 38 +++++++++++++ ...newExpression_multiplicativeExpression.ets | 35 ++++++++++++ .../newExpression_namespaceDeclaration.ets | 34 ++++++++++++ ...Expression_nullishCoalescingExpression.ets | 32 +++++++++++ .../newExpression_returnStatement.ets | 33 ++++++++++++ .../newExpression/newExpression_statement.ets | 44 +++++++++++++++ .../newExpression_stringInterpolation.ets | 33 ++++++++++++ .../newExpression_switchStatement.ets | 35 ++++++++++++ .../newExpression_topDeclaration.ets | 38 +++++++++++++ .../newExpression_topLevelStatements.ets | 29 ++++++++++ .../newExpression_trailingLambdaCall.ets | 39 ++++++++++++++ .../newExpression_tryStatement.ets | 36 +++++++++++++ .../newExpression_typeOfExpression.ets | 29 ++++++++++ .../newExpression_unaryExpression.ets | 36 +++++++++++++ .../newExpression_whileStatement.ets | 31 +++++++++++ .../thisExpression_additiveExpression.ets | 39 ++++++++++++++ .../thisExpression_assignmentExpression.ets | 35 ++++++++++++ .../thisExpression_awaitExpression.ets | 39 ++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 36 +++++++++++++ .../thisExpression_castExpression.ets | 35 ++++++++++++ ...hisExpression_conditionalAndExpression.ets | 34 ++++++++++++ .../thisExpression_conditionalExpression.ets | 34 ++++++++++++ ...thisExpression_conditionalOrExpression.ets | 34 ++++++++++++ .../thisExpression_constantExpression.ets | 34 ++++++++++++ ...sExpression_ensureNotNullishExpression.ets | 34 ++++++++++++ .../thisExpression_equalityExpression.ets | 34 ++++++++++++ .../thisExpression_fieldAccessExpression.ets | 35 ++++++++++++ .../thisExpression_forOfStatement.ets | 38 +++++++++++++ .../thisExpression_forStatement.ets | 36 +++++++++++++ ...hisExpression_functionTypeWithReceiver.ets | 30 +++++++++++ .../thisExpression_ifStatement.ets | 37 +++++++++++++ .../thisExpression_indexingExpression.ets | 35 ++++++++++++ .../thisExpression_instanceOfExpression.ets | 34 ++++++++++++ .../thisExpression_lambdaExpression.ets | 31 +++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 32 +++++++++++ .../thisExpression_loopStatement.ets | 40 ++++++++++++++ ...hisExpression_multiplicativeExpression.ets | 36 +++++++++++++ ...Expression_nullishCoalescingExpression.ets | 34 ++++++++++++ .../thisExpression_relationalExpression.ets | 37 +++++++++++++ .../thisExpression_returnStatement.ets | 34 ++++++++++++ .../thisExpression_shiftExpression.ets | 36 +++++++++++++ .../thisExpression_statement.ets | 44 +++++++++++++++ .../thisExpression_stringInterpolation.ets | 34 ++++++++++++ .../thisExpression_switchStatement.ets | 40 ++++++++++++++ .../thisExpression_throwStatement.ets | 35 ++++++++++++ .../thisExpression_tryStatement.ets | 38 +++++++++++++ .../thisExpression_typeOfExpression.ets | 34 ++++++++++++ .../thisExpression_unaryExpression.ets | 47 ++++++++++++++++ .../thisExpression_whileStatement.ets | 36 +++++++++++++ 289 files changed, 10012 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets new file mode 100644 index 0000000000..d805ee30e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BigIntLiteral.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.4 + * BigIntLiteral: + * '0n' + * | [1-9] ('_'? [0-9])* 'n' + * ; + */ + +let a = 153n; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets new file mode 100644 index 0000000000..42f909954d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_BooleanLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.5 + * BooleanLiteral: + * 'true' | 'false' + * ; + */ + +let a = true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets new file mode 100644 index 0000000000..1c23784557 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_FloatLiteral.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.3 + * FloatLiteral: + * DecimalIntegerLiteral '.' FractionalPart? ExponentPart? FloatTypeSuffix? + * | '.'FractionalPart ExponentPart? FloatTypeSuffix? + * | DecimalIntegerLiteral ExponentPart FloatTypeSuffix? + * ; + */ + +let x = 1.1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets new file mode 100644 index 0000000000..21b0f7c501 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_IntegerLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets new file mode 100644 index 0000000000..c862ea9992 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_Literal.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + */ + +let x = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets new file mode 100644 index 0000000000..91842ae991 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_MultilineStringLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * '`' (BacktickCharacter)* '`' + * ; + */ + +let x = `This is a multi-line string literal.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets new file mode 100644 index 0000000000..c18eda7458 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_NullLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + */ + +let x = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets new file mode 100644 index 0000000000..d8059d2b1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_StringLiteral.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + */ + +let x = "Hello, ArkTS!"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets new file mode 100644 index 0000000000..c3582dd853 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_UndefinedLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let x = undefined; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets new file mode 100644 index 0000000000..e7be79a83d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_additiveExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +1 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets new file mode 100644 index 0000000000..2566a36dfd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + name: string; + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets new file mode 100644 index 0000000000..8507787089 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_annotationUsage.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets new file mode 100644 index 0000000000..3f406c674a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let a = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets new file mode 100644 index 0000000000..42b6d38d07 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_arrayType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let a: number[] = [0, 0, 0, 0, 0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets new file mode 100644 index 0000000000..3cab3c1e38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; +a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets new file mode 100644 index 0000000000..7d17177b82 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_awaitExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function fetchData(): Promise { + return new Promise((resolve) => { + setTimeout(() => resolve(42), 100); + }); +} + +async function processData() { + const result = await fetchData(); + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..b3d33ca805 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_bitwiseAndLogicalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +1 & 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets new file mode 100644 index 0000000000..6c28ba02d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_castExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let x1: X = new X(); +let a: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets new file mode 100644 index 0000000000..11db111655 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = false; + static initializerBlock() { + if (!A.initialized) { + A.initialized = true; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets new file mode 100644 index 0000000000..103fb960d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalAndExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = true; +a && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets new file mode 100644 index 0000000000..7c80db9346 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 5; +(a > 5) ? a : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets new file mode 100644 index 0000000000..7df774b501 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x = true; +x || false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets new file mode 100644 index 0000000000..1be6bdc438 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantDeclarations.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const x: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets new file mode 100644 index 0000000000..cc952ef9f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let a = 5; +const x = a + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..06cc0d3c9b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let x: string | null = "Hello"; +x!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets new file mode 100644 index 0000000000..9f4af9e9b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_enumDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 11 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +const enum Color { Red = 0, Green = 1, Blue = 2 } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets new file mode 100644 index 0000000000..2a779ae16c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let x = 5; +x == 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets new file mode 100644 index 0000000000..688497c9ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportDirective.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +export let version = "1.0.0"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets new file mode 100644 index 0000000000..5703f8df2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_exportTypeDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} +export type MyA = A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets new file mode 100644 index 0000000000..605199d3dd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_expression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +let x = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets new file mode 100644 index 0000000000..f64a6a29b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_fieldAccessExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let x = new Person(); +x.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets new file mode 100644 index 0000000000..4077a6935c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_finallyClause.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets new file mode 100644 index 0000000000..56da9cbc23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let x of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets new file mode 100644 index 0000000000..c32a904cec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_forStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let x = 1; x < 10; x++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets new file mode 100644 index 0000000000..6f216daac5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let x: Person | null = null; +x?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets new file mode 100644 index 0000000000..6c2565834c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.19 + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + */ + +let x: (x: number, y: number) => number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..6bd2a1af3a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_functionTypeWithReceiver.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class x {} +type FA = (this: x) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets new file mode 100644 index 0000000000..9f503c9658 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + let x = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets new file mode 100644 index 0000000000..af0049acdf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_importDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './expressionList_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets new file mode 100644 index 0000000000..1b5ac3390f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_indexingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const x: number[] | null = null; +x?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets new file mode 100644 index 0000000000..072873de7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let x = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets new file mode 100644 index 0000000000..21a02d5655 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let x: string = new String("Hello"); +x instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets new file mode 100644 index 0000000000..41dd8e00dd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(x: number): number => { return Math.sin(x) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..dae05e414f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class x {} +let result1 = (this: x) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets new file mode 100644 index 0000000000..f9be6b692c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let x = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets new file mode 100644 index 0000000000..55644781c7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_methodCallExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number) {} +} + +let x = new MyClass(); +x.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets new file mode 100644 index 0000000000..35bc2e26eb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_multiplicativeExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x = 5; +x * 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets new file mode 100644 index 0000000000..041b42a5f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace x { + let a: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets new file mode 100644 index 0000000000..dab7744817 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let x = 1; +let a = new string[x]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets new file mode 100644 index 0000000000..bd5464bb7c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_newExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class x { + constructor(p: number) {} +} + +let instance = new x(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..6303677291 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let x: string | null = "Hello"; +x ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets new file mode 100644 index 0000000000..d3910155d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectLiteral.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} + +let x: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets new file mode 100644 index 0000000000..da5cf8dbb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_objectReference.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class x extends BaseClass { + constructor() { + super(); + } +} + +let instance = new x(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets new file mode 100644 index 0000000000..fe1cf1cd5a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_optionalParameter.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier'?' ':' type + * ; + */ + +function x(x: number, y: number = 7) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets new file mode 100644 index 0000000000..1df668b494 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parameterList.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function x(name: string = ""): string { + return "name"; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets new file mode 100644 index 0000000000..ca3463ce8a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_parenthesizedExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let x = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets new file mode 100644 index 0000000000..8509190b2e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_reExportDirective.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.9.4 + * reExportDirective: + * 'export' ('*' | selectiveBindings) 'from' importPath + * ; + */ + +export { version } from "./expressionList_exportDirective"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets new file mode 100644 index 0000000000..562184b309 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_recordLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let x: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets new file mode 100644 index 0000000000..0a7277cdf5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x = 5; +x < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets new file mode 100644 index 0000000000..e04313492c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_returnStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, x: number) { + return number1 + x; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets new file mode 100644 index 0000000000..d7d6b0cc64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_separateModuleDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets new file mode 100644 index 0000000000..94df4fc49a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let x = 5; +x << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets new file mode 100644 index 0000000000..d3ae48a0d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_signature.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +function test(x: number, y: number = 1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets new file mode 100644 index 0000000000..fc4ba52ddf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_spreadExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let x = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets new file mode 100644 index 0000000000..77fdf3197e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets new file mode 100644 index 0000000000..1a983d53d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let x = "Alice"; +`Hello, my name is ${x}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets new file mode 100644 index 0000000000..3d552ea8e6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 0; +switch (x) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets new file mode 100644 index 0000000000..fa7e98200a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_thisExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class x { + name: string; + constructor(name: string) { + this.name = "name"; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets new file mode 100644 index 0000000000..273b49f45a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let x = new Error("err"); +throw x; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets new file mode 100644 index 0000000000..04f62eb660 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const x = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets new file mode 100644 index 0000000000..b56c709616 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type x = number | string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets new file mode 100644 index 0000000000..7bc17e50b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + x(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.x("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets new file mode 100644 index 0000000000..88e5ebd9c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const x = 1; + return x; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets new file mode 100644 index 0000000000..aa33041125 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_tupleType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let x: [number, number, string, boolean, Object] = [6, 7, "abc", true, 666]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets new file mode 100644 index 0000000000..871680d0a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeAlias.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters? '=' type + * ; + */ + +type x = string | number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets new file mode 100644 index 0000000000..57ecd2db39 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeArguments.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +let a = new Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets new file mode 100644 index 0000000000..f359063221 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let x: number = 1; +typeof x; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets new file mode 100644 index 0000000000..7fa8548e2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let x = 5; +x++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets new file mode 100644 index 0000000000..d49757b2fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_unionType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +type x = int | double; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets new file mode 100644 index 0000000000..5233838874 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_variableDeclarations.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let x: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets new file mode 100644 index 0000000000..5fc8c538ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/1_introduction/expressionList/expressionList_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 1.2 + * expressionList: + * expression (',' expression)* ','? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let x = 5; +let n = 3; +while(x < n) { + x--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets new file mode 100644 index 0000000000..fcb2d7f189 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let x1 = 1.0; +x1 as number + x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets new file mode 100644 index 0000000000..e517eae869 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_annotationDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface X { + name: string; + value: number = 10 as number; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets new file mode 100644 index 0000000000..06852d947a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_assignmentExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let x1 = 1.0; +x1 += x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets new file mode 100644 index 0000000000..3b5934cd72 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function testAwait() { + let x1 = 1.0; + let promise = Promise.resolve(x1); + let result = await promise as Promise; + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..87e27e2c6e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let x1 = 1.0; +x1 as number & x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets new file mode 100644 index 0000000000..4244f87fd2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_classInitializer.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = 1.0 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..955a131a5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalAndExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let x1 = 1.0; +x1 as number && x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets new file mode 100644 index 0000000000..114f0daf3a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let x1 = 1.0; +(6 > 5) ? x1 as number : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..9859391327 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x1 = 1.0; +x1 as number || x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets new file mode 100644 index 0000000000..849cc16b70 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const a = 5 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..9803308601 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ensureNotNullishExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let nullable: number | null = 5; +let nonNull = nullable!; +let castedNonNull = (nullable as number)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets new file mode 100644 index 0000000000..b3604d45f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 5; +a != 10 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets new file mode 100644 index 0000000000..6d43d3245b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportDirective.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets new file mode 100644 index 0000000000..d23d3f0d82 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_exportTypeDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} +export type { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets new file mode 100644 index 0000000000..4c7f77362f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_finallyClause.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets new file mode 100644 index 0000000000..e64dc83fdd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr as Array) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets new file mode 100644 index 0000000000..59e472a72b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_forStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1 as number; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets new file mode 100644 index 0000000000..b61744de57 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_ifStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1.0; +if (a as number) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets new file mode 100644 index 0000000000..ef7194bc98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_importDirective.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './castExpression_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets new file mode 100644 index 0000000000..95a1d82af6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0 as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..85156a1644 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_instanceOfExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Base {} + +class Derived extends Base {} + +let obj = new Derived(); +let baseObj = obj as Base; +let isBase = baseObj instanceof Base; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets new file mode 100644 index 0000000000..9bb6ca40cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: number): number => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..ac59a52ead --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets new file mode 100644 index 0000000000..b896162d52 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..00fed51a9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_multiplicativeExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x1 = 1.0; +x1 as number * x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..dc9717ec60 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a = 10 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets new file mode 100644 index 0000000000..580bfad89c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_newArrayInstance.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +new number[2][2] as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..b4f7120ee7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +a ?? "0" as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets new file mode 100644 index 0000000000..0234c58279 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x1 = 1.0; +x1 as number <= x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets new file mode 100644 index 0000000000..2f7e684f25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +let a = 1; +function add(number1: number, number2: number) { + return a as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets new file mode 100644 index 0000000000..9d12c9219c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_selectiveExportDirective.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.9.1 + * selectiveExportDirective: + * 'export' selectiveBindings + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000..8fd7cbf385 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_separateModuleDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets new file mode 100644 index 0000000000..168e24ca40 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 5; +(a as number) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets new file mode 100644 index 0000000000..f8e2e31c5c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets new file mode 100644 index 0000000000..258af8bf5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a = "Alice"; +`Hello, my name is ${a}.` as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets new file mode 100644 index 0000000000..dc62722f0f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a as int) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets new file mode 100644 index 0000000000..4361e25418 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let a = new Error(); +throw a as Error; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets new file mode 100644 index 0000000000..9391d524be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const a = 3 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets new file mode 100644 index 0000000000..0e8a226cb3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..04776fcf63 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test("Hi" as string) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets new file mode 100644 index 0000000000..9fb0919cc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = 1 as number; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets new file mode 100644 index 0000000000..dd856d764c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let a = 1.0; +typeof (a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets new file mode 100644 index 0000000000..e41ad018f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +!(a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets new file mode 100644 index 0000000000..e2975246cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/castExpression/castExpression_whileStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let n = 3; +while((1 as number) < n) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets new file mode 100644 index 0000000000..6608202a4f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_additiveExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let x1 = 1.0; +x1 as number + x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets new file mode 100644 index 0000000000..73f6ed1696 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationDeclaration.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface X { + name: string; + value: number = 10 as number; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets new file mode 100644 index 0000000000..789501b7fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_annotationUsage.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface ClassPreamble { + authorName: string; + revision: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets new file mode 100644 index 0000000000..95824e5347 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_arrayLiteral.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let arr1 = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets new file mode 100644 index 0000000000..809ad5bd66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_assignmentExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let x1 = 1.0; +x1 += x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets new file mode 100644 index 0000000000..55bc5cbd83 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_awaitExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function testAwait() { + let x1 = 1.0; + let promise = Promise.resolve(x1); + let result = await promise as Promise; + return result; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..0745a72361 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let x1 = 1.0; +x1 as number & x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets new file mode 100644 index 0000000000..f537e701ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_castExpression.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let x1: X = new X(); +let a: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets new file mode 100644 index 0000000000..646942d0a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_classInitializer.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = 1.0 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets new file mode 100644 index 0000000000..65f39451f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalAndExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let x1 = 1.0; +x1 as number && x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets new file mode 100644 index 0000000000..8ab2080807 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let x1 = 1.0; +(6 > 5) ? x1 as number : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets new file mode 100644 index 0000000000..b04107b8c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_conditionalOrExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let x1 = 1.0; +x1 as number || x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets new file mode 100644 index 0000000000..b6b94e2b96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_constantExpression.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const a = 5 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..05e5ba3606 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ensureNotNullishExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let nullable: number | null = 5; +let nonNull = nullable!; +let castedNonNull = (nullable as number)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets new file mode 100644 index 0000000000..4ffa1c2161 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_equalityExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 5; +a != 10 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets new file mode 100644 index 0000000000..b145722521 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportDirective.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets new file mode 100644 index 0000000000..2ed01d7cef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_exportTypeDirective.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + */ + +class A {} + +export type { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets new file mode 100644 index 0000000000..03f90c1032 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_fieldAccessExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} + +let a = new Person(); +a.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets new file mode 100644 index 0000000000..9fe182ba61 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_finallyClause.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets new file mode 100644 index 0000000000..d62c3eebc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forOfStatement.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr as Array) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets new file mode 100644 index 0000000000..968243fb66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_forStatement.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1 as number; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets new file mode 100644 index 0000000000..205a652781 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionCallExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} + +let p: Person | null = null; +let a = p?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..60d1dfb511 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_functionTypeWithReceiver.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} + +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets new file mode 100644 index 0000000000..b164b397ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_ifStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let a = 1.0; +if (a as number) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets new file mode 100644 index 0000000000..036e7ad470 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_importDirective.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import * as number from './expression_ifStatement'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets new file mode 100644 index 0000000000..a26fdf98d7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_indexingExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const a: number[] | null = null; +let value = a?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets new file mode 100644 index 0000000000..cf735de084 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_initializerBlock.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0 as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets new file mode 100644 index 0000000000..849992d0c8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_instanceOfExpression.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Base {} + +class Derived extends Base {} + +let obj = new Derived(); +let baseObj = obj as Base; +let isBase = baseObj instanceof Base; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets new file mode 100644 index 0000000000..0f7eed87e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: number): number => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..05298b40f1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result = (this: A) => { let b = 1.0 as number }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets new file mode 100644 index 0000000000..357befacaf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_loopStatement.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets new file mode 100644 index 0000000000..cb73997175 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_methodCallExpression.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): number { + return 0; + } +} + +let a = new MyClass(); +let value = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets new file mode 100644 index 0000000000..060b9aca98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_multiplicativeExpression.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let x1 = 1.0; +x1 as number * x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets new file mode 100644 index 0000000000..dfb07aa09f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_namespaceDeclaration.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a = 10 as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets new file mode 100644 index 0000000000..d18c99a919 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newArrayInstance.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +new number[2][2] as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets new file mode 100644 index 0000000000..6b3a515d1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_newExpression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class A { + constructor(p: number) {} +} + +let instance = new A(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..d113daf8a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_nullishCoalescingExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +a ?? "0" as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets new file mode 100644 index 0000000000..0f0c936d43 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectLiteral.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} + +let a: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets new file mode 100644 index 0000000000..62f8637bf2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_objectReference.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class A extends BaseClass { + constructor() { + super(); + } +} + +let instance = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets new file mode 100644 index 0000000000..a146a6bb42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_parenthesizedExpression.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let a = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets new file mode 100644 index 0000000000..ce8866e75a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_recordLiteral.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let a: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets new file mode 100644 index 0000000000..15a9e9b895 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_relationalExpression.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let x1 = 1.0; +x1 as number <= x1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets new file mode 100644 index 0000000000..c17add5209 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_returnStatement.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +let a = 1; +function add(number1: number, number2: number) { + return a as number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets new file mode 100644 index 0000000000..ab47925bdd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_selectiveExportDirective.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.9.1 + * selectiveExportDirective: + * 'export' selectiveBindings + * ; + */ + +class A {} + +export { A as Object }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets new file mode 100644 index 0000000000..1cb8111028 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_separateModuleDeclaration.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets new file mode 100644 index 0000000000..eb446b3636 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_shiftExpression.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let a = 5; +(a as number) << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets new file mode 100644 index 0000000000..80992f14d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_spreadExpression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let a = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets new file mode 100644 index 0000000000..65c5174614 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_statement.ets @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let a = 1 as number; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets new file mode 100644 index 0000000000..b3f23e807b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_stringInterpolation.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let a = "Alice"; +`Hello, my name is ${a}.` as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets new file mode 100644 index 0000000000..9c19f4faa0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_switchStatement.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a as int) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets new file mode 100644 index 0000000000..b1d8d6e384 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_thisExpression.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + } +} + +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets new file mode 100644 index 0000000000..dce43d2f07 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_throwStatement.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let a = new Error(); +throw a as Error; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets new file mode 100644 index 0000000000..724c6dea1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topDeclaration.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export default const a = 3 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets new file mode 100644 index 0000000000..a16d0805f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_topLevelStatements.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a = 1 as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets new file mode 100644 index 0000000000..b61c79076a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_trailingLambdaCall.ets @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test("Hi" as string) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets new file mode 100644 index 0000000000..42c211cd9a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_tryStatement.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = 1 as number; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets new file mode 100644 index 0000000000..884f9752be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_typeOfExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let a = 1.0; +typeof (a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets new file mode 100644 index 0000000000..bd4cf8f8b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_unaryExpression.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +!(a as number); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets new file mode 100644 index 0000000000..8d19648a1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/expression/expression_whileStatement.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | awaitExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let n = 3; +while((1 as number) < n) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets new file mode 100644 index 0000000000..1d1057616f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +let secondNumber = numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets new file mode 100644 index 0000000000..b094ee3483 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_assignmentExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] += numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets new file mode 100644 index 0000000000..aacb2824c7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_awaitExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +await Promise.resolve(numbers[1 + 1]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..47b8041fa7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] & numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets new file mode 100644 index 0000000000..a4651aada9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_castExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] as number; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets new file mode 100644 index 0000000000..e510323ad6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static numbers = [10, 20, 30, 40, 50]; + static initialized = A.numbers[1 + 1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..66434ab762 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalAndExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] && numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets new file mode 100644 index 0000000000..19d3e6a089 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] ? numbers[1 + 1] : numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..c69ef61913 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] || numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets new file mode 100644 index 0000000000..b0d981c530 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +const value = numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..be448f431a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1]!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets new file mode 100644 index 0000000000..6e021612ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1 + 1] == 30; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets new file mode 100644 index 0000000000..c381e56536 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_finallyClause.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +try { +} catch (error) { +} finally { + numbers[1 + 1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets new file mode 100644 index 0000000000..7820392dc5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forOfStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let nestedNumbers = [[1, 2], [3, 4], [5, 6]]; +for (let subArray of nestedNumbers[1]) { // nestedNumbers[1]是[3, 4] + console.log(subArray); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets new file mode 100644 index 0000000000..28a6d8b527 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_forStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +for (let value = numbers[1 + 1]; value < 60; value++) { + console.log(value); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets new file mode 100644 index 0000000000..ba288e5ca8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_ifStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +if (numbers[1 + 1] == 30) { + console.log("The value is 30"); +} else { + console.log("The value is not 30"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets new file mode 100644 index 0000000000..20156596be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let numbers = [10, 20, 30, 40, 50]; + numbers[1 + 1] == 30; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..ba24d37490 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let numbers = ["name", "age"]; +numbers[1 + 0] instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets new file mode 100644 index 0000000000..ec594c32d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(test: number): number => { + let numbers = [0, 1]; + return numbers[1 + 0]; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..5937e8feb2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { + let numbers = [0, 1]; + return numbers[1 + 0]; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets new file mode 100644 index 0000000000..7ece07eec8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let numbers = [0, 1]; + let value = numbers[1 + 0]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..3a63d6da85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_multiplicativeExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let numbers = [0, 1]; +let value = numbers[1 + 0] * numbers[1 + 0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..92ff9a23c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let numbers = [10, 20, 30, 40, 50]; + let value = numbers[1 + 1] * numbers[0]; + console.log(value); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets new file mode 100644 index 0000000000..d97d0c25d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let value = 1; +let a = new string[value + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..118553c671 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_nullishCoalescingExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let test: string | null = "Hello"; +let numbers = [10, 20, 30, 40, 50]; +test ?? numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets new file mode 100644 index 0000000000..0947dea0b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1] < numbers[1 + 1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets new file mode 100644 index 0000000000..e263f8b91e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add() { + let numbers = [10, 20, 30, 40, 50]; + return numbers[0] + numbers[1]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets new file mode 100644 index 0000000000..348830b6d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_separateModuleDeclaration.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a = new string[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets new file mode 100644 index 0000000000..08a7da8b76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_shiftExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let numbers = [10, 20, 30, 40, 50]; +numbers[1] << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets new file mode 100644 index 0000000000..25657035fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +while(true) { + let numbers = [0, 1]; + let value = numbers[1 + 0]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets new file mode 100644 index 0000000000..c559763b9d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let numbers = ["0", "1"]; +numbers[1] = `Hello, my name is ${numbers[1]}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets new file mode 100644 index 0000000000..5bb780cd2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_switchStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch (a) { + case 0: + let numbers = [0, 1]; + let value = numbers[1 + 0]; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets new file mode 100644 index 0000000000..b957c5fac5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_throwStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let numbers = [0, 1]; +let test = new Error("An error occurred" + numbers[1 + 0]); +throw test; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets new file mode 100644 index 0000000000..cf7c692b80 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let a = new string[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..3233ef61be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_trailingLambdaCall.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +let numbers = [0, 1]; +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +let a = new A(); +a.test(numbers[1 + 0]) { + (result: number) => { + console.log(result); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets new file mode 100644 index 0000000000..adb04b9b46 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let numbers = [0, 1]; + return numbers[1]; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets new file mode 100644 index 0000000000..1c973f32c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let numbers = [0, 1]; +typeof numbers[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets new file mode 100644 index 0000000000..ffb65b3605 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let numbers = [0, 1]; +++numbers[1]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets new file mode 100644 index 0000000000..2d4ab6818a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/indexingExpression/indexingExpression_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let numbers = [0, 1]; +let n = 3; +while(numbers[1] < n) { + numbers[1]--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets new file mode 100644 index 0000000000..848e7a596a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets new file mode 100644 index 0000000000..94851a38ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_assignmentExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets new file mode 100644 index 0000000000..5a67597bdb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +async function test() { + const a = await new Promise((resolve) => resolve(new A(5 + 6))); + return a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets new file mode 100644 index 0000000000..eb2b9b9c77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_castExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} + +let test: Object = new X() as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets new file mode 100644 index 0000000000..d9b572352a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_classInitializer.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class A { + static initialized = new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..3aea4b64e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A {} + +new A && new A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets new file mode 100644 index 0000000000..ff1f3af1a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A {} + +(6 > 5) ? new A : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..e21c1359f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A {} + +new A || new A; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets new file mode 100644 index 0000000000..76eb41293f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_constantExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..0786450882 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ensureNotNullishExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + constructor(p: number) {} +} + +new A(5 + 6)!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets new file mode 100644 index 0000000000..75bdfaa251 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_equalityExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + constructor(p: number) {} +} + +let b = 1; +b != new A(5 + 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets new file mode 100644 index 0000000000..139e7056ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A { + constructor(p: number) {} +} + +try { +} catch (error) { +} finally { + let a = new A(5 + 6); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets new file mode 100644 index 0000000000..1b6ce073e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_ifStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A {} + +if (new A()) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets new file mode 100644 index 0000000000..72bc69c878 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = new Test(); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..a099f35665 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_instanceOfExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A {} +new A() instanceof Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets new file mode 100644 index 0000000000..89576e44ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +class A {} +(a: number): number => { const b = new A() }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..eaa8c206a8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => { const c = new A(); }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets new file mode 100644 index 0000000000..d4d8dd2004 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A {} + +while(true) { + const c = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..77770d277c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_multiplicativeExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + constructor(p: number) {} +} + +const a = new A(5 * 6); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..69f5df07d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +class A {} + +namespace X { + let a = new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..3fa2d87ec8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A {} + +let a: string | null = "Hello"; +a ?? new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets new file mode 100644 index 0000000000..b8e61cb4ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A {} + +function add(number: number, number1: number) { + return new A(); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets new file mode 100644 index 0000000000..d7b1d6acbd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_statement.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A {} + +while(true) { + const c = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets new file mode 100644 index 0000000000..d829bbe158 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_stringInterpolation.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + constructor(p: string) {} +} + +const a = new A(`Hello, my name is tom`); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets new file mode 100644 index 0000000000..7be2ddf008 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A {} + +switch (1) { + case 1: + let a = new A(); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets new file mode 100644 index 0000000000..6bf2a6af64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topDeclaration.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +new Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets new file mode 100644 index 0000000000..6f02cba79f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type a = Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..1113725c31 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + test(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} + +new A().test("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets new file mode 100644 index 0000000000..94f6a56cee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const a = new Array(); + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets new file mode 100644 index 0000000000..db9321e9ca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +typeof new Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets new file mode 100644 index 0000000000..109526ac9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!new Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets new file mode 100644 index 0000000000..af19b6ac66 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/newExpression/newExpression_whileStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(1 < 2) { + const a = new Array; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets new file mode 100644 index 0000000000..6015b44cb0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_additiveExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value + n; + } + + increment(): void { + this.value = this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets new file mode 100644 index 0000000000..9de5e96b4b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_assignmentExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value += this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets new file mode 100644 index 0000000000..eadc19f405 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_awaitExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class Counter { + value: number = 5; + + async increment(): Promise { + this.value += 1; + } + + async getDelayedValue(): Promise { + await this.increment(); + return this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..a89f62c26e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_bitwiseAndLogicalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value & n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets new file mode 100644 index 0000000000..ce301f6ffb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_castExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + + +class Counter { + value: number = 5; + + increment(): void { + this.value = this.value as number; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..7bcbd8a9c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalAndExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value && this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets new file mode 100644 index 0000000000..2e51365660 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return (2 > 1) ? this.value : this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..1f088e2f05 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_conditionalOrExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value || this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets new file mode 100644 index 0000000000..576098572a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_constantExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + const a = this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..d58bb0a779 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ensureNotNullishExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value!; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets new file mode 100644 index 0000000000..4f536a6bd7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_equalityExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value != 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets new file mode 100644 index 0000000000..10739c1ffd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_fieldAccessExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + let a = new Counter(); + a.value = this.value + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets new file mode 100644 index 0000000000..58763e0c87 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forOfStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let a = 1; +class Counter { + value: number = 1; + arr = [1, 2, 3]; + increment(): void { + for (let a of this.arr) { + this.value++; + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets new file mode 100644 index 0000000000..5c5f20dae4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_forStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + for (let i = 0; i < 5; i++) { + this.value = this.value + 1; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..63575e88a5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_functionTypeWithReceiver.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class A {} + +type FA = (this: A) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets new file mode 100644 index 0000000000..dd7034399d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_ifStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + if (this.value < 6) { + console.log("Value is less than 6"); + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets new file mode 100644 index 0000000000..302a164efc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_indexingExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + let arr: number[] = [1, 2]; + this.value = arr[0]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..00675d2fb8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_instanceOfExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class Counter { + value: string = "name"; + + add(n: number): boolean { + return this.value instanceof string; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets new file mode 100644 index 0000000000..b508640542 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +class A {} + +(this: A): number => { return 0 }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..0d9ae5d40f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} + +let result = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets new file mode 100644 index 0000000000..644be14a48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_loopStatement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + while (this.value < 10) { + this.value = this.value + 1; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..71a23ce856 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_multiplicativeExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value = this.value * this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..c4b0d3f626 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_nullishCoalescingExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets new file mode 100644 index 0000000000..9ce824a18f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_relationalExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + this.value >= this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets new file mode 100644 index 0000000000..982397a5d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_returnStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets new file mode 100644 index 0000000000..01513763b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_shiftExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class Counter { + value: number = 5; + + add(n: number): number { + return this.value >> 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets new file mode 100644 index 0000000000..31cf2559d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_statement.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class Counter { + value: number | null = 5; + + add(n: number): number { + return (this.value ?? 0) + n; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets new file mode 100644 index 0000000000..9120bc66b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_stringInterpolation.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class Counter { + value: string = "name"; + + increment(): void { + this.value = `Hello, my name is tom.`; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets new file mode 100644 index 0000000000..04dbd15548 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_switchStatement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + switch (1) { + case 1: + this.value++; + break; + default: + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets new file mode 100644 index 0000000000..c15fa2b7d8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_throwStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +class Counter { + value: string = "name"; + + increment(): void { + let a = new Error("err" + this.value); + throw a; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets new file mode 100644 index 0000000000..698394799b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + try { + this.value++; + } catch (error) { + console.error("An error occurred during increment:", error); + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets new file mode 100644 index 0000000000..b4b41fb825 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_typeOfExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + typeof this.value; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets new file mode 100644 index 0000000000..28ead0e4b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_unaryExpression.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class Counter { + value: number = 5; + + increment(): void { + switch (1) { + case 1: + this.value++; + break; + default: + break; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets new file mode 100644 index 0000000000..cf4cd47046 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/thisExpression/thisExpression_whileStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class Counter { + value: number = 1; + + increment(): void { + while(this.value) { + console.log(this.value); + } + } +} -- Gitee