From 9cb8fdf99647af7e02da4ffb044bb539518af1e6 Mon Sep 17 00:00:00 2001 From: liujia178 Date: Wed, 23 Apr 2025 14:26:01 +0800 Subject: [PATCH] arrayLiteral&objectLiteral&recordLiteral Signed-off-by: liujia178 --- .../arrayLiteral_annotationDeclaration.ets | 30 +++++++++++++ .../arrayLiteral_annotationUsage.ets | 36 ++++++++++++++++ .../arrayLiteral_assignmentExpression.ets | 28 +++++++++++++ .../arrayLiteral_awaitExpression.ets | 33 +++++++++++++++ .../arrayLiteral_classInitializer.ets | 35 ++++++++++++++++ .../arrayLiteral_conditionalExpression.ets | 28 +++++++++++++ .../arrayLiteral_constantExpression.ets | 28 +++++++++++++ ...rrayLiteral_ensureNotNullishExpression.ets | 28 +++++++++++++ .../arrayLiteral_equalityExpression.ets | 28 +++++++++++++ .../arrayLiteral_fieldAccessExpression.ets | 33 +++++++++++++++ .../arrayLiteral_forOfStatement.ets | 32 ++++++++++++++ .../arrayLiteral_forStatement.ets | 34 +++++++++++++++ .../arrayLiteral_functionCallExpression.ets | 32 ++++++++++++++ .../arrayLiteral/arrayLiteral_ifStatement.ets | 32 ++++++++++++++ .../arrayLiteral_indexingExpression.ets | 29 +++++++++++++ .../arrayLiteral_initializerBlock.ets | 32 ++++++++++++++ .../arrayLiteral_lambdaExpression.ets | 28 +++++++++++++ ...ayLiteral_lambdaExpressionWithReceiver.ets | 31 ++++++++++++++ .../arrayLiteral_loopStatement.ets | 35 ++++++++++++++++ .../arrayLiteral_methodCallExpression.ets | 36 ++++++++++++++++ .../arrayLiteral_namespaceDeclaration.ets | 31 ++++++++++++++ .../arrayLiteral_newArrayInstance.ets | 29 +++++++++++++ .../arrayLiteral_newExpression.ets | 33 +++++++++++++++ ...rayLiteral_nullishCoalescingExpression.ets | 28 +++++++++++++ .../arrayLiteral_objectLiteral.ets | 32 ++++++++++++++ .../arrayLiteral_parenthesizedExpression.ets | 28 +++++++++++++ .../arrayLiteral_recordLiteral.ets | 31 ++++++++++++++ .../arrayLiteral_returnStatement.ets | 30 +++++++++++++ ...arrayLiteral_separateModuleDeclaration.ets | 29 +++++++++++++ .../arrayLiteral_spreadExpression.ets | 31 ++++++++++++++ .../arrayLiteral/arrayLiteral_statement.ets | 38 +++++++++++++++++ .../arrayLiteral_stringInterpolation.ets | 29 +++++++++++++ .../arrayLiteral_thisExpression.ets | 33 +++++++++++++++ .../arrayLiteral_throwStatement.ets | 28 +++++++++++++ .../arrayLiteral_topDeclaration.ets | 37 ++++++++++++++++ .../arrayLiteral_topLevelStatements.ets | 28 +++++++++++++ .../arrayLiteral_trailingLambdaCall.ets | 38 +++++++++++++++++ .../arrayLiteral_tryStatement.ets | 35 ++++++++++++++++ .../arrayLiteral_typeOfExpression.ets | 29 +++++++++++++ .../arrayLiteral_unaryExpression.ets | 35 ++++++++++++++++ .../arrayLiteral_whileStatement.ets | 31 ++++++++++++++ .../objectLiteral_additiveExpression.ets | 33 +++++++++++++++ .../objectLiteral_assignmentExpression.ets | 31 ++++++++++++++ .../objectLiteral_awaitExpression.ets | 38 +++++++++++++++++ ...ectLiteral_bitwiseAndLogicalExpression.ets | 35 ++++++++++++++++ .../objectLiteral_castExpression.ets | 31 ++++++++++++++ .../objectLiteral_classInitializer.ets | 36 ++++++++++++++++ ...objectLiteral_conditionalAndExpression.ets | 33 +++++++++++++++ .../objectLiteral_conditionalExpression.ets | 33 +++++++++++++++ .../objectLiteral_conditionalOrExpression.ets | 33 +++++++++++++++ .../objectLiteral_constantExpression.ets | 31 ++++++++++++++ ...jectLiteral_ensureNotNullishExpression.ets | 32 ++++++++++++++ .../objectLiteral_equalityExpression.ets | 33 +++++++++++++++ .../objectLiteral_fieldAccessExpression.ets | 33 +++++++++++++++ .../objectLiteral_finallyClause.ets | 38 +++++++++++++++++ .../objectLiteral_forOfStatement.ets | 39 +++++++++++++++++ .../objectLiteral_forStatement.ets | 38 +++++++++++++++++ .../objectLiteral_functionCallExpression.ets | 35 ++++++++++++++++ ...objectLiteral_functionTypeWithReceiver.ets | 31 ++++++++++++++ .../objectLiteral_ifStatement.ets | 35 ++++++++++++++++ .../objectLiteral_indexingExpression.ets | 32 ++++++++++++++ .../objectLiteral_initializerBlock.ets | 35 ++++++++++++++++ .../objectLiteral_instanceOfExpression.ets | 32 ++++++++++++++ .../objectLiteral_lambdaExpression.ets | 34 +++++++++++++++ ...ctLiteral_lambdaExpressionWithReceiver.ets | 31 ++++++++++++++ .../objectLiteral_loopStatement.ets | 38 +++++++++++++++++ .../objectLiteral_methodCallExpression.ets | 36 ++++++++++++++++ ...objectLiteral_multiplicativeExpression.ets | 34 +++++++++++++++ .../objectLiteral_namespaceDeclaration.ets | 34 +++++++++++++++ .../objectLiteral_newArrayInstance.ets | 32 ++++++++++++++ .../objectLiteral_newExpression.ets | 33 +++++++++++++++ ...ectLiteral_nullishCoalescingExpression.ets | 32 ++++++++++++++ .../objectLiteral_parenthesizedExpression.ets | 32 ++++++++++++++ .../objectLiteral_recordLiteral.ets | 32 ++++++++++++++ .../objectLiteral_relationalExpression.ets | 35 ++++++++++++++++ .../objectLiteral_returnStatement.ets | 34 +++++++++++++++ ...bjectLiteral_separateModuleDeclaration.ets | 32 ++++++++++++++ .../objectLiteral_shiftExpression.ets | 34 +++++++++++++++ .../objectLiteral_spreadExpression.ets | 35 ++++++++++++++++ .../objectLiteral/objectLiteral_statement.ets | 41 ++++++++++++++++++ .../objectLiteral_stringInterpolation.ets | 32 ++++++++++++++ .../objectLiteral_switchStatement.ets | 34 +++++++++++++++ .../objectLiteral_thisExpression.ets | 34 +++++++++++++++ .../objectLiteral_throwStatement.ets | 32 ++++++++++++++ .../objectLiteral_topDeclaration.ets | 40 ++++++++++++++++++ .../objectLiteral_topLevelStatements.ets | 31 ++++++++++++++ .../objectLiteral_trailingLambdaCall.ets | 40 ++++++++++++++++++ .../objectLiteral_tryStatement.ets | 39 +++++++++++++++++ .../objectLiteral_typeOfExpression.ets | 32 ++++++++++++++ .../objectLiteral_unaryExpression.ets | 39 +++++++++++++++++ .../objectLiteral_whileStatement.ets | 34 +++++++++++++++ .../recordLiteral_assignmentExpression.ets | 28 +++++++++++++ .../recordLiteral_awaitExpression.ets | 34 +++++++++++++++ .../recordLiteral_castExpression.ets | 36 ++++++++++++++++ .../recordLiteral_classInitializer.ets | 36 ++++++++++++++++ ...recordLiteral_conditionalAndExpression.ets | 30 +++++++++++++ .../recordLiteral_conditionalExpression.ets | 30 +++++++++++++ .../recordLiteral_conditionalOrExpression.ets | 30 +++++++++++++ .../recordLiteral_constantExpression.ets | 28 +++++++++++++ ...cordLiteral_ensureNotNullishExpression.ets | 29 +++++++++++++ .../recordLiteral_equalityExpression.ets | 30 +++++++++++++ .../recordLiteral_fieldAccessExpression.ets | 39 +++++++++++++++++ .../recordLiteral_finallyClause.ets | 34 +++++++++++++++ .../recordLiteral_forStatement.ets | 34 +++++++++++++++ .../recordLiteral_functionCallExpression.ets | 32 ++++++++++++++ ...recordLiteral_functionTypeWithReceiver.ets | 28 +++++++++++++ .../recordLiteral_ifStatement.ets | 33 +++++++++++++++ .../recordLiteral_indexingExpression.ets | 32 ++++++++++++++ .../recordLiteral_initializerBlock.ets | 32 ++++++++++++++ .../recordLiteral_instanceOfExpression.ets | 29 +++++++++++++ .../recordLiteral_lambdaExpression.ets | 31 ++++++++++++++ ...rdLiteral_lambdaExpressionWithReceiver.ets | 34 +++++++++++++++ .../recordLiteral_loopStatement.ets | 36 ++++++++++++++++ .../recordLiteral_methodCallExpression.ets | 42 +++++++++++++++++++ .../recordLiteral_namespaceDeclaration.ets | 31 ++++++++++++++ .../recordLiteral_newArrayInstance.ets | 29 +++++++++++++ .../recordLiteral_newExpression.ets | 33 +++++++++++++++ ...ordLiteral_nullishCoalescingExpression.ets | 29 +++++++++++++ .../recordLiteral_parenthesizedExpression.ets | 31 ++++++++++++++ .../recordLiteral_returnStatement.ets | 31 ++++++++++++++ ...ecordLiteral_separateModuleDeclaration.ets | 29 +++++++++++++ .../recordLiteral_spreadExpression.ets | 35 ++++++++++++++++ .../recordLiteral/recordLiteral_statement.ets | 38 +++++++++++++++++ .../recordLiteral_stringInterpolation.ets | 29 +++++++++++++ .../recordLiteral_thisExpression.ets | 39 +++++++++++++++++ .../recordLiteral_throwStatement.ets | 29 +++++++++++++ .../recordLiteral_topDeclaration.ets | 37 ++++++++++++++++ .../recordLiteral_topLevelStatements.ets | 28 +++++++++++++ .../recordLiteral_trailingLambdaCall.ets | 38 +++++++++++++++++ .../recordLiteral_tryStatement.ets | 36 ++++++++++++++++ .../recordLiteral_typeOfExpression.ets | 29 +++++++++++++ .../recordLiteral_unaryExpression.ets | 36 ++++++++++++++++ .../recordLiteral_whileStatement.ets | 32 ++++++++++++++ 133 files changed, 4370 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_whileStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_castExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionTypeWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationDeclaration.ets new file mode 100644 index 0000000000..61dc594037 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface a { + value: number[] = [10]; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationUsage.ets new file mode 100644 index 0000000000..4479421bfb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_annotationUsage.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface DetailedAnnotation { + authorName: string[]; + creationDate: string[]; +} +@DetailedAnnotation({ + authorName: ["张三"], + creationDate: ["2025-03-19"] +}) +class DocumentedClass {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_assignmentExpression.ets new file mode 100644 index 0000000000..23ed5d07cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = [5, 6]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_awaitExpression.ets new file mode 100644 index 0000000000..bf7d6b81bb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise { + return new Promise((resolve, reject) => { + resolve([1, 2]); + }); +} +const res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_classInitializer.ets new file mode 100644 index 0000000000..a54fae73c0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = [1, 2]; + static initializerBlock() { + if (ExampleClass1.initialized == [1, 2]) { + ExampleClass1.initialized = [1, 2, 3]; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_conditionalExpression.ets new file mode 100644 index 0000000000..75a85575cc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_conditionalExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +(7 > 5) ? [7] : [5]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_constantExpression.ets new file mode 100644 index 0000000000..f82e71dbd8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const a = [3, 14]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..ba4badc95f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ensureNotNullishExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +[1, 2]!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_equalityExpression.ets new file mode 100644 index 0000000000..5cde11e37b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_equalityExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +[5] == [5]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000..eaf96c623b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_fieldAccessExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + name: number[] = [1, 2]; +} + +let person = new Person1(); +person.name = [1, 2]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forOfStatement.ets new file mode 100644 index 0000000000..47e030946d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forOfStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forStatement.ets new file mode 100644 index 0000000000..ec782fd0cb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_forStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let a = [1, 2]; +let i: number = 1; +for (; i < 10; i++) { + if (a == [1, 2]) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_functionCallExpression.ets new file mode 100644 index 0000000000..b289ec26cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function func1(x: number[]): number { + return 0; +} + +func1([1, 2]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ifStatement.ets new file mode 100644 index 0000000000..f45e1116bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_ifStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let i = [1, 2]; +if (i == [1, 2]) { + console.log("true"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_indexingExpression.ets new file mode 100644 index 0000000000..71d80c9957 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +let numbers = [1, 2, 3, 4, 5]; +numbers[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_initializerBlock.ets new file mode 100644 index 0000000000..ca0b1792ee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let a = [1, 2] ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpression.ets new file mode 100644 index 0000000000..f66fb232b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +(): number[] => { return [1, 2] } diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..157f92e0a7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A): number[] => { return [0, 1]; }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_loopStatement.ets new file mode 100644 index 0000000000..00cf9dc32f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let i = [1, 2]; +while(i == [1, 2]) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_methodCallExpression.ets new file mode 100644 index 0000000000..a29fe4e6a1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_methodCallExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: number[] = [1, 2]; + setName(name: number[]): void { + this.name = name; + } +} + +let person = new Person2(); +person.setName([1, 2]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000..33d29f1b16 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number[] = [1, 2]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newArrayInstance.ets new file mode 100644 index 0000000000..60b5071b8c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new string[3]; +a[0] = "a"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newExpression.ets new file mode 100644 index 0000000000..880348835e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_newExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: number[]) {} +} + +new D([5, 6]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..2000671b9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +null ?? [42, 43]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_objectLiteral.ets new file mode 100644 index 0000000000..cf5d454c9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_objectLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string[] = ["a", "b"] + age: number = 0 +} +let b : Person = {name: ["Bob", "White"], age: 25} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000..646cedc087 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_parenthesizedExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let arr1: number[] = ([1, 2, 3]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_recordLiteral.ets new file mode 100644 index 0000000000..792614a009 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let map: Record = { + "John": [25, 2], + "Mary": [21, 4], +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_returnStatement.ets new file mode 100644 index 0000000000..d6b6d06027 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_returnStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function a() { + return [1, 2]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000..ee470ce9e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_separateModuleDeclaration.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.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a: string[] = ['1', '2']; +console.info('a: ' + a); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_spreadExpression.ets new file mode 100644 index 0000000000..8dce17ea0e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_spreadExpression.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.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let array1 = [1, 2, 3]; +let array2 = [4, 5]; +let array3 = [...array1, ...array2]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_statement.ets new file mode 100644 index 0000000000..b35b8bb9bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let x = [10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_stringInterpolation.ets new file mode 100644 index 0000000000..52156e78fe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = ['Alice']; +`Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_thisExpression.ets new file mode 100644 index 0000000000..37ec0b2440 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_thisExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public field: number[]; + constructor() { + this.field = [1, 2]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_throwStatement.ets new file mode 100644 index 0000000000..8ddcc53fcb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_throwStatement.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error("error" + [1]); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topDeclaration.ets new file mode 100644 index 0000000000..6fb1227d04 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export let x: string[], y: string[]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topLevelStatements.ets new file mode 100644 index 0000000000..f967810c5a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: number[] = [56, 58]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000..ca3bf82259 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_trailingLambdaCall.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +let a = new A(); +a.methodTwo(["Hi"]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_tryStatement.ets new file mode 100644 index 0000000000..981d14e405 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processOne(a: number[]): number[] { + try { + const res = [1]; + return res; + } catch (error) { + return [-1]; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_typeOfExpression.ets new file mode 100644 index 0000000000..c50e5c0b36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let s: string[] = ['a', 'b']; +typeof s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_unaryExpression.ets new file mode 100644 index 0000000000..7bda751b9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_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 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +![3, 5]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_whileStatement.ets new file mode 100644 index 0000000000..383a810daf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/arrayLiteral/arrayLiteral_whileStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let i = [1, 2]; +while(i == [1, 2]) { + i == [1, 2, 3]; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_additiveExpression.ets new file mode 100644 index 0000000000..00c596b957 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a.s + 4; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_assignmentExpression.ets new file mode 100644 index 0000000000..d0197ebbca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_assignmentExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 5}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_awaitExpression.ets new file mode 100644 index 0000000000..4eea22fa5e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_awaitExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +class S { + s: number = 0; +} + +function foo(): Promise { + return new Promise((resolve, reject) => { + let a: S = {s: 5}; + resolve(a); + }); +} +const res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..54c94e63fb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_bitwiseAndLogicalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +let b = new S; +a.s & b.s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_castExpression.ets new file mode 100644 index 0000000000..a5e23a2917 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_castExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X {} +let x1 : X = new X(); +let ob : Object = x1 as Object; +let x2 : X = ob as X; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_classInitializer.ets new file mode 100644 index 0000000000..7140be5d40 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_classInitializer.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = false; + static initializerBlock() { + if (!ExampleClass1.initialized) { + ExampleClass1.initialized = true; + } + } +} +let a = new ExampleClass1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalAndExpression.ets new file mode 100644 index 0000000000..e468e23996 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalAndExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +let b = new S; +a && b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalExpression.ets new file mode 100644 index 0000000000..1b50bc2a58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 7}; +let b: S = {s: 5}; +(7 > 5) ? a : b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalOrExpression.ets new file mode 100644 index 0000000000..a72ecd0683 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_conditionalOrExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +let b = new S; +a || b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_constantExpression.ets new file mode 100644 index 0000000000..315164552b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_constantExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +class S { + s: string = ''; +} +const a: S = {s: 'Alice'}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..179cef640a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ensureNotNullishExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_equalityExpression.ets new file mode 100644 index 0000000000..911cb0c0e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_equalityExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +let b = new S; +a == b; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000..27004741c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_fieldAccessExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + name: string = 'Alice'; +} + +let person = new Person1(); +person.name = 'Bob'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_finallyClause.ets new file mode 100644 index 0000000000..747ef7ec1c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A { + s: number = 0; +} + +function processOne() { + try { + } catch (error) { + } finally { + let x: A = {s: 5}; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forOfStatement.ets new file mode 100644 index 0000000000..57cfed9f33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forOfStatement.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +class A { + aa: number[] = []; +} +class B { + bb: number = 0; +} +let a: A = {aa: [1, 5]}; +let b: B = {bb: 10}; +for (const num of a.aa) { + b.bb = num; + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forStatement.ets new file mode 100644 index 0000000000..45232c731b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_forStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 5}; +let b: S = {s: 10}; +let i: number = 1; +for (; i < 10 && a != b; i++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionCallExpression.ets new file mode 100644 index 0000000000..54b5805c81 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; +} +function func1(x: Person2): number { + return 0; +} +let person = new Person2(); +func1(person); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..5081dfe488 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter(','ftParameterList)?')'ftReturnType + * ; + */ + +class A { + s: number = 0; +} +type F = (a: A) => void; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_ifStatement.ets new file mode 100644 index 0000000000..5691ac96f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +class S { + s: string = ''; +} +let a: S = {s: 'Alice'}; +if (a) { + console.log("true"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_indexingExpression.ets new file mode 100644 index 0000000000..1dbf7e274c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_indexingExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +class S { + s: number[] = []; +} +let a: S = {s: [1, 2, 3, 4, 5]}; +let b = a.s[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_initializerBlock.ets new file mode 100644 index 0000000000..efdfdb0352 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_initializerBlock.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class S { + s: number = 0; +} +class Test { + static initializerBlock() { + let a: S = {s: 56}; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_instanceOfExpression.ets new file mode 100644 index 0000000000..01c388eef7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_instanceOfExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a instanceof S; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpression.ets new file mode 100644 index 0000000000..e4b07c4a7b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +class S { + s: string = ''; +} +let result = async (): Promise => { + let a: S = {s: 'Alice'}; + return a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..f33434bd3b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (a: A): A => { return a; }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_loopStatement.ets new file mode 100644 index 0000000000..1aba6ddc30 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +class S { + s: string = ''; +} +let a: S = {s: 'Alice'}; +while(a) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_methodCallExpression.ets new file mode 100644 index 0000000000..b2cf29bbcc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_methodCallExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(name: string): void { + this.name = name; + } +} + +let person = new Person2(); +person.setName('Bob'); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_multiplicativeExpression.ets new file mode 100644 index 0000000000..9a53c00be3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a.s * 4; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000..bad78753e0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +class S { + s: number = 0; +} +namespace NS1 { + let a: S = {s: 1}; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newArrayInstance.ets new file mode 100644 index 0000000000..3ffc9a395d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newArrayInstance.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +class S { + s: number[] = []; +} +let a: S = {s: new number[1]}; +a.s[0] = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newExpression.ets new file mode 100644 index 0000000000..ff0b1884ba --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_newExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: number) {} +} + +let d = new D(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..eec040081b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_nullishCoalescingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +null ?? a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000..385a9a0118 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +class Person { + name: string = "" + age: number = 0 +} +let b : Person = {name: "a", age: (8 + 10)} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_recordLiteral.ets new file mode 100644 index 0000000000..be031891d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_recordLiteral.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +class Person { + name: string = "" +} + +let s: Record = {"John": {name: "John"}}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_relationalExpression.ets new file mode 100644 index 0000000000..4a74cd0937 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_relationalExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a.s < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_returnStatement.ets new file mode 100644 index 0000000000..7fabab8939 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_returnStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +class S { + s: number = 0; +} +function A(S1: S) { + let a: S = {s: 5}; + return a; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000..39982c014a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_separateModuleDeclaration.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 5}; +console.info('a: ' + a); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_shiftExpression.ets new file mode 100644 index 0000000000..ee3c951ea4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_shiftExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +a.s << 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_spreadExpression.ets new file mode 100644 index 0000000000..586f39de57 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_spreadExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +class Person { + name: number[] = []; + age: number = 0; +} +let array1: number[] = [1, 2, 3]; +let array2: number[] = [4, 5]; +let b : Person = {name: [...array1, ...array2], age: 25} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_statement.ets new file mode 100644 index 0000000000..7617ec2413 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +class S { + s: string = ''; +} +let a: S = {s: 'Alice'}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_stringInterpolation.ets new file mode 100644 index 0000000000..8f4db6325f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_stringInterpolation.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +class S { + s: string = ''; +} +let a: S = {s: 'Alice'}; +`Hello, my name is ${a}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_switchStatement.ets new file mode 100644 index 0000000000..2de3e54700 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_switchStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +class S { + s: int = 0; +} +let x: S = {s: 5}; +switch (x.s) { + case 5: break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_thisExpression.ets new file mode 100644 index 0000000000..14abd71cee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_thisExpression.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public field: number; + constructor() { + this.field = 1; + } +} +let b : ThisExample = {field: 8} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_throwStatement.ets new file mode 100644 index 0000000000..9f7a0f24b3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_throwStatement.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +class S { + s: number = 0; +} +let x: S = {s: 5}; +throw new Error("error" + x); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topDeclaration.ets new file mode 100644 index 0000000000..3ba121f1c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topDeclaration.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +class S { + s: number = 0; +} +export let a: S = {s: 5}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topLevelStatements.ets new file mode 100644 index 0000000000..5988351b23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_topLevelStatements.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 56}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000..0bdc229b89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +class B {} +let a = new A(); +let b = new B(); +a.methodTwo(b) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_tryStatement.ets new file mode 100644 index 0000000000..805a29ae58 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_tryStatement.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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +class S { + s: number = 0; +} + +function processOne(a: number): number { + try { + let x: S = {s: 5}; + return x.s; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_typeOfExpression.ets new file mode 100644 index 0000000000..fadc748981 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +class S { + s: number = 0; +} +let a: S = {s: 5}; +typeof a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_unaryExpression.ets new file mode 100644 index 0000000000..590e503dd2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +class S { + s: number = 0; +} +let a = new S; +!a; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_whileStatement.ets new file mode 100644 index 0000000000..70c8f96d28 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/objectLiteral/objectLiteral_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 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +class S { + s: string = ''; +} +let a: S = {s: 'Alice'}; +while(a) { + a = {s: '1'}; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_assignmentExpression.ets new file mode 100644 index 0000000000..5303085a92 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let s: Record = {"John": 1}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_awaitExpression.ets new file mode 100644 index 0000000000..6e064ad608 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_awaitExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +function foo(): Promise> { + return new Promise>((resolve, reject) => { + let s: Record = {"John": 1}; + resolve(s); + }); +} +const res = await foo(); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_castExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_castExpression.ets new file mode 100644 index 0000000000..6286d4e56b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_castExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.15 + * castExpression: + * expression 'as' type + * ; + */ + +class X { + name: Record = { + "John": 1, + "Mary": 2, + }; +} + +let x1 : X = {name: {"John": 1}}; +let ob : Object = x1 as Object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_classInitializer.ets new file mode 100644 index 0000000000..eace300cb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_classInitializer.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static s1: Record = {"John": 1, "Mary": 21}; + static s2: Record = {"John": 1}; + static initializerBlock() { + if (ExampleClass1.s1 == ExampleClass1.s2) { + ExampleClass1.s1 = {"John": 1}; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalAndExpression.ets new file mode 100644 index 0000000000..cd40aa6c1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalAndExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +let s: Record = {"John": 1}; +let s1: Record = {"John": 1}; +s && s1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalExpression.ets new file mode 100644 index 0000000000..c9909e0a77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +let s: Record = {"John": 1}; +let s1: Record = {"Amy": 12}; +(7 > 5) ? s : s1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalOrExpression.ets new file mode 100644 index 0000000000..3b03bf8f06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_conditionalOrExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +let s: Record = {"John": 1}; +let s1: Record = {"John": 1}; +s || s1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_constantExpression.ets new file mode 100644 index 0000000000..8b62c4b2a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const s: Record = {"John": 1}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..d9c9b91795 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let s: Record = {"John": 1}; +s!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_equalityExpression.ets new file mode 100644 index 0000000000..489e738c89 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_equalityExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +let s: Record = {"John": 1}; +let s1: Record = {"John": 1}; +s == s1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000..9e738724ed --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_fieldAccessExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + name: Record = { + "John": 1, + "Mary": 2, + }; +} + +let person = new Person1(); +person.name = { + "John": 1, + "Mary": 2, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_finallyClause.ets new file mode 100644 index 0000000000..e6bf4ee3d5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_finallyClause.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne() { + try { + } catch (error) { + } finally { + let s1: Record = {"John": 1, "Mary": 21}; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_forStatement.ets new file mode 100644 index 0000000000..5beb446c9c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_forStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let s1: Record = {"John": 1}; +let i: number = 1; +for (; i < 10 && s1; i++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionCallExpression.ets new file mode 100644 index 0000000000..7662bebc4e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_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 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function func1(x: Record): number { + return 0; +} + +func1({"John": 1}); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionTypeWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionTypeWithReceiver.ets new file mode 100644 index 0000000000..528964c2ee --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_functionTypeWithReceiver.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 17.12.4 + * functionTypeWithReceiver: + * '(' receiverParameter(','ftParameterList)?')'ftReturnType + * ; + */ + +type F = (a: Record) => void; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ifStatement.ets new file mode 100644 index 0000000000..896ab6d068 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_ifStatement.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +let s1: Record = {"John": 1}; +let s2: Record = {"John": 2}; +if (s1 == s2) { + console.log("s1 == s2"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_indexingExpression.ets new file mode 100644 index 0000000000..95678262f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_indexingExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +let a = [1, 2, 3, 4, 5]; +let map: Record = { + "John": a[0], + "Mary": a[1], +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_initializerBlock.ets new file mode 100644 index 0000000000..fa909d3824 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let sum: Record = {"John": 1, "Mary": 21}; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_instanceOfExpression.ets new file mode 100644 index 0000000000..10def05220 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +let a: Record = {"John": 1}; +a instanceof object; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpression.ets new file mode 100644 index 0000000000..d592090ee7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number, z?: number): Promise => { + let s: Record = {"John": 1}; + return s; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..0ae883e611 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A): Record => { + let a: Record = {"John": 1, "Mary": 21}; + return a; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_loopStatement.ets new file mode 100644 index 0000000000..ca9d4138a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_loopStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +let s1: Record = {"John": 1}; +let s2: Record = {"John": 2}; +while(s1 == s2) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_methodCallExpression.ets new file mode 100644 index 0000000000..9e7497d223 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_methodCallExpression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: Record = { + "John": 1, + "Mary": 2, + }; + setName(name: Record): void { + this.name = name; + } +} + +let person = new Person2(); +person.setName({ + "John": 1, + "Mary": 2, +}); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000..8238919508 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: Record = {"John": 1, "Mary": 21}; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newArrayInstance.ets new file mode 100644 index 0000000000..94928529c5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newArrayInstance.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new Record[1]; +a[0] = {"John": 1, "Mary": 21}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newExpression.ets new file mode 100644 index 0000000000..eb81687803 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_newExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: Record) {} +} + +new D({"John": 1}); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..0366abb8a5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +let s: Record = {"John": 1}; +null ?? s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000..ab0aa15a0d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_parenthesizedExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let map: Record = { + "John": (5 + 3), + "Mary": (1 + 3), +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_returnStatement.ets new file mode 100644 index 0000000000..1dfbc6cf67 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add() { + let s1: Record = {"John": 1, "Mary": 21}; + return s1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000..30968df46d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_separateModuleDeclaration.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let a: Record = {"John": 1, "Mary": 21}; +console.info('a: ' + a); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_spreadExpression.ets new file mode 100644 index 0000000000..192d2447ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_spreadExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let array1 = [1, 2, 3]; +let array2 = [4, 5]; +let array3 = [...array1, ...array2]; +let map: Record = { + "John": array3, + "Mary": array2, +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_statement.ets new file mode 100644 index 0000000000..a9839214d2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let s: Record = {"John": 1}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_stringInterpolation.ets new file mode 100644 index 0000000000..8aa9e3c41a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let s: Record = {"John": 1}; +`Hello, my name is ${s}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_thisExpression.ets new file mode 100644 index 0000000000..19b7ea1dd9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_thisExpression.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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public map: Record = { + "John": 1, + "Mary": 2, + }; + constructor() { + this.map = { + "John": 3, + "Mary": 4, + }; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_throwStatement.ets new file mode 100644 index 0000000000..fc3bb41330 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +let s1: Record = {"John": 1, "Mary": 21}; +throw new Error("error" + s1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topDeclaration.ets new file mode 100644 index 0000000000..bc05303de0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export let a: Record = {"John": 1, "Mary": 21}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topLevelStatements.ets new file mode 100644 index 0000000000..063b5e6013 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: Record = {"John": 1, "Mary": 21}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000..37f396bf32 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_trailingLambdaCall.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +let a = new A(); +a.methodTwo>({"John": 1, "Mary": 21}) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_tryStatement.ets new file mode 100644 index 0000000000..e4d9b92b47 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processOne(): Record { + try { + let s1: Record = {"John": 1, "Mary": 21}; + const res = s1; + return res; + } catch (error) { + return {"John": 1}; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_typeOfExpression.ets new file mode 100644 index 0000000000..5be0a2d89f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let s: Record = {"John": 1}; +typeof s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_unaryExpression.ets new file mode 100644 index 0000000000..ca601a3302 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +let s: Record = {"John": 1}; +!s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_whileStatement.ets new file mode 100644 index 0000000000..2f519d73ef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/7_expressions/recordLiteral/recordLiteral_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.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let s1: Record = {"John": 1}; +let s2: Record = {"John": 2}; +while(s1 !== s2) { + s1 = s2; +} -- Gitee