From e66d0272422c77edf1775d22e3571a5b7e8a0cd8 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Tue, 22 Apr 2025 19:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A6=82=E4=B8=8B=E8=A1=A8?= =?UTF-8?q?=E8=BE=BE=E5=BC=8F=E7=9A=84=E6=AD=A3=E4=BA=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=20spreadExpression&parenthesizedExpression&f?= =?UTF-8?q?unctionCallExpression&signature&restParameter¶meterList&opt?= =?UTF-8?q?ionalParameter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujia178 --- .../optionalParameter_additiveExpression.ets | 34 ++++++++++++++ .../optionalParameter_annotationUsage.ets | 35 ++++++++++++++ .../optionalParameter_arrayLiteral.ets | 34 ++++++++++++++ ...optionalParameter_assignmentExpression.ets | 33 +++++++++++++ .../optionalParameter_awaitExpression.ets | 36 ++++++++++++++ ...lParameter_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../optionalParameter_classInitializer.ets | 33 +++++++++++++ ...onalParameter_conditionalAndExpression.ets | 35 ++++++++++++++ ...ptionalParameter_conditionalExpression.ets | 35 ++++++++++++++ ...ionalParameter_conditionalOrExpression.ets | 35 ++++++++++++++ .../optionalParameter_constantExpression.ets | 33 +++++++++++++ .../optionalParameter_equalityExpression.ets | 32 +++++++++++++ .../optionalParameter_expression.ets | 47 +++++++++++++++++++ .../optionalParameter_finallyClause.ets | 38 +++++++++++++++ ...tionalParameter_functionCallExpression.ets | 33 +++++++++++++ ...onalParameter_functionTypeWithReceiver.ets | 31 ++++++++++++ .../optionalParameter_initializerBlock.ets | 33 +++++++++++++ .../optionalParameter_lambdaExpression.ets | 31 ++++++++++++ ...Parameter_lambdaExpressionWithReceiver.ets | 35 ++++++++++++++ ...optionalParameter_methodCallExpression.ets | 35 ++++++++++++++ ...onalParameter_multiplicativeExpression.ets | 35 ++++++++++++++ ...optionalParameter_namespaceDeclaration.ets | 34 ++++++++++++++ ...lParameter_nullishCoalescingExpression.ets | 33 +++++++++++++ .../optionalParameter_objectLiteral.ets | 35 ++++++++++++++ .../optionalParameter_objectReference.ets | 38 +++++++++++++++ ...ionalParameter_parenthesizedExpression.ets | 33 +++++++++++++ .../optionalParameter_recordLiteral.ets | 31 ++++++++++++ ...optionalParameter_relationalExpression.ets | 35 ++++++++++++++ .../optionalParameter_restParameter.ets | 31 ++++++++++++ .../optionalParameter_returnStatement.ets | 33 +++++++++++++ .../optionalParameter_shiftExpression.ets | 35 ++++++++++++++ .../optionalParameter_stringInterpolation.ets | 31 ++++++++++++ .../optionalParameter_thisExpression.ets | 37 +++++++++++++++ .../optionalParameter_trailingLambdaCall.ets | 40 ++++++++++++++++ .../optionalParameter_typeArguments.ets | 31 ++++++++++++ .../optionalParameter_typeParameters.ets | 31 ++++++++++++ .../optionalParameter_unaryExpression.ets | 39 +++++++++++++++ .../parameterList_additiveExpression.ets | 34 ++++++++++++++ .../parameterList_annotationUsage.ets | 35 ++++++++++++++ .../parameterList_arrayLiteral.ets | 34 ++++++++++++++ .../parameterList_assignmentExpression.ets | 33 +++++++++++++ .../parameterList_awaitExpression.ets | 36 ++++++++++++++ ...ameterList_bitwiseAndLogicalExpression.ets | 38 +++++++++++++++ .../parameterList_classInitializer.ets | 33 +++++++++++++ ...parameterList_conditionalAndExpression.ets | 35 ++++++++++++++ .../parameterList_conditionalExpression.ets | 35 ++++++++++++++ .../parameterList_conditionalOrExpression.ets | 35 ++++++++++++++ .../parameterList_constantExpression.ets | 33 +++++++++++++ .../parameterList_equalityExpression.ets | 32 +++++++++++++ .../parameterList_expression.ets | 47 +++++++++++++++++++ .../parameterList_finallyClause.ets | 38 +++++++++++++++ .../parameterList_functionCallExpression.ets | 33 +++++++++++++ ...parameterList_functionTypeWithReceiver.ets | 31 ++++++++++++ .../parameterList_initializerBlock.ets | 33 +++++++++++++ .../parameterList_lambdaExpression.ets | 31 ++++++++++++ ...meterList_lambdaExpressionWithReceiver.ets | 35 ++++++++++++++ .../parameterList_methodCallExpression.ets | 35 ++++++++++++++ ...parameterList_multiplicativeExpression.ets | 35 ++++++++++++++ .../parameterList_namespaceDeclaration.ets | 34 ++++++++++++++ ...ameterList_nullishCoalescingExpression.ets | 33 +++++++++++++ .../parameterList_objectLiteral.ets | 35 ++++++++++++++ .../parameterList_objectReference.ets | 39 +++++++++++++++ .../parameterList_optionalParameter.ets | 34 ++++++++++++++ .../parameterList_parenthesizedExpression.ets | 33 +++++++++++++ .../parameterList_recordLiteral.ets | 31 ++++++++++++ .../parameterList_relationalExpression.ets | 35 ++++++++++++++ .../parameterList_restParameter.ets | 31 ++++++++++++ .../parameterList_returnStatement.ets | 33 +++++++++++++ .../parameterList_shiftExpression.ets | 35 ++++++++++++++ .../parameterList_stringInterpolation.ets | 31 ++++++++++++ .../parameterList_thisExpression.ets | 37 +++++++++++++++ .../parameterList_trailingLambdaCall.ets | 40 ++++++++++++++++ .../parameterList_typeArguments.ets | 31 ++++++++++++ .../parameterList_typeParameters.ets | 31 ++++++++++++ .../parameterList_unaryExpression.ets | 39 +++++++++++++++ .../restParameter_additiveExpression.ets | 33 +++++++++++++ .../restParameter_annotationUsage.ets | 34 ++++++++++++++ .../restParameter_arrayLiteral.ets | 33 +++++++++++++ .../restParameter_assignmentExpression.ets | 32 +++++++++++++ .../restParameter_awaitExpression.ets | 35 ++++++++++++++ ...tParameter_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../restParameter_classInitializer.ets | 32 +++++++++++++ ...restParameter_conditionalAndExpression.ets | 34 ++++++++++++++ .../restParameter_conditionalExpression.ets | 34 ++++++++++++++ .../restParameter_conditionalOrExpression.ets | 34 ++++++++++++++ .../restParameter_constantExpression.ets | 32 +++++++++++++ .../restParameter_equalityExpression.ets | 31 ++++++++++++ .../restParameter_expression.ets | 46 ++++++++++++++++++ .../restParameter_finallyClause.ets | 37 +++++++++++++++ .../restParameter_functionCallExpression.ets | 32 +++++++++++++ ...restParameter_functionTypeWithReceiver.ets | 30 ++++++++++++ .../restParameter_initializerBlock.ets | 32 +++++++++++++ .../restParameter_lambdaExpression.ets | 30 ++++++++++++ ...Parameter_lambdaExpressionWithReceiver.ets | 34 ++++++++++++++ .../restParameter_methodCallExpression.ets | 34 ++++++++++++++ ...restParameter_multiplicativeExpression.ets | 34 ++++++++++++++ .../restParameter_namespaceDeclaration.ets | 33 +++++++++++++ ...tParameter_nullishCoalescingExpression.ets | 32 +++++++++++++ .../restParameter_objectLiteral.ets | 34 ++++++++++++++ .../restParameter_objectReference.ets | 38 +++++++++++++++ .../restParameter_parenthesizedExpression.ets | 32 +++++++++++++ .../restParameter_recordLiteral.ets | 30 ++++++++++++ .../restParameter_relationalExpression.ets | 34 ++++++++++++++ .../restParameter_returnStatement.ets | 32 +++++++++++++ .../restParameter_shiftExpression.ets | 34 ++++++++++++++ .../restParameter_stringInterpolation.ets | 30 ++++++++++++ .../restParameter_thisExpression.ets | 36 ++++++++++++++ .../restParameter_trailingLambdaCall.ets | 39 +++++++++++++++ .../restParameter_typeArguments.ets | 30 ++++++++++++ .../restParameter_typeParameters.ets | 30 ++++++++++++ .../restParameter_unaryExpression.ets | 38 +++++++++++++++ .../signature_additiveExpression.ets | 33 +++++++++++++ .../signature/signature_annotationUsage.ets | 34 ++++++++++++++ .../signature/signature_arrayLiteral.ets | 33 +++++++++++++ .../signature_assignmentExpression.ets | 32 +++++++++++++ .../signature/signature_awaitExpression.ets | 35 ++++++++++++++ .../signature_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../signature/signature_classInitializer.ets | 32 +++++++++++++ .../signature_conditionalAndExpression.ets | 34 ++++++++++++++ .../signature_conditionalExpression.ets | 34 ++++++++++++++ .../signature_conditionalOrExpression.ets | 34 ++++++++++++++ .../signature_constantExpression.ets | 32 +++++++++++++ .../signature_equalityExpression.ets | 31 ++++++++++++ .../signature/signature_expression.ets | 46 ++++++++++++++++++ .../signature/signature_finallyClause.ets | 37 +++++++++++++++ .../signature_functionCallExpression.ets | 32 +++++++++++++ .../signature/signature_lambdaExpression.ets | 30 ++++++++++++ ...signature_lambdaExpressionWithReceiver.ets | 34 ++++++++++++++ .../signature_methodCallExpression.ets | 34 ++++++++++++++ .../signature_multiplicativeExpression.ets | 34 ++++++++++++++ .../signature_namespaceDeclaration.ets | 33 +++++++++++++ .../signature_nullishCoalescingExpression.ets | 32 +++++++++++++ .../signature/signature_objectLiteral.ets | 34 ++++++++++++++ .../signature/signature_objectReference.ets | 38 +++++++++++++++ .../signature/signature_optionalParameter.ets | 33 +++++++++++++ .../signature/signature_parameterList.ets | 33 +++++++++++++ .../signature_parenthesizedExpression.ets | 32 +++++++++++++ .../signature/signature_recordLiteral.ets | 30 ++++++++++++ .../signature_relationalExpression.ets | 34 ++++++++++++++ .../signature/signature_restParameter.ets | 30 ++++++++++++ .../signature/signature_returnStatement.ets | 32 +++++++++++++ .../signature/signature_shiftExpression.ets | 34 ++++++++++++++ .../signature_stringInterpolation.ets | 30 ++++++++++++ .../signature/signature_thisExpression.ets | 36 ++++++++++++++ .../signature_trailingLambdaCall.ets | 39 +++++++++++++++ .../signature/signature_typeArguments.ets | 30 ++++++++++++ .../signature/signature_typeParameters.ets | 30 ++++++++++++ .../signature/signature_unaryExpression.ets | 38 +++++++++++++++ ...ctionCallExpression_additiveExpression.ets | 33 +++++++++++++ ...functionCallExpression_annotationUsage.ets | 34 ++++++++++++++ ...ionCallExpression_assignmentExpression.ets | 32 +++++++++++++ ...functionCallExpression_awaitExpression.ets | 35 ++++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ .../functionCallExpression_castExpression.ets | 37 +++++++++++++++ ...allExpression_conditionalAndExpression.ets | 34 ++++++++++++++ ...onCallExpression_conditionalExpression.ets | 34 ++++++++++++++ ...CallExpression_conditionalOrExpression.ets | 34 ++++++++++++++ ...ctionCallExpression_constantExpression.ets | 32 +++++++++++++ ...lExpression_ensureNotNullishExpression.ets | 33 +++++++++++++ ...ctionCallExpression_equalityExpression.ets | 31 ++++++++++++ .../functionCallExpression_forOfStatement.ets | 31 ++++++++++++ .../functionCallExpression_forStatement.ets | 35 ++++++++++++++ .../functionCallExpression_ifStatement.ets | 35 ++++++++++++++ ...ctionCallExpression_indexingExpression.ets | 33 +++++++++++++ .../functionCallExpression_loopStatement.ets | 43 +++++++++++++++++ ...allExpression_multiplicativeExpression.ets | 34 ++++++++++++++ ...Expression_nullishCoalescingExpression.ets | 31 ++++++++++++ ...ionCallExpression_relationalExpression.ets | 33 +++++++++++++ ...functionCallExpression_returnStatement.ets | 32 +++++++++++++ ...functionCallExpression_shiftExpression.ets | 33 +++++++++++++ .../functionCallExpression_statement.ets | 41 ++++++++++++++++ ...tionCallExpression_stringInterpolation.ets | 30 ++++++++++++ ...functionCallExpression_switchStatement.ets | 35 ++++++++++++++ ...ctionCallExpression_trailingLambdaCall.ets | 39 +++++++++++++++ .../functionCallExpression_tryStatement.ets | 37 +++++++++++++++ ...functionCallExpression_unaryExpression.ets | 45 ++++++++++++++++++ .../functionCallExpression_whileStatement.ets | 37 +++++++++++++++ ...nthesizedExpression_additiveExpression.ets | 29 ++++++++++++ ...esizedExpression_annotationDeclaration.ets | 30 ++++++++++++ ...arenthesizedExpression_annotationUsage.ets | 37 +++++++++++++++ ...hesizedExpression_assignmentExpression.ets | 28 +++++++++++ ...arenthesizedExpression_awaitExpression.ets | 31 ++++++++++++ ...Expression_bitwiseAndLogicalExpression.ets | 37 +++++++++++++++ ...parenthesizedExpression_castExpression.ets | 30 ++++++++++++ ...renthesizedExpression_classInitializer.ets | 32 +++++++++++++ ...zedExpression_conditionalAndExpression.ets | 34 ++++++++++++++ ...esizedExpression_conditionalExpression.ets | 34 ++++++++++++++ ...izedExpression_conditionalOrExpression.ets | 34 ++++++++++++++ ...nthesizedExpression_constantExpression.ets | 32 +++++++++++++ ...dExpression_ensureNotNullishExpression.ets | 29 ++++++++++++ ...nthesizedExpression_equalityExpression.ets | 31 ++++++++++++ ...esizedExpression_fieldAccessExpression.ets | 32 +++++++++++++ .../parenthesizedExpression_finallyClause.ets | 37 +++++++++++++++ ...parenthesizedExpression_forOfStatement.ets | 31 ++++++++++++ .../parenthesizedExpression_forStatement.ets | 31 ++++++++++++ ...sizedExpression_functionCallExpression.ets | 32 +++++++++++++ ...zedExpression_functionTypeWithReceiver.ets | 29 ++++++++++++ .../parenthesizedExpression_ifStatement.ets | 31 ++++++++++++ ...nthesizedExpression_indexingExpression.ets | 29 ++++++++++++ ...hesizedExpression_instanceOfExpression.ets | 29 ++++++++++++ ...renthesizedExpression_lambdaExpression.ets | 30 ++++++++++++ ...xpression_lambdaExpressionWithReceiver.ets | 34 ++++++++++++++ .../parenthesizedExpression_loopStatement.ets | 37 +++++++++++++++ ...hesizedExpression_methodCallExpression.ets | 34 ++++++++++++++ ...renthesizedExpression_newArrayInstance.ets | 29 ++++++++++++ .../parenthesizedExpression_newExpression.ets | 32 +++++++++++++ ...Expression_nullishCoalescingExpression.ets | 28 +++++++++++ ...hesizedExpression_relationalExpression.ets | 32 +++++++++++++ ...arenthesizedExpression_returnStatement.ets | 32 +++++++++++++ ...arenthesizedExpression_shiftExpression.ets | 30 ++++++++++++ .../parenthesizedExpression_statement.ets | 38 +++++++++++++++ ...thesizedExpression_stringInterpolation.ets | 30 ++++++++++++ ...arenthesizedExpression_switchStatement.ets | 29 ++++++++++++ ...parenthesizedExpression_thisExpression.ets | 36 ++++++++++++++ ...parenthesizedExpression_throwStatement.ets | 29 ++++++++++++ ...nthesizedExpression_trailingLambdaCall.ets | 39 +++++++++++++++ .../parenthesizedExpression_tryStatement.ets | 34 ++++++++++++++ ...renthesizedExpression_typeOfExpression.ets | 29 ++++++++++++ ...arenthesizedExpression_unaryExpression.ets | 35 ++++++++++++++ ...parenthesizedExpression_whileStatement.ets | 34 ++++++++++++++ .../spreadExpression_assignmentExpression.ets | 29 ++++++++++++ .../spreadExpression_awaitExpression.ets | 35 ++++++++++++++ .../spreadExpression_castExpression.ets | 30 ++++++++++++ .../spreadExpression_classInitializer.ets | 32 +++++++++++++ ...eadExpression_conditionalAndExpression.ets | 32 +++++++++++++ ...spreadExpression_conditionalExpression.ets | 32 +++++++++++++ ...readExpression_conditionalOrExpression.ets | 29 ++++++++++++ .../spreadExpression_constantExpression.ets | 29 ++++++++++++ ...dExpression_ensureNotNullishExpression.ets | 30 ++++++++++++ .../spreadExpression_equalityExpression.ets | 29 ++++++++++++ .../spreadExpression_finallyClause.ets | 38 +++++++++++++++ .../spreadExpression_forStatement.ets | 33 +++++++++++++ ...preadExpression_functionCallExpression.ets | 35 ++++++++++++++ .../spreadExpression_ifStatement.ets | 31 ++++++++++++ .../spreadExpression_initializerBlock.ets | 34 ++++++++++++++ .../spreadExpression_instanceOfExpression.ets | 31 ++++++++++++ .../spreadExpression_loopStatement.ets | 38 +++++++++++++++ .../spreadExpression_methodCallExpression.ets | 35 ++++++++++++++ .../spreadExpression_namespaceDeclaration.ets | 34 ++++++++++++++ .../spreadExpression_newArrayInstance.ets | 31 ++++++++++++ .../spreadExpression_newExpression.ets | 32 +++++++++++++ ...Expression_nullishCoalescingExpression.ets | 29 ++++++++++++ ...readExpression_parenthesizedExpression.ets | 29 ++++++++++++ .../spreadExpression_statement.ets | 40 ++++++++++++++++ .../spreadExpression_stringInterpolation.ets | 30 ++++++++++++ .../spreadExpression_thisExpression.ets | 32 +++++++++++++ .../spreadExpression_trailingLambdaCall.ets | 43 +++++++++++++++++ .../spreadExpression_tryStatement.ets | 38 +++++++++++++++ .../spreadExpression_typeOfExpression.ets | 32 +++++++++++++ .../spreadExpression_whileStatement.ets | 32 +++++++++++++ 250 files changed, 8422 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_additiveExpression.ets new file mode 100644 index 0000000000..e2cc4c9482 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.ets new file mode 100644 index 0000000000..580b03519e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_annotationUsage.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.ets new file mode 100644 index 0000000000..d5c1873b28 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_arrayLiteral.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.ets new file mode 100644 index 0000000000..dd637714c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_assignmentExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets new file mode 100644 index 0000000000..763ffc5008 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..8c4e6dff64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets new file mode 100644 index 0000000000..ca7ed31bcf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_classInitializer.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalAndExpression.ets new file mode 100644 index 0000000000..114285ccc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalExpression.ets new file mode 100644 index 0000000000..e7dc9f1424 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_conditionalOrExpression.ets new file mode 100644 index 0000000000..58d51036bc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_constantExpression.ets new file mode 100644 index 0000000000..c92cd760db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets new file mode 100644 index 0000000000..54086063aa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.ets new file mode 100644 index 0000000000..ec07820833 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_expression.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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets new file mode 100644 index 0000000000..faecb4228a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.ets new file mode 100644 index 0000000000..2450559b19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionCallExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..b01a2ec778 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_functionTypeWithReceiver.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets new file mode 100644 index 0000000000..ab4b8e2c25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2 ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets new file mode 100644 index 0000000000..53e3d25614 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..33440e5ed0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.ets new file mode 100644 index 0000000000..c97d848265 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_methodCallExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_multiplicativeExpression.ets new file mode 100644 index 0000000000..8ee3fbda65 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets new file mode 100644 index 0000000000..75279a11c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..edc2d269fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectLiteral.ets new file mode 100644 index 0000000000..98d3bd977c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_objectReference.ets new file mode 100644 index 0000000000..34657daf64 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C();c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.ets new file mode 100644 index 0000000000..c5e7534c00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_parenthesizedExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_recordLiteral.ets new file mode 100644 index 0000000000..fc9f165844 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets new file mode 100644 index 0000000000..92910d4cce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.ets new file mode 100644 index 0000000000..d4cff8330c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_restParameter.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets new file mode 100644 index 0000000000..f18360f332 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_shiftExpression.ets new file mode 100644 index 0000000000..4a4c021739 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_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 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets new file mode 100644 index 0000000000..b9c89e844a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.ets new file mode 100644 index 0000000000..fd20008892 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_thisExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets new file mode 100644 index 0000000000..74f2ac700f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.ets new file mode 100644 index 0000000000..2f87de5ee6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeArguments.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.ets new file mode 100644 index 0000000000..ed28c4509c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_typeParameters.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.ets new file mode 100644 index 0000000000..67513bad22 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/optionalParameter/optionalParameter_unaryExpression.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.8.1 + * optionalParameter: + * identifier':' type'='expression + * | identifier'?'':' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_additiveExpression.ets new file mode 100644 index 0000000000..0d87134c4f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.ets new file mode 100644 index 0000000000..e3f3d8311f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_annotationUsage.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.ets new file mode 100644 index 0000000000..429cb2c142 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_arrayLiteral.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.ets new file mode 100644 index 0000000000..19c5a9a006 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_assignmentExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets new file mode 100644 index 0000000000..184272b577 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_awaitExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..7f883c0d5a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_bitwiseAndLogicalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets new file mode 100644 index 0000000000..97359f5699 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_classInitializer.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalAndExpression.ets new file mode 100644 index 0000000000..88cd8df3e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalExpression.ets new file mode 100644 index 0000000000..856b61c0fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_conditionalOrExpression.ets new file mode 100644 index 0000000000..0db11c73a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_constantExpression.ets new file mode 100644 index 0000000000..d543988540 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets new file mode 100644 index 0000000000..0146c99e3c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_equalityExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.ets new file mode 100644 index 0000000000..e9f8ff35e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_expression.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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets new file mode 100644 index 0000000000..0e9d5d9b5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.ets new file mode 100644 index 0000000000..d66c631a98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionCallExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..1dd13bb210 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_functionTypeWithReceiver.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.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets new file mode 100644 index 0000000000..263ad99ea5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (, parameter)* (, restParameter)? ,? + * | restParameter ,? + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2 ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets new file mode 100644 index 0000000000..09e6656b1b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..753c0322cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_lambdaExpressionWithReceiver.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.ets new file mode 100644 index 0000000000..9effc877c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_methodCallExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_multiplicativeExpression.ets new file mode 100644 index 0000000000..8f85ea5a76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets new file mode 100644 index 0000000000..4d0031a5e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..52bd5a2d9b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectLiteral.ets new file mode 100644 index 0000000000..4aff118e50 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_objectReference.ets new file mode 100644 index 0000000000..03aa5db411 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.ets new file mode 100644 index 0000000000..e0c862beba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_optionalParameter.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.ets new file mode 100644 index 0000000000..f10232d416 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_parenthesizedExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_recordLiteral.ets new file mode 100644 index 0000000000..45f7eaf4f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets new file mode 100644 index 0000000000..c8f220c178 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.ets new file mode 100644 index 0000000000..63e4b50fac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_restParameter.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets new file mode 100644 index 0000000000..48e16242bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_shiftExpression.ets new file mode 100644 index 0000000000..76887cad38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_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 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets new file mode 100644 index 0000000000..9a229f2969 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_stringInterpolation.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.ets new file mode 100644 index 0000000000..b886419a34 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_thisExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets new file mode 100644 index 0000000000..b54ff9a7c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.ets new file mode 100644 index 0000000000..4918e9af19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeArguments.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.ets new file mode 100644 index 0000000000..60989e1adf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_typeParameters.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.ets new file mode 100644 index 0000000000..5179f3adc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/parameterList/parameterList_unaryExpression.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.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets new file mode 100644 index 0000000000..32224b8543 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.ets new file mode 100644 index 0000000000..b0a5cd5b89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_annotationUsage.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.ets new file mode 100644 index 0000000000..e352a4e5cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_arrayLiteral.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.ets new file mode 100644 index 0000000000..0600d3ea3e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_assignmentExpression.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_awaitExpression.ets new file mode 100644 index 0000000000..93a2208687 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..3c368631dc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets new file mode 100644 index 0000000000..49b47b6a3a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalAndExpression.ets new file mode 100644 index 0000000000..65658e88de --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalExpression.ets new file mode 100644 index 0000000000..5ebe0d58b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_conditionalOrExpression.ets new file mode 100644 index 0000000000..ddfc8e7b41 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.ets new file mode 100644 index 0000000000..a84f4dab00 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_constantExpression.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets new file mode 100644 index 0000000000..e0cdbb2c08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets new file mode 100644 index 0000000000..a8ca5ade98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_expression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets new file mode 100644 index 0000000000..e722d79d2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionCallExpression.ets new file mode 100644 index 0000000000..017a88b487 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..33cdb9ab1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_functionTypeWithReceiver.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} + +type FA = (this: dollar, z?: number, ...numbers: number[]) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_initializerBlock.ets new file mode 100644 index 0000000000..f1871f118c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]) { + let sum = 1.2 + 2; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets new file mode 100644 index 0000000000..8e70f9b78c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..a639e9504e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_methodCallExpression.ets new file mode 100644 index 0000000000..f25713ca36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.ets new file mode 100644 index 0000000000..02eeb897a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_multiplicativeExpression.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets new file mode 100644 index 0000000000..f3edb4e751 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..b504521e55 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.ets new file mode 100644 index 0000000000..c147e2a11b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectLiteral.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_objectReference.ets new file mode 100644 index 0000000000..855a693ff1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_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 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.ets new file mode 100644 index 0000000000..0731e38e6c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_parenthesizedExpression.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.ets new file mode 100644 index 0000000000..3a3ad93009 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_recordLiteral.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets new file mode 100644 index 0000000000..af81a1cbec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets new file mode 100644 index 0000000000..93a983939e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets new file mode 100644 index 0000000000..420672bbb5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.ets new file mode 100644 index 0000000000..46317f76fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_stringInterpolation.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.ets new file mode 100644 index 0000000000..09840fca80 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_thisExpression.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets new file mode 100644 index 0000000000..b38a0c64af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.ets new file mode 100644 index 0000000000..dd08af8a0d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeArguments.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.ets new file mode 100644 index 0000000000..b65d3b6a98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_typeParameters.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.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets new file mode 100644 index 0000000000..d079e072b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/restParameter/restParameter_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets new file mode 100644 index 0000000000..f4ff5952a2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.ets new file mode 100644 index 0000000000..d99222724a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_annotationUsage.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar {} + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.ets new file mode 100644 index 0000000000..75bd684881 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_arrayLiteral.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.ets new file mode 100644 index 0000000000..1b885b88d8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_assignmentExpression.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_awaitExpression.ets new file mode 100644 index 0000000000..245d762eaf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..48fa038c9d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets new file mode 100644 index 0000000000..54e7fd400d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalAndExpression.ets new file mode 100644 index 0000000000..e2112d65d6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalExpression.ets new file mode 100644 index 0000000000..4f426eb75e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_conditionalOrExpression.ets new file mode 100644 index 0000000000..3faa455f98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.ets new file mode 100644 index 0000000000..fa0831b9f7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_constantExpression.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets new file mode 100644 index 0000000000..e198abbe73 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets new file mode 100644 index 0000000000..46276b15ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_expression.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets new file mode 100644 index 0000000000..d6413b654d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let func1: () => void; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_functionCallExpression.ets new file mode 100644 index 0000000000..27863accd3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets new file mode 100644 index 0000000000..0391f30f11 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: () => void; + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..16efa94c4f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: () => void; + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_methodCallExpression.ets new file mode 100644 index 0000000000..5d83fdcf5b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +person.setName(1, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.ets new file mode 100644 index 0000000000..93605a0ec5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_multiplicativeExpression.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets new file mode 100644 index 0000000000..dbddce7d41 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_namespaceDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..0db2280e99 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number = null ?? 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.ets new file mode 100644 index 0000000000..bf004ab41a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectLiteral.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; + sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_objectReference.ets new file mode 100644 index 0000000000..54ae860e0b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_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 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.ets new file mode 100644 index 0000000000..acfad68258 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_optionalParameter.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.ets new file mode 100644 index 0000000000..1185055f8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parameterList.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.ets new file mode 100644 index 0000000000..fce81bd4bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_parenthesizedExpression.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +function sum(x: number, y: number = 3 * 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(5, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.ets new file mode 100644 index 0000000000..1cd3b17b68 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_recordLiteral.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +function sum(x: Record, y?: number, ...numbers: number[]): void {} + +sum({"John": 25}, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets new file mode 100644 index 0000000000..111c6d9e88 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean = 3 < 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, false, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.ets new file mode 100644 index 0000000000..ecb5b273f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_restParameter.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets new file mode 100644 index 0000000000..bd151274ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return 0; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets new file mode 100644 index 0000000000..7414547517 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number = 3 >> 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.ets new file mode 100644 index 0000000000..9cfb159c98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_stringInterpolation.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.ets new file mode 100644 index 0000000000..00261c1882 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_thisExpression.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: C, n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets new file mode 100644 index 0000000000..314684cea7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.ets new file mode 100644 index 0000000000..04d8800861 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeArguments.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type (',' type)* '>' + * ; + */ + +class StaticExample { + private add(x: number, y?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.ets new file mode 100644 index 0000000000..74767f90ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_typeParameters.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.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets new file mode 100644 index 0000000000..fda441e5c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/4_names_declarations_and_scopes/signature/signature_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * ( parameterList? ) returnType? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: number, y: boolean = !true, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, true, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets new file mode 100644 index 0000000000..9e85175668 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_additiveExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.ets new file mode 100644 index 0000000000..771d2104c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_annotationUsage.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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface dollar { } + +@dollar function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets new file mode 100644 index 0000000000..2a755c546a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_assignmentExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let arr: number[] = [1, 2, 3]; +sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_awaitExpression.ets new file mode 100644 index 0000000000..4a1cbcef51 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..8855bb31b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(5 & 3, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.ets new file mode 100644 index 0000000000..b5990221e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_castExpression.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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +function sum(x: number, y: int = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +let flo = 2.3; +let y: int = flo as int; +await sum(5 & 3, y, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..ed7fb6def2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalExpression.ets new file mode 100644 index 0000000000..dfde2f1b37 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum((7 > 5) ? 7 : 5, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..76f39bf78f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" || "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets new file mode 100644 index 0000000000..d79d1f9afc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_constantExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..e6905ba675 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +let x = 3; +sum(x!, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets new file mode 100644 index 0000000000..5284467fb2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum(7 == 5, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets new file mode 100644 index 0000000000..11fbd362a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forOfStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let dollar of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_forStatement.ets new file mode 100644 index 0000000000..417213d924 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +for (let dollar = 1; dollar < 10; dollar++) { + if (true) { + sum(7 == 5, 2, 3); + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets new file mode 100644 index 0000000000..1cf93bb207 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_ifStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +if ((true)) { + sum(7 == 5, 2, 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_indexingExpression.ets new file mode 100644 index 0000000000..77d623858a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +let arr = [1, 2, 3]; +sum(arr[0], 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets new file mode 100644 index 0000000000..0c906e47ec --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_loopStatement.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; + +while(!unionArray) { + sum(7 == 5, 2, 3); + break +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.ets new file mode 100644 index 0000000000..35c00ef0a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_multiplicativeExpression.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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 3 * 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..19ffe4af77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, null ?? 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.ets new file mode 100644 index 0000000000..2137226f81 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_relationalExpression.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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: number, y: boolean, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, 3 < 2, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets new file mode 100644 index 0000000000..e57c76ce54 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): void {} + +function call(): void { + sum(1, 2, 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets new file mode 100644 index 0000000000..0f9d330f9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +function sum(x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1;} + +sum(1, 3 >> 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets new file mode 100644 index 0000000000..9c46c15638 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets new file mode 100644 index 0000000000..46ca16c695 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = 'Alice'; +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets new file mode 100644 index 0000000000..8aa27631be --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_switchStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let a = 0; +switch (a) { + case 0: + sum("name", 2, 3, 4); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..63a3d6bc1d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets new file mode 100644 index 0000000000..eea9420b54 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_tryStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +function processTwo(a: number): number { + try { + sum("name", 2, 3, 4); + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.ets new file mode 100644 index 0000000000..75391a23a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_unaryExpression.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.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +function sum(x: boolean, y?: number, ...numbers: number[]): void {} + +let a = 2; +let b = 3; +let c = 4; +let d = 5; +let e = 2; +let f = -3; +let g = 4; +let h = 5; + +sum(!h, a++, ++b, c--, --d, +e, -f, ~g); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets new file mode 100644 index 0000000000..c96c34e9af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/functionCallExpression/functionCallExpression_whileStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.11 + * functionCallExpression: + * expression('?.'| typeArguments)?argumentsblock? + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let a = 5; +let b = 3; + +while((a > b)) { + a--; + sum("name", 2, 3, 4); + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_additiveExpression.ets new file mode 100644 index 0000000000..b3f6fbfa12 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +(2 + 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.ets new file mode 100644 index 0000000000..050cfd6fae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationDeclaration.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface dollar { + a: number = (2 + 3); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.ets new file mode 100644 index 0000000000..181129f998 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_annotationUsage.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface Version { + versionNumber: number; +} + +@Version( (2 + 3) ) +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets new file mode 100644 index 0000000000..9460586506 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let y: number = 3; +(y = 4) diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets new file mode 100644 index 0000000000..b763f7f4e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_awaitExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function main() { + let result = await Promise.resolve(2 + 3); + console.log(result); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..0acb04d62c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(((5 & 3) | (2 ^ 1)), (3 + 2), 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_castExpression.ets new file mode 100644 index 0000000000..8c8dbb7030 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1: X = new X(); +let dollar: Object = (x1) as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets new file mode 100644 index 0000000000..d6af1e5818 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + static add(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return (x + 1); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..37cbe9144d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: * expression '&&' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum("a" && "b", 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalExpression.ets new file mode 100644 index 0000000000..72f03abd26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: * expression '?' expression ':' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(((7 > 5) ? 7 : 5), 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..d45afb3274 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: * expression '||' expression + * ; + */ + +function sum(x: string, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(("a" || "b"), 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.ets new file mode 100644 index 0000000000..538da23d8f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_constantExpression.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +function sum(x: number, y: number = (3 + 2), z?: number, ...numbers: number[]): number { + return x + 1; +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..5828eea699 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let dollar: string | null = "Hello"; +(dollar!); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets new file mode 100644 index 0000000000..26952de3ce --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +function sum(x: boolean, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +sum((7 == 5), 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets new file mode 100644 index 0000000000..5996877b7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_fieldAccessExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person { + name: string = "Unknown"; +} +let dollar = new Person(); +(dollar.name) = "Alice"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets new file mode 100644 index 0000000000..c5a27e0ce9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_finallyClause.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + (2 + 1) + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forOfStatement.ets new file mode 100644 index 0000000000..2ebbd3d1b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +for (let dollar of (arr)) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets new file mode 100644 index 0000000000..51bb8be4de --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_forStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.6 + * Identifier: + * IdentifierStart IdentifierPart* + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +for (let dollar = 1;(dollar < 10);(dollar++)) { + if (true) { + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionCallExpression.ets new file mode 100644 index 0000000000..0945b38726 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + return 0; +} + +(sum(7, 2, 3)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..ab870c1557 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter (',' ftParameterList)? ')' ftReturnType + * ; + */ + +class dollar {} +type FA = ((this: dollar) => boolean); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_ifStatement.ets new file mode 100644 index 0000000000..3942d84aa2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if ((true)) { + let dollar = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_indexingExpression.ets new file mode 100644 index 0000000000..849c9da828 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +const arr: number[] | null = null; +(arr?.[0]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..6271906037 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let str: string = new String("Hello"); +(str instanceof String); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets new file mode 100644 index 0000000000..daff30ddba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise => { + let func1: (() => void); + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..9214f948d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A, x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number => { + let func1: (() => void); + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.ets new file mode 100644 index 0000000000..6ac9d9d432 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_loopStatement.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let a = 1; +while((a > 0)) { + let dollar = 1; + a--; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_methodCallExpression.ets new file mode 100644 index 0000000000..c3f0e4757a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +(person.setName(1, 2, 3, 4)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newArrayInstance.ets new file mode 100644 index 0000000000..7557807416 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let dollar = 1; +let a = (new string[dollar]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_newExpression.ets new file mode 100644 index 0000000000..58065b887b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class dollar { + constructor(p: number) {} +} +let instance = (new dollar(5)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..7c872ec5d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_nullishCoalescingExpression.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +(null ?? 2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets new file mode 100644 index 0000000000..edb009ca94 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.24 + * relationalExpression: * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +function sum(x: boolean, y: boolean, z: boolean): void {} + +sum((1 < 2), (3 < 2), (1 <= 2)); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets new file mode 100644 index 0000000000..f005eeec02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_returnStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function sum(x: number, y?: number, ...numbers: number[]): number { + return (2 + 3); +} + +sum(1, 2, 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_shiftExpression.ets new file mode 100644 index 0000000000..36e068d202 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +(3 >> 2) diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_statement.ets new file mode 100644 index 0000000000..825f85ef83 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let dollar = (10); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.ets new file mode 100644 index 0000000000..5d3164e6ea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_stringInterpolation.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +function sum(x: string, y?: number, ...numbers: number[]): void {} + +let name = ('Alice'); +sum(name, 2, 3, 4); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets new file mode 100644 index 0000000000..8ca5c2534b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_switchStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let a = 0; +switch ((a)) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.ets new file mode 100644 index 0000000000..51863db3c8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_thisExpression.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class C {} +function sum(this: C, x: number, y: number, z?: number, ...numbers: number[]): number { + return x + 1; +} +function bar(this: (C), n: number): void {} + +let c = new C(); +c.sum(1, 2, 3); +bar(c, 1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets new file mode 100644 index 0000000000..843087ea75 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let err = new Error(); +throw (err); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..37cbabc9f3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_trailingLambdaCall.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +(a.methodTwo)("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.ets new file mode 100644 index 0000000000..0744b4da51 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_tryStatement.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + return (3 + 2); + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets new file mode 100644 index 0000000000..022158321d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let n: number = 1; +(typeof n); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_unaryExpression.ets new file mode 100644 index 0000000000..577d17d383 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_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 4.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 7.20 + * unaryExpression: * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let dollar = 5; +(dollar++); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.ets new file mode 100644 index 0000000000..8367705f7b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/parenthesizedExpression/parenthesizedExpression_whileStatement.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.8.1 + * parenthesizedExpression: + * '(' expression ')' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let a = 5; +let b = 3; + +while((a > b)) { + a--; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets new file mode 100644 index 0000000000..1f6f251212 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.29 + * assignmentExpression: * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_awaitExpression.ets new file mode 100644 index 0000000000..02eb826be7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_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.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_castExpression.ets new file mode 100644 index 0000000000..dbcf7806bb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_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 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets new file mode 100644 index 0000000000..8afce656c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_classInitializer.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass2 { + first = [1, 2]; + second = [3, 4]; + unionArray = [...this.first, ...this.second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets new file mode 100644 index 0000000000..b18bc04e76 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalAndExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let useFirst = true; + +[...second] && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets new file mode 100644 index 0000000000..8b61916fd3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let useFirst = true; + +let result = [...(useFirst ? first : second), 5, 6]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets new file mode 100644 index 0000000000..108220345f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first || [10]]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets new file mode 100644 index 0000000000..cba062368f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first || [10]]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..ee07da8ece --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ensureNotNullishExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first!, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets new file mode 100644 index 0000000000..01a4db30c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.25 + * equalityExpression: * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets new file mode 100644 index 0000000000..9f8fbc1a8c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_finallyClause.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): number { + let first = [1, 2]; + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + [...first]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets new file mode 100644 index 0000000000..bef2ae00da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_forStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let first = [1, 2]; +let unionArray = [...first]; +for (;unionArray;) { + if (true) { + break; + } } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.ets new file mode 100644 index 0000000000..79e08ebbae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_functionCallExpression.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.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function sum(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): Promise { + return new Promise((resolve, reject) => { + resolve("a"); + }); +} + +let arr: number[] = [1, 2, 3]; +await sum(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_ifStatement.ets new file mode 100644 index 0000000000..3b3df5e87d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_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 2.6 + * Identifier: + * IdentifierStart IdentifierPart* + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets new file mode 100644 index 0000000000..2ad7f6ba55 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_initializerBlock.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = [...first, ...second]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets new file mode 100644 index 0000000000..167dca73a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_instanceOfExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; +unionArray instanceof Array; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets new file mode 100644 index 0000000000..9feffa0966 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_loopStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = [...first, ...second]; + +while(!unionArray) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.ets new file mode 100644 index 0000000000..a8c3c40844 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_methodCallExpression.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.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(x: number, y: number = 3 + 2, z?: number, ...numbers: number[]): void {} +} + +let person = new Person2(); +let arr: number[] = [1, 2, 3]; +person.setName(1, 2, 3, ...arr); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets new file mode 100644 index 0000000000..dd6e967fd1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = new number[5]; + unionArray = [...first, ...second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets new file mode 100644 index 0000000000..44be6b91e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newArrayInstance.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_newExpression.ets new file mode 100644 index 0000000000..24b43e680e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_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 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..49417dec32 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let first = [1, 2]; +let unionArray = [...first] ?? [10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets new file mode 100644 index 0000000000..fc6b027579 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_parenthesizedExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let first = [1, 2]; +let unionArray = ([...first]) ?? [10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets new file mode 100644 index 0000000000..17e8a0dd5d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_statement.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throwStatementt + * | tryStatement + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +if([...first] == [...second]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets new file mode 100644 index 0000000000..618f20a894 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.31 + * stringInterpolation: * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +let first = ['Alice']; +let unionArray = new string[5]; +unionArray = [...first]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets new file mode 100644 index 0000000000..0cd43741c3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_thisExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ExampleClass2 { + first = [1, 2]; + second = [3, 4]; + unionArray = [...this.first, ...this.second]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets new file mode 100644 index 0000000000..1574594090 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_trailingLambdaCall.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(x: T, callback: (result: T) => void): void { + const result = x; + callback(result); + } +} + +let a = new A(); +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; +a.methodTwo(unionArray) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets new file mode 100644 index 0000000000..5afcf3b302 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processTwo(a: number): number { + try { + let first = [1, 2]; + let second = [3, 4]; + let unionArray = new number[5]; + unionArray = [...first, ...second]; + return 0; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets new file mode 100644 index 0000000000..9e522164dc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_typeOfExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let first = [1, 2]; +let second = [3, 4]; +let unionArray = new number[5]; +unionArray = [...first, ...second]; +typeof unionArray; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets new file mode 100644 index 0000000000..a1dc3ce65f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/spreadExpression/spreadExpression_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let first = [1, 2]; + +while([...first]!) { + break; +} -- Gitee