From 2786032072b999f2f3537bafc389545c4369dd2a Mon Sep 17 00:00:00 2001 From: liujia178 Date: Tue, 22 Apr 2025 10:23:26 +0800 Subject: [PATCH] constantDeclarations&typeAlias&variableDeclarations&typeArguments&typeParameters&fieldAccessExpression&methodCallExpression&objectReference Signed-off-by: liujia178 --- ...onstantDeclarations_additiveExpression.ets | 29 ++++++++++++ .../constantDeclarations_arrayLiteral.ets | 28 +++++++++++ ...stantDeclarations_assignmentExpression.ets | 30 ++++++++++++ .../constantDeclarations_awaitExpression.ets | 33 +++++++++++++ ...clarations_bitwiseAndLogicalExpression.ets | 30 ++++++++++++ .../constantDeclarations_castExpression.ets | 30 ++++++++++++ ...tDeclarations_conditionalAndExpression.ets | 28 +++++++++++ ...tantDeclarations_conditionalExpression.ets | 28 +++++++++++ ...ntDeclarations_conditionalOrExpression.ets | 28 +++++++++++ ...eclarations_ensureNotNullishExpression.ets | 29 ++++++++++++ ...onstantDeclarations_equalityExpression.ets | 28 +++++++++++ .../constantDeclarations_expression.ets | 42 +++++++++++++++++ ...tantDeclarations_fieldAccessExpression.ets | 33 +++++++++++++ .../constantDeclarations_finallyClause.ets | 32 +++++++++++++ .../constantDeclarations_forOfStatement.ets | 31 ++++++++++++ .../constantDeclarations_forStatement.ets | 30 ++++++++++++ ...antDeclarations_functionCallExpression.ets | 32 +++++++++++++ .../constantDeclarations_ifStatement.ets | 31 ++++++++++++ ...onstantDeclarations_indexingExpression.ets | 29 ++++++++++++ .../constantDeclarations_initializerBlock.ets | 32 +++++++++++++ ...stantDeclarations_instanceOfExpression.ets | 29 ++++++++++++ .../constantDeclarations_lambdaExpression.ets | 29 ++++++++++++ ...larations_lambdaExpressionWithReceiver.ets | 31 ++++++++++++ .../constantDeclarations_loopStatement.ets | 35 ++++++++++++++ ...stantDeclarations_methodCallExpression.ets | 34 ++++++++++++++ ...tDeclarations_multiplicativeExpression.ets | 30 ++++++++++++ ...stantDeclarations_namespaceDeclaration.ets | 31 ++++++++++++ .../constantDeclarations_newArrayInstance.ets | 29 ++++++++++++ .../constantDeclarations_newExpression.ets | 32 +++++++++++++ ...clarations_nullishCoalescingExpression.ets | 29 ++++++++++++ .../constantDeclarations_objectLiteral.ets | 32 +++++++++++++ .../constantDeclarations_objectReference.ets | 41 ++++++++++++++++ ...ntDeclarations_parenthesizedExpression.ets | 28 +++++++++++ .../constantDeclarations_recordLiteral.ets | 31 ++++++++++++ ...stantDeclarations_relationalExpression.ets | 31 ++++++++++++ ...Declarations_separateModuleDeclaration.ets | 30 ++++++++++++ .../constantDeclarations_shiftExpression.ets | 30 ++++++++++++ .../constantDeclarations_spreadExpression.ets | 30 ++++++++++++ .../constantDeclarations_statement.ets | 38 +++++++++++++++ ...nstantDeclarations_stringInterpolation.ets | 29 ++++++++++++ .../constantDeclarations_switchStatement.ets | 33 +++++++++++++ .../constantDeclarations_thisExpression.ets | 35 ++++++++++++++ .../constantDeclarations_topDeclaration.ets | 37 +++++++++++++++ ...onstantDeclarations_trailingLambdaCall.ets | 37 +++++++++++++++ .../constantDeclarations_tryStatement.ets | 35 ++++++++++++++ .../constantDeclarations_typeParameter.ets | 28 +++++++++++ .../constantDeclarations_unaryExpression.ets | 36 ++++++++++++++ .../constantDeclarations_whileStatement.ets | 32 +++++++++++++ .../typeAlias_functionTypeWithReceiver.ets | 29 ++++++++++++ .../typeAlias/typeAlias_restParameter.ets | 28 +++++++++++ .../typeAlias_separateModuleDeclaration.ets | 28 +++++++++++ .../typeAlias/typeAlias_signature.ets | 28 +++++++++++ .../typeAlias/typeAlias_topDeclaration.ets | 37 +++++++++++++++ .../typeAlias_topLevelStatements.ets | 28 +++++++++++ .../typeAlias/typeAlias_typeArguments.ets | 28 +++++++++++ .../typeAlias/typeAlias_typeParameter.ets | 28 +++++++++++ ...ariableDeclarations_additiveExpression.ets | 29 ++++++++++++ .../variableDeclarations_arrayLiteral.ets | 28 +++++++++++ ...iableDeclarations_assignmentExpression.ets | 29 ++++++++++++ .../variableDeclarations_awaitExpression.ets | 33 +++++++++++++ ...clarations_bitwiseAndLogicalExpression.ets | 30 ++++++++++++ .../variableDeclarations_castExpression.ets | 30 ++++++++++++ ...eDeclarations_conditionalAndExpression.ets | 28 +++++++++++ ...ableDeclarations_conditionalExpression.ets | 28 +++++++++++ ...leDeclarations_conditionalOrExpression.ets | 28 +++++++++++ ...eclarations_ensureNotNullishExpression.ets | 29 ++++++++++++ ...ariableDeclarations_equalityExpression.ets | 28 +++++++++++ .../variableDeclarations_expression.ets | 42 +++++++++++++++++ ...ableDeclarations_fieldAccessExpression.ets | 33 +++++++++++++ .../variableDeclarations_finallyClause.ets | 32 +++++++++++++ .../variableDeclarations_forOfStatement.ets | 31 ++++++++++++ .../variableDeclarations_forStatement.ets | 32 +++++++++++++ ...bleDeclarations_functionCallExpression.ets | 32 +++++++++++++ .../variableDeclarations_ifStatement.ets | 31 ++++++++++++ ...ariableDeclarations_indexingExpression.ets | 29 ++++++++++++ .../variableDeclarations_initializerBlock.ets | 32 +++++++++++++ ...iableDeclarations_instanceOfExpression.ets | 29 ++++++++++++ .../variableDeclarations_lambdaExpression.ets | 29 ++++++++++++ ...larations_lambdaExpressionWithReceiver.ets | 31 ++++++++++++ .../variableDeclarations_loopStatement.ets | 35 ++++++++++++++ ...iableDeclarations_methodCallExpression.ets | 34 ++++++++++++++ ...eDeclarations_multiplicativeExpression.ets | 30 ++++++++++++ ...iableDeclarations_namespaceDeclaration.ets | 31 ++++++++++++ .../variableDeclarations_newArrayInstance.ets | 29 ++++++++++++ .../variableDeclarations_newExpression.ets | 32 +++++++++++++ ...clarations_nullishCoalescingExpression.ets | 29 ++++++++++++ .../variableDeclarations_objectLiteral.ets | 32 +++++++++++++ .../variableDeclarations_objectReference.ets | 39 +++++++++++++++ ...leDeclarations_parenthesizedExpression.ets | 28 +++++++++++ .../variableDeclarations_recordLiteral.ets | 31 ++++++++++++ ...iableDeclarations_relationalExpression.ets | 31 ++++++++++++ ...Declarations_separateModuleDeclaration.ets | 30 ++++++++++++ .../variableDeclarations_shiftExpression.ets | 30 ++++++++++++ .../variableDeclarations_spreadExpression.ets | 30 ++++++++++++ .../variableDeclarations_statement.ets | 38 +++++++++++++++ ...riableDeclarations_stringInterpolation.ets | 29 ++++++++++++ .../variableDeclarations_switchStatement.ets | 33 +++++++++++++ .../variableDeclarations_thisExpression.ets | 35 ++++++++++++++ .../variableDeclarations_topDeclaration.ets | 37 +++++++++++++++ ...ariableDeclarations_trailingLambdaCall.ets | 37 +++++++++++++++ .../variableDeclarations_tryStatement.ets | 35 ++++++++++++++ .../variableDeclarations_unaryExpression.ets | 36 ++++++++++++++ .../variableDeclarations_whileStatement.ets | 32 +++++++++++++ .../typeArguments_assignmentExpression.ets | 29 ++++++++++++ ...typeArguments_conditionalAndExpression.ets | 29 ++++++++++++ .../typeArguments_conditionalOrExpression.ets | 29 ++++++++++++ .../typeArguments_constantExpression.ets | 29 ++++++++++++ ...peArguments_ensureNotNullishExpression.ets | 29 ++++++++++++ .../typeArguments_equalityExpression.ets | 29 ++++++++++++ .../typeArguments_expression.ets | 43 +++++++++++++++++ .../typeArguments_forOfStatement.ets | 30 ++++++++++++ .../typeArguments_functionCallExpression.ets | 31 ++++++++++++ .../typeArguments_instanceOfExpression.ets | 29 ++++++++++++ .../typeArguments_lambdaExpression.ets | 29 ++++++++++++ ...Arguments_lambdaExpressionWithReceiver.ets | 31 ++++++++++++ .../typeArguments_loopStatement.ets | 35 ++++++++++++++ .../typeArguments_methodCallExpression.ets | 31 ++++++++++++ .../typeArguments_namespaceDeclaration.ets | 31 ++++++++++++ .../typeArguments_newExpression.ets | 30 ++++++++++++ ...eArguments_nullishCoalescingExpression.ets | 29 ++++++++++++ .../typeArguments_objectLiteral.ets | 35 ++++++++++++++ .../typeArguments_objectReference.ets | 38 +++++++++++++++ .../typeArguments_parenthesizedExpression.ets | 34 ++++++++++++++ .../typeArguments_recordLiteral.ets | 31 ++++++++++++ ...ypeArguments_separateModuleDeclaration.ets | 31 ++++++++++++ .../typeArguments/typeArguments_statement.ets | 41 ++++++++++++++++ .../typeArguments_topDeclaration.ets | 40 ++++++++++++++++ .../typeArguments_topLevelStatements.ets | 28 +++++++++++ .../typeArguments_trailingLambdaCall.ets | 38 +++++++++++++++ .../typeArguments_tryStatement.ets | 35 ++++++++++++++ .../typeArguments_typeOfExpression.ets | 28 +++++++++++ .../typeArguments_unaryExpression.ets | 35 ++++++++++++++ .../typeArguments_whileStatement.ets | 28 +++++++++++ .../typeParameters_objectLiteral.ets | 31 ++++++++++++ ...typeParameters_parenthesizedExpression.ets | 28 +++++++++++ ...peParameters_separateModuleDeclaration.ets | 31 ++++++++++++ .../typeParameters_topDeclaration.ets | 40 ++++++++++++++++ ...eldAccessExpression_additiveExpression.ets | 34 ++++++++++++++ ...dAccessExpression_assignmentExpression.ets | 34 ++++++++++++++ .../fieldAccessExpression_awaitExpression.ets | 33 +++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 35 ++++++++++++++ .../fieldAccessExpression_castExpression.ets | 33 +++++++++++++ ...essExpression_conditionalAndExpression.ets | 34 ++++++++++++++ ...AccessExpression_conditionalExpression.ets | 33 +++++++++++++ ...cessExpression_conditionalOrExpression.ets | 34 ++++++++++++++ ...eldAccessExpression_constantExpression.ets | 33 +++++++++++++ ...sExpression_ensureNotNullishExpression.ets | 33 +++++++++++++ ...eldAccessExpression_equalityExpression.ets | 33 +++++++++++++ .../fieldAccessExpression_forStatement.ets | 35 ++++++++++++++ .../fieldAccessExpression_ifStatement.ets | 34 ++++++++++++++ ...eldAccessExpression_indexingExpression.ets | 33 +++++++++++++ ...dAccessExpression_instanceOfExpression.ets | 33 +++++++++++++ .../fieldAccessExpression_loopStatement.ets | 39 +++++++++++++++ ...essExpression_multiplicativeExpression.ets | 35 ++++++++++++++ ...Expression_nullishCoalescingExpression.ets | 33 +++++++++++++ ...dAccessExpression_relationalExpression.ets | 36 ++++++++++++++ .../fieldAccessExpression_returnStatement.ets | 35 ++++++++++++++ .../fieldAccessExpression_shiftExpression.ets | 35 ++++++++++++++ .../fieldAccessExpression_statement.ets | 45 ++++++++++++++++++ ...ldAccessExpression_stringInterpolation.ets | 34 ++++++++++++++ .../fieldAccessExpression_switchStatement.ets | 39 +++++++++++++++ .../fieldAccessExpression_topDeclaration.ets | 42 +++++++++++++++++ ...eldAccessExpression_trailingLambdaCall.ets | 36 ++++++++++++++ ...fieldAccessExpression_typeOfExpression.ets | 33 +++++++++++++ .../fieldAccessExpression_unaryExpression.ets | 40 ++++++++++++++++ .../fieldAccessExpression_whileStatement.ets | 35 ++++++++++++++ ...ethodCallExpression_additiveExpression.ets | 36 ++++++++++++++ ...hodCallExpression_assignmentExpression.ets | 35 ++++++++++++++ .../methodCallExpression_awaitExpression.ets | 37 +++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../methodCallExpression_castExpression.ets | 35 ++++++++++++++ ...allExpression_conditionalAndExpression.ets | 34 ++++++++++++++ ...odCallExpression_conditionalExpression.ets | 34 ++++++++++++++ ...CallExpression_conditionalOrExpression.ets | 34 ++++++++++++++ ...ethodCallExpression_constantExpression.ets | 35 ++++++++++++++ ...lExpression_ensureNotNullishExpression.ets | 35 ++++++++++++++ ...ethodCallExpression_equalityExpression.ets | 35 ++++++++++++++ .../methodCallExpression_forStatement.ets | 37 +++++++++++++++ .../methodCallExpression_ifStatement.ets | 36 ++++++++++++++ ...ethodCallExpression_indexingExpression.ets | 35 ++++++++++++++ ...hodCallExpression_instanceOfExpression.ets | 35 ++++++++++++++ .../methodCallExpression_loopStatement.ets | 41 ++++++++++++++++ ...allExpression_multiplicativeExpression.ets | 37 +++++++++++++++ ...Expression_nullishCoalescingExpression.ets | 35 ++++++++++++++ ...hodCallExpression_relationalExpression.ets | 38 +++++++++++++++ .../methodCallExpression_returnStatement.ets | 37 +++++++++++++++ .../methodCallExpression_shiftExpression.ets | 37 +++++++++++++++ .../methodCallExpression_statement.ets | 47 +++++++++++++++++++ ...thodCallExpression_stringInterpolation.ets | 36 ++++++++++++++ .../methodCallExpression_switchStatement.ets | 41 ++++++++++++++++ .../methodCallExpression_topDeclaration.ets | 44 +++++++++++++++++ ...ethodCallExpression_trailingLambdaCall.ets | 41 ++++++++++++++++ .../methodCallExpression_typeOfExpression.ets | 35 ++++++++++++++ .../methodCallExpression_unaryExpression.ets | 42 +++++++++++++++++ .../methodCallExpression_whileStatement.ets | 35 ++++++++++++++ .../objectReference_additiveExpression.ets | 36 ++++++++++++++ .../objectReference_arrayLiteral.ets | 35 ++++++++++++++ .../objectReference_assignmentExpression.ets | 36 ++++++++++++++ .../objectReference_awaitExpression.ets | 35 ++++++++++++++ ...tReference_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../objectReference_castExpression.ets | 35 ++++++++++++++ ...jectReference_conditionalAndExpression.ets | 35 ++++++++++++++ .../objectReference_conditionalExpression.ets | 35 ++++++++++++++ ...bjectReference_conditionalOrExpression.ets | 35 ++++++++++++++ .../objectReference_constantExpression.ets | 35 ++++++++++++++ ...ctReference_ensureNotNullishExpression.ets | 35 ++++++++++++++ .../objectReference_equalityExpression.ets | 35 ++++++++++++++ .../objectReference_fieldAccessExpression.ets | 34 ++++++++++++++ .../objectReference_forStatement.ets | 37 +++++++++++++++ .../objectReference_ifStatement.ets | 36 ++++++++++++++ .../objectReference_indexingExpression.ets | 35 ++++++++++++++ .../objectReference_instanceOfExpression.ets | 35 ++++++++++++++ .../objectReference_loopStatement.ets | 41 ++++++++++++++++ ...jectReference_multiplicativeExpression.ets | 37 +++++++++++++++ ...tReference_nullishCoalescingExpression.ets | 35 ++++++++++++++ ...bjectReference_parenthesizedExpression.ets | 35 ++++++++++++++ .../objectReference_recordLiteral.ets | 41 ++++++++++++++++ .../objectReference_relationalExpression.ets | 38 +++++++++++++++ .../objectReference_returnStatement.ets | 37 +++++++++++++++ .../objectReference_shiftExpression.ets | 37 +++++++++++++++ .../objectReference_spreadExpression.ets | 37 +++++++++++++++ .../objectReference_statement.ets | 47 +++++++++++++++++++ .../objectReference_stringInterpolation.ets | 36 ++++++++++++++ .../objectReference_switchStatement.ets | 41 ++++++++++++++++ .../objectReference_topDeclaration.ets | 44 +++++++++++++++++ .../objectReference_trailingLambdaCall.ets | 38 +++++++++++++++ .../objectReference_typeOfExpression.ets | 35 ++++++++++++++ .../objectReference_unaryExpression.ets | 42 +++++++++++++++++ .../objectReference_whileStatement.ets | 35 ++++++++++++++ 229 files changed, 7684 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_additiveExpression.ets new file mode 100644 index 0000000000..66e032eff2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +const a = 1 + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_arrayLiteral.ets new file mode 100644 index 0000000000..476ba3cb43 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +const a: number[] = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_assignmentExpression.ets new file mode 100644 index 0000000000..f75d1d28be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + + */ + +let a = 5; +const test = a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_awaitExpression.ets new file mode 100644 index 0000000000..f8fa30b7cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} +const res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..3ed8168e08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +const test = 1 & 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.ets new file mode 100644 index 0000000000..af7fede22d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_castExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +const test: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.ets new file mode 100644 index 0000000000..9d21e48e84 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalAndExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +const a = 1 && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.ets new file mode 100644 index 0000000000..a9afa31433 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +const a = 1 > 0 ? 1 : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.ets new file mode 100644 index 0000000000..6d041228ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_conditionalOrExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +const a = 0 || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..0952b27c75 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let test: string | null = "Hello"; +const a = test!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.ets new file mode 100644 index 0000000000..f77c0278b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_equalityExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +const a = 1 == 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_expression.ets new file mode 100644 index 0000000000..d1d16fab76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const test = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.ets new file mode 100644 index 0000000000..55ae4dc53b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_fieldAccessExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let test = new Person(); +test.name = "Alice"; +const a = test.name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_finallyClause.ets new file mode 100644 index 0000000000..aa862ea66c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forOfStatement.ets new file mode 100644 index 0000000000..3b82091622 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (const a of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.ets new file mode 100644 index 0000000000..d1cb03e9d1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_forStatement.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1; a < 10; a++) { + const b = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_functionCallExpression.ets new file mode 100644 index 0000000000..a8ef65fa09 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let a: Person | null = null; +const test = a?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_ifStatement.ets new file mode 100644 index 0000000000..10c44236f4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_indexingExpression.ets new file mode 100644 index 0000000000..6eff4b3865 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const test: number[] | null = null; +const a = test?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_initializerBlock.ets new file mode 100644 index 0000000000..9d1d88a664 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + const a = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_instanceOfExpression.ets new file mode 100644 index 0000000000..9a5da30062 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +const test: string = new String("Hello"); +test instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpression.ets new file mode 100644 index 0000000000..f26593e8cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +const a = (test: number): number => { return Math.sin(test) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..a2ffdfac89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +const result1 = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_loopStatement.ets new file mode 100644 index 0000000000..9cbe473467 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + const test = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.ets new file mode 100644 index 0000000000..6173d06863 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_methodCallExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): string { + return `Hello, ${a}`; + } +} +let a = new MyClass(); +const test = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.ets new file mode 100644 index 0000000000..cd83712f5b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_multiplicativeExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +const test = 1 * 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_namespaceDeclaration.ets new file mode 100644 index 0000000000..bf1c7420f3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace test { + const a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newArrayInstance.ets new file mode 100644 index 0000000000..adbf0e48da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let test = 1; +const a = new string[test]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.ets new file mode 100644 index 0000000000..984b090039 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_newExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class A { + constructor(p: number) {} +} +const instance = new A(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..baa0392303 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +const test = a ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.ets new file mode 100644 index 0000000000..ff3e9e04fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectLiteral.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +const test: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_objectReference.ets new file mode 100644 index 0000000000..0b8ff69ff9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} + +class A extends BaseClass { + constructor() { + super(); + } +} + +const test = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_parenthesizedExpression.ets new file mode 100644 index 0000000000..be7ca7aab1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +const test = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_recordLiteral.ets new file mode 100644 index 0000000000..50a1a5125c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +const test: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.ets new file mode 100644 index 0000000000..6b5b96306d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_relationalExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +const test = 5 < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.ets new file mode 100644 index 0000000000..0be5faf02a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_separateModuleDeclaration.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +function test() { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.ets new file mode 100644 index 0000000000..2ea3a5863b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_shiftExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +const test = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_spreadExpression.ets new file mode 100644 index 0000000000..6e4db6106c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +const test = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_statement.ets new file mode 100644 index 0000000000..2f390c7c53 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +const test = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_stringInterpolation.ets new file mode 100644 index 0000000000..d9dc2f14b0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = "Alice"; +const test = `Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets new file mode 100644 index 0000000000..bf10a17460 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch (1) { + case 1: { + const res = 1; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.ets new file mode 100644 index 0000000000..8cbdfe4d7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_thisExpression.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + const s = this.name; + } +} +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_topDeclaration.ets new file mode 100644 index 0000000000..7bbff99dc5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +const a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.ets new file mode 100644 index 0000000000..c108fc20ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_trailingLambdaCall.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + add(arg: T, callback: (result: T) => void): number { + return 0; + } +} +let a = new A(); +const test = a.add("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_tryStatement.ets new file mode 100644 index 0000000000..939e22f060 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + const test = 1; + return test; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.ets new file mode 100644 index 0000000000..a3ff8e59f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_typeParameter.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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +let a: Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_unaryExpression.ets new file mode 100644 index 0000000000..59fa095302 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +const test = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_whileStatement.ets new file mode 100644 index 0000000000..876fa18f79 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/constantDeclarations/constantDeclarations_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 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + const a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..dd072e5a5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * 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/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.ets new file mode 100644 index 0000000000..642efa8974 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_restParameter.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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +type Handler = (s: string, ...numbers: number[]) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_separateModuleDeclaration.ets new file mode 100644 index 0000000000..d39ffb89b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +type Matrix = number[][]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_signature.ets new file mode 100644 index 0000000000..dfc953fe25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +type Handler = (s: string, no: number) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topDeclaration.ets new file mode 100644 index 0000000000..cd84e6c37a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +type Handler = (s: string, no: number) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_topLevelStatements.ets new file mode 100644 index 0000000000..76bb6ae6a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type A = number | string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeArguments.ets new file mode 100644 index 0000000000..f4dbf80520 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +type Dictionary = Map; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.ets new file mode 100644 index 0000000000..55e35c435d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/typeAlias/typeAlias_typeParameter.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 4.6.1 + * typeAlias: + * 'type' identifiertypeParameters? '=' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +type Predicate = (x: T) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_additiveExpression.ets new file mode 100644 index 0000000000..d00d79822b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +let a = 1 + 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_arrayLiteral.ets new file mode 100644 index 0000000000..3b9448ecc5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let a: number[] = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_assignmentExpression.ets new file mode 100644 index 0000000000..7fe9d2a128 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; +let test = a += 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_awaitExpression.ets new file mode 100644 index 0000000000..24b1218861 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} +let res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..1236528c76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +let test = 1 & 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.ets new file mode 100644 index 0000000000..416f960f63 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_castExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +let test: Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.ets new file mode 100644 index 0000000000..bf10f99e47 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalAndExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let a = 1 && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.ets new file mode 100644 index 0000000000..702e96e013 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let a = 1 > 0 ? 1 : 0; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.ets new file mode 100644 index 0000000000..b67dea8969 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_conditionalOrExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let a = 0 || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..02272f37bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let test: string | null = "Hello"; +let a = test!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.ets new file mode 100644 index 0000000000..228191c644 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_equalityExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let a = 1 == 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_expression.ets new file mode 100644 index 0000000000..1c0d7eec17 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +let test = 10 / 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.ets new file mode 100644 index 0000000000..1679508d50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_fieldAccessExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let test = new Person(); +test.name = "Alice"; +let a = test.name; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_finallyClause.ets new file mode 100644 index 0000000000..a0b470f47d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +try { +} catch (error) { +} finally { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forOfStatement.ets new file mode 100644 index 0000000000..65902e0c00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let a of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_forStatement.ets new file mode 100644 index 0000000000..a2feb04c60 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let a = 1; a < 10; a++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_functionCallExpression.ets new file mode 100644 index 0000000000..88e1efe5e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +let a: Person | null = null; +let test = a?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_ifStatement.ets new file mode 100644 index 0000000000..d120efd87b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_indexingExpression.ets new file mode 100644 index 0000000000..e42ce88eb0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const test: number[] | null = null; +let a = test?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_initializerBlock.ets new file mode 100644 index 0000000000..4ca1849bb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let a = 0; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_instanceOfExpression.ets new file mode 100644 index 0000000000..7ba7253f59 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let test: string = new String("Hello"); +let a = test instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpression.ets new file mode 100644 index 0000000000..163db2429f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let a = (test: number): number => { return Math.sin(test) }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..cb705dc415 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result1 = (this: A) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_loopStatement.ets new file mode 100644 index 0000000000..141f48b927 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + let test = 1; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.ets new file mode 100644 index 0000000000..59324fa6b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_methodCallExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number): string { + return `Hello, ${a}`; + } +} +let a = new MyClass(); +let test = a.sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.ets new file mode 100644 index 0000000000..7f38a10bb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_multiplicativeExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +let test = 1 * 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_namespaceDeclaration.ets new file mode 100644 index 0000000000..8bf774c584 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace test { + let a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newArrayInstance.ets new file mode 100644 index 0000000000..5895924f77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let test = 1; +let a = new string[test]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.ets new file mode 100644 index 0000000000..c7c81c1a7b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_newExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * 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/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..ce473e7d6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let a: string | null = "Hello"; +let test = a ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.ets new file mode 100644 index 0000000000..60081f327a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectLiteral.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +let test: Person = {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.ets new file mode 100644 index 0000000000..b4b0a509c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_objectReference.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() { + } +} +class A extends BaseClass { + constructor() { + super(); + } +} +let test = new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_parenthesizedExpression.ets new file mode 100644 index 0000000000..141d5a4139 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let test = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_recordLiteral.ets new file mode 100644 index 0000000000..1f886edd59 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let test: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.ets new file mode 100644 index 0000000000..97dcf80db6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_relationalExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +let test = 5 < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.ets new file mode 100644 index 0000000000..8c5775742b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_separateModuleDeclaration.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +function test() { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.ets new file mode 100644 index 0000000000..3f47035690 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_shiftExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +let test = 1 << 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_spreadExpression.ets new file mode 100644 index 0000000000..410c8576b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let test = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_statement.ets new file mode 100644 index 0000000000..821d44aa48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let test = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_stringInterpolation.ets new file mode 100644 index 0000000000..17032a6bef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = "Alice"; +let test = `Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets new file mode 100644 index 0000000000..8c1c734613 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_switchStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +switch (1) { + case 1: { + let res = 1; + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.ets new file mode 100644 index 0000000000..9997d7ba8a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_thisExpression.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class A { + name: string; + constructor(name: string) { + this.name = name; + let s = this.name; + } +} +let person = new A("Alice"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_topDeclaration.ets new file mode 100644 index 0000000000..45b6883fbb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let a = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.ets new file mode 100644 index 0000000000..4492c25450 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_trailingLambdaCall.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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + add(arg: T, callback: (result: T) => void): number { + return 0; + } +} +let a = new A(); +let test = a.add("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_tryStatement.ets new file mode 100644 index 0000000000..93a94b148a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let test = 1; + return test; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_unaryExpression.ets new file mode 100644 index 0000000000..c15295b3e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let a = 5; +let test = a++; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_whileStatement.ets new file mode 100644 index 0000000000..2e90349ee9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/variableDeclarations/variableDeclarations_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 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + let a = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_assignmentExpression.ets new file mode 100644 index 0000000000..fd3567b6cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalAndExpression.ets new file mode 100644 index 0000000000..71bc4c4115 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class GenericBox {} +new GenericBox() && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_conditionalOrExpression.ets new file mode 100644 index 0000000000..ecad1f59a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class GenericBox {} +new GenericBox() || true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_constantExpression.ets new file mode 100644 index 0000000000..f1df6107ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..fc0db5a9e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class GenericBox {} +new GenericBox()!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_equalityExpression.ets new file mode 100644 index 0000000000..be43b03467 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class GenericBox {} +new GenericBox() != 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.ets new file mode 100644 index 0000000000..336f0cd501 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_expression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.ets new file mode 100644 index 0000000000..0450951269 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_forOfStatement.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +for (let arr of Array()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.ets new file mode 100644 index 0000000000..b28a20fccc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_functionCallExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ( '?.' | typeArguments)? arguments block? + * ; + */ + +class Person { + sayHello() {} +} +new Person()?.sayHello(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_instanceOfExpression.ets new file mode 100644 index 0000000000..b0db744e2f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class GenericBox {} +new GenericBox() instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpression.ets new file mode 100644 index 0000000000..1bdb674157 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? + * ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(a: Array): Array => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..e74aaafe5d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result = (this: A, a: Array): Array => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_loopStatement.ets new file mode 100644 index 0000000000..5a9b09a3d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class GenericBox {} +while(new GenericBox()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.ets new file mode 100644 index 0000000000..6f2d3e21f8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_methodCallExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class MyClass { + sayHello(a: number) {} +} +new MyClass().sayHello(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_namespaceDeclaration.ets new file mode 100644 index 0000000000..ce92efa952 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace A { + let a: Array; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.ets new file mode 100644 index 0000000000..a55ccd7d0a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_newExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class GenericBox {} +const stringBox = new GenericBox(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..02ce840f96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class GenericBox {} +new GenericBox() ?? "Default"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.ets new file mode 100644 index 0000000000..55740f71e1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectLiteral.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} +let a: Person = { + name: "Alice", + age: 25, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.ets new file mode 100644 index 0000000000..32ec5290b6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_objectReference.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class BaseClass { + constructor() {} +} +class A extends BaseClass { + constructor() { + super(); + } +} +new A(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.ets new file mode 100644 index 0000000000..fd993a63af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_parenthesizedExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +class GenericBox { + private value: T; + constructor(value: T) { + this.value = value; + } +} +const intBox = new GenericBox(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_recordLiteral.ets new file mode 100644 index 0000000000..7bfcba0932 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let a: Record = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.ets new file mode 100644 index 0000000000..44f17fa49e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_separateModuleDeclaration.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +class Person { + name: string; + age: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_statement.ets new file mode 100644 index 0000000000..4fb483d71c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class GenericBox {} +while(new GenericBox()) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.ets new file mode 100644 index 0000000000..832a7d3267 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topDeclaration.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class Person { + name: string; + age: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_topLevelStatements.ets new file mode 100644 index 0000000000..cfa86b977f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +let a: Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.ets new file mode 100644 index 0000000000..fc2db399e9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_trailingLambdaCall.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + B(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +let a = new A(); +a.B("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_tryStatement.ets new file mode 100644 index 0000000000..cde097fc78 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let a: Array; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.ets new file mode 100644 index 0000000000..d522ab1fab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_typeOfExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +typeof Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.ets new file mode 100644 index 0000000000..565452feb5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_unaryExpression.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!Array(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.ets new file mode 100644 index 0000000000..4454925227 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeArguments/typeArguments_whileStatement.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 5.2.1 + * typeArguments: + * '<' type( ',' type)* '>' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +while(Array().length < 3) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.ets new file mode 100644 index 0000000000..c0d5dd5c51 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_objectLiteral.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_parenthesizedExpression.ets new file mode 100644 index 0000000000..8272658f2c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function createDictionary(key: K, value: V) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.ets new file mode 100644 index 0000000000..148173f4ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_separateModuleDeclaration.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +class Person { + name: string = "name"; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.ets new file mode 100644 index 0000000000..908c492e03 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/5_generics/typeParameters/typeParameters_topDeclaration.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 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class Person { + name: string = ""; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.ets new file mode 100644 index 0000000000..853d58b5a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_additiveExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age + instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_assignmentExpression.ets new file mode 100644 index 0000000000..935b8c59c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.age = 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_awaitExpression.ets new file mode 100644 index 0000000000..de8edafe48 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + name: string = "Alice"; + age: Promise = Promise.resolve(25); +} +const instance = new A(); +const result = await instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..2714e49a12 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_bitwiseAndLogicalExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age & 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.ets new file mode 100644 index 0000000000..bf1bb1502c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_castExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +const result = instance.name as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..0638792a11 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets new file mode 100644 index 0000000000..dae79d8382 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +(instance.age > 5) ? 6 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..73beafd98d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_constantExpression.ets new file mode 100644 index 0000000000..0ed433b1b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..6bce04d5a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets new file mode 100644 index 0000000000..9558135148 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_equalityExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets new file mode 100644 index 0000000000..537f3a3c7b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_forStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_ifStatement.ets new file mode 100644 index 0000000000..9c75736c49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +if (instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.ets new file mode 100644 index 0000000000..e5460629b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_indexingExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..bdc731df20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_instanceOfExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets new file mode 100644 index 0000000000..4c3ecbe61c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_loopStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..a44f98fc82 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age * instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..00f35a5412 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_nullishCoalescingExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +null ?? instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets new file mode 100644 index 0000000000..d6d7aaa195 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_relationalExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age < instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets new file mode 100644 index 0000000000..22df5ef8ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_returnStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +function add() { + return instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.ets new file mode 100644 index 0000000000..6cef955aad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_shiftExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age << instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.ets new file mode 100644 index 0000000000..703c12512f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_statement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_stringInterpolation.ets new file mode 100644 index 0000000000..bee53d386a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.name = `Hello, my name is ${a}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.ets new file mode 100644 index 0000000000..859c3e5f6a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_switchStatement.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + name: string = "Alice"; + age: int = 25; +} +const instance = new A(); +switch (instance.age) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.ets new file mode 100644 index 0000000000..6406c117a1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_topDeclaration.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +export default const result = instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..f4a08821b5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_trailingLambdaCall.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.ets new file mode 100644 index 0000000000..34f55be209 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_typeOfExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +typeof instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.ets new file mode 100644 index 0000000000..6e226a6abb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_unaryExpression.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.9 + * fieldAccessExpression: + * objectReference (. | ?.) identifier + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +!instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.ets new file mode 100644 index 0000000000..ae81fe6bc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/fieldAccessExpression/fieldAccessExpression_whileStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.ets new file mode 100644 index 0000000000..5084c4c7d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_additiveExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") + instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_assignmentExpression.ets new file mode 100644 index 0000000000..77405092c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +let a = 1; +instance.method([1, 2, 3], a += 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_awaitExpression.ets new file mode 100644 index 0000000000..7f8f97309c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + async method(arg1: number[], arg2: string): Promise { + return new Promise((resolve) => { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + resolve("Done"); + }); + } +} +const instance = new A(); +await instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..d472dc674c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_bitwiseAndLogicalExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +let a = 1; +const instance = new A(); +instance.method([1, 2, 3], a & 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_castExpression.ets new file mode 100644 index 0000000000..8eeb866ee5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +const result = instance.method([1, 2, 3], "Hello") as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..dbd152373e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], 1 && 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalExpression.ets new file mode 100644 index 0000000000..19908ff673 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], (6 > 5) ? 6 : 5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..a9c22f5830 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A { + method(arg1: number[], arg2: number) { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + } +} +const instance = new A(); +instance.method([1, 2, 3], 1 || 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets new file mode 100644 index 0000000000..0cb89a3800 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_constantExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +const result = instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..e57b84d74e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ensureNotNullishExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello")!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.ets new file mode 100644 index 0000000000..245011735c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_equalityExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets new file mode 100644 index 0000000000..933704c1fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.method([1, 2, 3], "Hello"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets new file mode 100644 index 0000000000..d937d82706 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_ifStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +if (instance.method([1, 2, 3], "Hello")) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_indexingExpression.ets new file mode 100644 index 0000000000..685a6815a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello")?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..ece1bfe5d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_instanceOfExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets new file mode 100644 index 0000000000..2dd9fe5ef1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..7459ecd7d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_multiplicativeExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") * instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..15d8c4dbff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_nullishCoalescingExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +null ?? instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.ets new file mode 100644 index 0000000000..8295ad3da5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_relationalExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") < instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.ets new file mode 100644 index 0000000000..6353120fdb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_returnStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +function add() { + return instance.method([1, 2, 3], "Hello"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.ets new file mode 100644 index 0000000000..5170fefccd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_shiftExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): number { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") << instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.ets new file mode 100644 index 0000000000..1a6c0353fc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_statement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.ets new file mode 100644 index 0000000000..42f666b6ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_stringInterpolation.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +let a = 1; +const instance = new A(); +instance.method([1, 2, 3], `Hello, my name is ${a}.`); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.ets new file mode 100644 index 0000000000..b18a554a14 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_switchStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + method(arg1: number[], arg2: string): int { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return 1; + } +} +const instance = new A(); +switch (instance.method([1, 2, 3], "Hello")) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.ets new file mode 100644 index 0000000000..6f4bf543c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_topDeclaration.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +export default const result = instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..be7ba0f899 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_trailingLambdaCall.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + method(arg1: number[], arg2: string, callback: () => void): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + callback(); + return "Done"; + } +} +const instance = new A(); +instance.method([1, 2, 3], "Hello") { + console.log("Inside trailing lambda"); +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.ets new file mode 100644 index 0000000000..afaac8e4bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_typeOfExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +typeof instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.ets new file mode 100644 index 0000000000..a6969605fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_unaryExpression.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +!instance.method([1, 2, 3], "Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.ets new file mode 100644 index 0000000000..203104db22 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/methodCallExpression/methodCallExpression_whileStatement.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.10 + * methodCallExpression: + * objectReference (. | ?.) identifier typeArguments? arguments block? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + method(arg1: number[], arg2: string): string { + console.log(`arg1: ${arg1}, arg2: ${arg2}`); + return "Done"; + } +} +const instance = new A(); +while(instance.method([1, 2, 3], "Hello")) { } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.ets new file mode 100644 index 0000000000..f5d11109ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_additiveExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age + instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.ets new file mode 100644 index 0000000000..c09e1715db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_arrayLiteral.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets new file mode 100644 index 0000000000..d7da6ed1ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_assignmentExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.age = 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets new file mode 100644 index 0000000000..21ad2cd541 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class A { + name: string = "Alice"; + age: Promise = Promise.resolve(25); +} +const instance = new A(); +const result = await instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..1dad5e99c7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_bitwiseAndLogicalExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age & 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_castExpression.ets new file mode 100644 index 0000000000..4b4c358445 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +const result = instance.name as string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.ets new file mode 100644 index 0000000000..e7207538d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalAndExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.ets new file mode 100644 index 0000000000..5ddd096e42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +(instance.age > 5) ? 6 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.ets new file mode 100644 index 0000000000..b751169038 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_conditionalOrExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets new file mode 100644 index 0000000000..4f311d084c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_constantExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..bf2dad3614 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ensureNotNullishExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.ets new file mode 100644 index 0000000000..7c106e48ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_equalityExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name == "string"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.ets new file mode 100644 index 0000000000..3a5ebec369 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_fieldAccessExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let instance = new Person(); +instance.name = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets new file mode 100644 index 0000000000..ec0a611c52 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_forStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +for (let a = 1; a < 10; a++) { + instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets new file mode 100644 index 0000000000..493723b159 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_ifStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +if (instance.age) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_indexingExpression.ets new file mode 100644 index 0000000000..191061fd39 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr?.[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.ets new file mode 100644 index 0000000000..400187fe38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_instanceOfExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.name instanceof String; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets new file mode 100644 index 0000000000..cf003b82b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_loopStatement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.ets new file mode 100644 index 0000000000..82a9e898fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_multiplicativeExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age * instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..6485031764 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_nullishCoalescingExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +null ?? instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.ets new file mode 100644 index 0000000000..0dc3cedfa6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_parenthesizedExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 1; +} +const instance = new A(); +instance.age = (5 + 10) * 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.ets new file mode 100644 index 0000000000..165a470e9f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_recordLiteral.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +class A { + name: string = "Alice"; + rec: Record = { + "John": 25, + "Mary": 21, + }; +} +const instance = new A(); +instance.rec = { + "John": 25, + "Mary": 21, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.ets new file mode 100644 index 0000000000..0f9da62667 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_relationalExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age < instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.ets new file mode 100644 index 0000000000..d01b9cf488 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_returnStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +function add() { + return instance.age; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.ets new file mode 100644 index 0000000000..785eb06e4b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_shiftExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age << instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.ets new file mode 100644 index 0000000000..de7281858d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_spreadExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +class A { + name: string = "Alice"; + arr: number[] = [1, 2, 3]; +} +const instance = new A(); +instance.arr = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.ets new file mode 100644 index 0000000000..a3baecdbf1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_statement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.ets new file mode 100644 index 0000000000..abd85a5ae2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_stringInterpolation.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +let a = 1; +instance.name = `Hello, my name is ${a}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.ets new file mode 100644 index 0000000000..50437a19c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_switchStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class A { + name: string = "Alice"; + age: int = 25; +} +const instance = new A(); +switch (instance.age) { + case 1: + console.log("Case 1"); + break; + default: + console.log("Default case"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.ets new file mode 100644 index 0000000000..2e99569196 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_topDeclaration.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +export default const result = instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.ets new file mode 100644 index 0000000000..d4af564854 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_trailingLambdaCall.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.ets new file mode 100644 index 0000000000..bbc220a354 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_typeOfExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +typeof instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.ets new file mode 100644 index 0000000000..2565394bb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_unaryExpression.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +!instance.age; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.ets new file mode 100644 index 0000000000..ae81fe6bc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectReference/objectReference_whileStatement.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 + * objectReference: + * typeReference + * | 'super' + * | primaryExpression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class A { + name: string = "Alice"; + age: number = 25; +} +const instance = new A(); +while(instance.age) {} -- Gitee