From aef22cf312f18fb28adb689a047a442a556ceade Mon Sep 17 00:00:00 2001 From: liujia178 Date: Fri, 13 Jun 2025 06:51:03 +0800 Subject: [PATCH] test: Add specification test cases Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/IBWNFN?from=project-issue Signed-off-by: liujia178 --- .../ets/spec/10_interfaces/EnumConstant.ets | 25 ++ .../spec/10_interfaces/EnumConstantList.ets | 38 ++++ .../spec/10_interfaces/EnumDeclaration.ets | 29 +++ .../10_interfaces/InterfaceDeclaration.ets | 59 +++++ .../spec/10_interfaces/InterfaceMember.ets | 56 +++++ .../InterfaceMethodDeclaration.ets | 37 +++ .../spec/10_interfaces/InterfaceProperty.ets | 47 ++++ .../spec/10_interfaces/InterfaceTypeList.ets | 35 +++ .../13_compilation_units/CompilationUnit.ets | 51 +++++ ...ationTypeAliasSelectiveExportDirective.ets | 64 ++++++ .../DeclarationModule/ImportDirective.ets | 37 +++ ...ationTypeAliasSelectiveExportDirective.ets | 76 +++++++ .../DefaultBinding/DefaultAsIdentifier.ets | 24 ++ .../DefaultBinding/Identifier.ets | 23 ++ .../13_compilation_units/ExportDirective.ets | 58 +++++ .../13_compilation_units/ImportDirective.ets | 55 +++++ .../spec/13_compilation_units/NameBinding.ets | 34 +++ .../NamespaceDeclaration.ets | 100 ++++++++ .../ReExportDirective.ets | 25 ++ .../SelectiveBindings.ets | 35 +++ .../ImportDirective.ets | 33 +++ ...ationTopLevelStatementsExportDirective.ets | 68 ++++++ ...ationTopLevelStatementsExportDirective.ets | 62 +++++ .../SingleExportDirective.ets | 29 +++ ...AccessorWithReceiverDeclarationDefault.ets | 42 ++++ ...eiverDeclarationDefaultAnnotationUsage.ets | 46 ++++ .../ConstantDeclarationsDefault.ets | 37 +++ ...tantDeclarationsDefaultAnnotationUsage.ets | 42 ++++ .../ExportAnnotationUsageDeclaraction.ets | 140 ++++++++++++ .../FunctionDeclarationDefault.ets | 38 ++++ ...ctionDeclarationDefaultAnnotationUsage.ets | 42 ++++ ...FunctionWithReceiverDeclarationDefault.ets | 39 ++++ ...eiverDeclarationDefaultAnnotationUsage.ets | 43 ++++ .../NamespaceDeclarationDefault.ets | 38 ++++ ...spaceDeclarationDefaultAnnotationUsage.ets | 77 +++++++ .../TopDeclaration/TypeDeclarationDefault.ets | 40 ++++ .../TypeDeclarationDefaultAnnotationUsage.ets | 44 ++++ .../VariableDeclarationsDefault.ets | 36 +++ ...ableDeclarationsDefaultAnnotationUsage.ets | 41 ++++ .../TopLevelStatements.ets | 29 +++ .../14_ambient_declarations/ambientConst.ets | 28 +++ .../ambientConstList.ets | 29 +++ .../ambientDeclaration.ets | 65 ++++++ .../ambientFunctionDeclaration.ets | 35 +++ .../2_lexical_elements/BacktickCharacter.ets | 39 ++++ .../spec/2_lexical_elements/BigIntLiteral.ets | 213 ++++++++++++++++++ .../2_lexical_elements/BooleanLiteral.ets | 24 ++ .../DoubleQuoteCharacter.ets | 33 +++ .../2_lexical_elements/EscapeSequence.ets | 56 +++++ .../2_lexical_elements/LineContinuation.ets | 30 +++ .../MultilineStringLiteral.ets | 31 +++ .../SingleQuoteCharacter.ets | 33 +++ .../spec/2_lexical_elements/StringLiteral.ets | 37 +++ .../compiler/ets/spec/3_types/ftParameter.ets | 39 ++++ .../ets/spec/3_types/ftParameterList.ets | 36 +++ .../ets/spec/3_types/functionType.ets | 33 +++ .../compiler/ets/spec/3_types/tupleType.ets | 27 +++ .../ast/compiler/ets/spec/3_types/type.ets | 89 ++++++++ .../ets/spec/3_types/typeReference.ets | 36 +++ .../ets/spec/3_types/typeReferencePart.ets | 30 +++ .../compiler/ets/spec/3_types/unionType.ets | 37 +++ .../ConstantDeclaration.ets | 25 ++ .../ConstantDeclarationList.ets | 25 ++ .../ConstantDeclarations.ets | 23 ++ .../FunctionDeclaration.ets | 41 ++++ .../Modifiers.ets | 25 ++ .../OptionalParameter.ets | 28 +++ .../Parameter.ets | 41 ++++ .../ParameterList.ets | 47 ++++ .../QualifiedName.ets | 28 +++ .../RestParameter.ets | 31 +++ .../Signature.ets | 37 +++ .../TypeAlias.ets | 25 ++ .../TypeDeclaration.ets | 39 ++++ .../VariableDeclaration.ets | 44 ++++ .../VariableDeclarationList.ets | 25 ++ .../VariableDeclarations.ets | 23 ++ .../ets/spec/5_generics/Constraint.ets | 25 ++ .../ets/spec/5_generics/TypeArguments.ets | 25 ++ .../ets/spec/5_generics/TypeParameter.ets | 45 ++++ .../spec/5_generics/TypeParameterDefault.ets | 25 ++ .../ets/spec/5_generics/TypeParameterList.ets | 25 ++ .../ets/spec/5_generics/TypeParameters.ets | 23 ++ .../spec/7_expressions/ArgumentSequence.ets | 40 ++++ .../ets/spec/7_expressions/Arguments.ets | 31 +++ .../spec/7_expressions/BinaryExpression.ets | 44 ++++ .../ets/spec/7_expressions/Expression.ets | 102 +++++++++ .../spec/7_expressions/ObjectReference.ets | 47 ++++ .../spec/7_expressions/PrimaryExpression.ets | 78 +++++++ .../ets/spec/7_expressions/RestArgument.ets | 31 +++ .../spec/7_expressions/constantExpression.ets | 23 ++ .../spec/7_expressions/lambdaExpression.ets | 40 ++++ .../spec/7_expressions/lambdaParameter.ets | 47 ++++ .../7_expressions/lambdaParameterList.ets | 37 +++ .../spec/7_expressions/lambdaSignature.ets | 37 +++ .../compiler/ets/spec/8_statements/block.ets | 25 ++ .../ets/spec/8_statements/breakStatement.ets | 33 +++ .../spec/8_statements/continueStatement.ets | 33 +++ .../spec/8_statements/expressionStatement.ets | 23 ++ .../ets/spec/8_statements/forOfStatement.ets | 47 ++++ .../ets/spec/8_statements/forStatement.ets | 106 +++++++++ .../ets/spec/8_statements/ifStatement.ets | 40 ++++ .../spec/8_statements/localDeclaration.ets | 40 ++++ .../ets/spec/8_statements/loopStatement.ets | 61 +++++ .../ets/spec/8_statements/returnStatement.ets | 29 +++ .../ets/spec/8_statements/statement.ets | 64 ++++++ .../ets/spec/8_statements/switchStatement.ets | 96 ++++++++ .../spec/8_statements/whileDoStatement.ets | 34 +++ .../ets/spec/9_classes/ConstructorBody.ets | 75 ++++++ .../ets/spec/9_classes/ConstructorCall.ets | 39 ++++ .../spec/9_classes/ConstructorDeclaration.ets | 38 ++++ .../astchecker/astchecker-ets-ignored.txt | 4 + .../srcdumper/srcdumper-ets-ignored.txt | 21 ++ 113 files changed, 4894 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstant.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstantList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMember.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMethodDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceProperty.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceTypeList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/CompilationUnit.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/AmbientDeclarationTypeAliasSelectiveExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirectiveAmbientDeclarationTypeAliasSelectiveExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/DefaultAsIdentifier.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/Identifier.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ImportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NameBinding.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NamespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ReExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SelectiveBindings.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SingleExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ExportAnnotationUsageDeclaraction.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefaultAnnotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConst.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConstList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientFunctionDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BacktickCharacter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BigIntLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BooleanLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/DoubleQuoteCharacter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/LineContinuation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/MultilineStringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/SingleQuoteCharacter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/StringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/ftParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/ftParameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/functionType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/tupleType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/type.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/typeReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/typeReferencePart.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/3_types/unionType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarationList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/FunctionDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Modifiers.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/OptionalParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Parameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ParameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/QualifiedName.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/RestParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Signature.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeAlias.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarationList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/Constraint.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/TypeArguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterDefault.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/ArgumentSequence.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/Arguments.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/BinaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/Expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/ObjectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/PrimaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/RestArgument.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaSignature.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/block.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/breakStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/continueStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/expressionStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/localDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/8_statements/whileDoStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorBody.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorDeclaration.ets diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstant.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstant.ets new file mode 100644 index 0000000000..dd9091938a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstant.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 10.7 + * enumConstant: + * identifier ('=' constantExpression)? + * ; + */ + +enum E1 { A } + +enum E2 { A = 5, B = 77 } diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstantList.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstantList.ets new file mode 100644 index 0000000000..91820e03ac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumConstantList.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 10.7 + * enumConstantList: + * enumConstant (',' enumConstant)* ','? + * ; + * + * enumConstant: + * identifier ('=' constantExpression)? + * ; + * + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + * + */ + +enum Color { Red, Green } + +enum Fruit { Apple, } + +enum E1 { X } + +enum E2 { X, Y, } diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumDeclaration.ets new file mode 100644 index 0000000000..29308f9de6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/EnumDeclaration.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 10.7 + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + * + * enumConstantList: + * enumConstant (',' enumConstant)* ','? + * ; + */ + +const enum Color { Red } + +enum Fruit { Apple } diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceDeclaration.ets new file mode 100644 index 0000000000..054978ac23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceDeclaration.ets @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 10.1 + * interfaceDeclaration: + * 'interface' identifier typeParameters? + * interfaceExtendsClause? '{' interfaceMember* '}' + * ; + * + * interfaceExtendsClause: + * 'extends' interfaceTypeList + * ; + * + * CHAPTER 10.3 + * interfaceMember: + * annotationUsage? + * ( interfaceProperty + * | interfaceMethodDeclaration + * ) + * ; + */ + +interface ExampleInterface1 {} + +interface ExampleInterface2 {} + +interface ExampleInterface3 extends ExampleInterface1 {} + +interface ExampleInterface4 { + property: string; + method(param: number): void +} + +interface ExampleInterface5 extends ExampleInterface1 {} + +interface ExampleInterface6 { + property: string; + method(param: number): void +} + +interface ExampleInterface7 extends ExampleInterface1 {} + +interface ExampleInterface8 extends ExampleInterface1 { + property: string; + method(param: number): void +} diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMember.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMember.ets new file mode 100644 index 0000000000..fbe50050f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMember.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 10.3 + * interfaceMember: + * annotationUsage? + * ( interfaceProperty + * | interfaceMethodDeclaration + * ) + * ; + * + * CHAPTER 10.1 + * interfaceDeclaration: + * 'interface' identifier typeParameters? + * interfaceExtendsClause? '{' interfaceMember* '}' + * ; + */ + +@interface ClassPreamble { + revision: number; +} + +interface ExampleInterface1 { + @ClassPreamble({ + revision: 2 + }) + property: string; +} + +interface ExampleInterface2 { + @ClassPreamble({ + revision: 2 + }) + method(param: number): void +} + +interface ExampleInterface3 { + property: string; +} + +interface ExampleInterface4 { + method(param: number): void +} diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMethodDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMethodDeclaration.ets new file mode 100644 index 0000000000..f2bc1911e7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceMethodDeclaration.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 10.6 + * interfaceMethodDeclaration: + * identifier signature + * | interfaceDefaultMethodDeclaration + * ; + * + * CHAPTER 17.11 + * interfaceDefaultMethodDeclaration: + * 'private'? identifier signature block + * ; + */ + +interface SignatureInterface { + signatureMethod(param: string): void +} + +interface DefaultInterface { + defaultMethod(param: string): string { + return param; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceProperty.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceProperty.ets new file mode 100644 index 0000000000..e4b11e7dc3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceProperty.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 10.5 + * interfaceProperty: + * 'readonly'? identifier '?'? ':' type + * | 'get' identifier '(' ')' returnType + * | 'set' identifier '(' parameter ')' + * ; + */ + +interface ExampleInterface1 { + readonly name: string; +} + +interface ExampleInterface2 { + name?: string; +} + +interface ExampleInterface3 { + name: string; +} + +interface ExampleInterface4 { + readonly name?: string; +} + +interface ExampleInterface5 { + get getMethod(): number +} + +interface ExampleInterface6 { + set setMethod(index: number) +} diff --git a/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceTypeList.ets b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceTypeList.ets new file mode 100644 index 0000000000..0750d069fc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/10_interfaces/InterfaceTypeList.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 10.1 + * interfaceTypeList: + * typeReference (',' typeReference)* + * ; + * + * interfaceExtendsClause: + * 'extends' interfaceTypeList + * ; + */ + +interface ExampleInterface1 {} + +interface ExampleInterface2 {} + +interface ExampleInterface3 {} + +interface ExampleInterface4 extends ExampleInterface1, ExampleInterface2, ExampleInterface3 {} + +interface ExampleInterface5 extends ExampleInterface1 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/CompilationUnit.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/CompilationUnit.ets new file mode 100644 index 0000000000..b4223c5e8b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/CompilationUnit.ets @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13 + * compilationUnit: + * separateModuleDeclaration + * | packageDeclaration + * | declarationModule + * ; + * + * packageDeclaration: + * packageModule+ + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + * + * CHAPTER 13.5 + * declarationModule: + * importDirective* + * ('export'?ambientDeclaration + * |'export'?typeAlias + * | selectiveExportDirective + * )* + * ; + */ + +package myPackage; + +interface MyInterface { + doSomething(): void +} + +let v2 = 2 + 3 * 4; + +declare function foo(): void diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/AmbientDeclarationTypeAliasSelectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/AmbientDeclarationTypeAliasSelectiveExportDirective.ets new file mode 100644 index 0000000000..44c9115664 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/AmbientDeclarationTypeAliasSelectiveExportDirective.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.5 + * declarationModule: + * importDirective* + * ('export'?ambientDeclaration + * |'export'?typeAlias + * | selectiveExportDirective + * )* + * ; + * + * CHAPTER 13.12 + * ambientDeclaration: + * 'declare' + * ( ambientConstantDeclaration + * | ambientFunctionDeclaration + * | ambientClassDeclaration + * | ambientInterfaceDeclaration + * | ambientNamespaceDeclaration + * | 'const'? enumDeclaration + * ) + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters?'='type + * ; + * + * CHAPTER 13.9.1 + * 'export' selectiveBindings + * ; + */ + +declare enum Color { Red }; + +declare enum Digit { One,Two }; + +export declare enum Fruit { Apple }; + +type numberExample = number; + +type boolExample = boolean; + +export type stringExample = string; + +export { Color }; + +export { Digit }; + +export { numberExample }; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirective.ets new file mode 100644 index 0000000000..beaff155cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirective.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 13.5 + * declarationModule: + * importDirective* + * ('export'?ambientDeclaration + * |'export'?typeAlias + * | selectiveExportDirective + * )* + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import { MyClass1 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface1 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface2 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirectiveAmbientDeclarationTypeAliasSelectiveExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirectiveAmbientDeclarationTypeAliasSelectiveExportDirective.ets new file mode 100644 index 0000000000..185f8c41a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirectiveAmbientDeclarationTypeAliasSelectiveExportDirective.ets @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.5 + * declarationModule: + * importDirective* + * ('export'?ambientDeclaration + * |'export'?typeAlias + * | selectiveExportDirective + * )* + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + * + * CHAPTER 13.12 + * ambientDeclaration: + * 'declare' + * ( ambientConstantDeclaration + * | ambientFunctionDeclaration + * | ambientClassDeclaration + * | ambientInterfaceDeclaration + * | ambientNamespaceDeclaration + * | 'const'? enumDeclaration + * ) + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters?'='type + * ; + * + * CHAPTER 13.9.1 + * 'export' selectiveBindings + * ; + */ + +import { MyClass1 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface1 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface2 } from "../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective"; + +declare enum Color { Red }; + +declare enum Digit { One,Two }; + +export declare enum Fruit { Apple }; + +type numberExample = number; + +type boolExample = boolean; + +export type stringExample = string; + +export { Color }; + +export { Digit }; + +export { numberExample }; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/DefaultAsIdentifier.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/DefaultAsIdentifier.ets new file mode 100644 index 0000000000..c684a1df96 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/DefaultAsIdentifier.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.3 + * defaultBinding: + * identifier | ('{''default''as' identifier'}') + * ; + */ + +import { default as defaultExport } from + '../SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/Identifier.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/Identifier.ets new file mode 100644 index 0000000000..08be126790 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/DefaultBinding/Identifier.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.3 + * defaultBinding: + * identifier | ('{''default''as' identifier'}') + * ; + */ + +import defaultExport from '../SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ExportDirective.ets new file mode 100644 index 0000000000..61c8780386 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ExportDirective.ets @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + * + * CHAPTER 13.9.1 + * selectiveExportDirective: + * 'export' selectiveBindings + * ; + * + * CHAPTER 13.9.2 + * singleExportDirective: + * 'export' 'default'? identifier + * ; + * + * CHAPTER 13.9.3 + * exportTypeDirective: + * 'export' 'type' selectiveBindings + * ; + * + * CHAPTER 13.9.4 + * reExportDirective: + * 'export' ('*' | selectiveBindings) 'from' importPath + * ; + */ + +class Class1 {} + +class Class2 {} + +class Class3 {} + +export { Class1 }; + +export Class2; + +export type { Class3 }; + +export * from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ImportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ImportDirective.ets new file mode 100644 index 0000000000..5c176bcc53 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ImportDirective.ets @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + * + * allBinding: + * '*' bindingAlias + * ; + * + * selectiveBindings: + * '{' nameBinding(','nameBinding)* ','?'}' + * ; + * + * defaultBinding: + * identifier|('{''default''as' identifier'}') + * ; + * + * typeBinding: + * 'type' selectiveBindings + * ; + * + * bindingAlias: + * 'as'identifier + * ; + * + * importPath: + * StringLiteral + * ; + */ + +import * as someModule from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +import { MyClass1 } from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +import defaultExport from './SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective'; + +import type { MyClassThree } from + './SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NameBinding.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NameBinding.ets new file mode 100644 index 0000000000..816fe243c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NameBinding.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 13.3 + * nameBinding: + * identifier bindingAlias? + * ; + * + * bindingAlias: + * 'as'identifier + * ; + * + * selectiveBindings: + * '{' nameBinding(','nameBinding)* ','?'}' + * ; + */ + +import { MyClass1 } from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +import { MyInterface2 as someInterface} from + './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NamespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NamespaceDeclaration.ets new file mode 100644 index 0000000000..fe6962439b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/NamespaceDeclaration.ets @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block'static' block + * ; + */ + +namespace NS1 { + let a: number; +} + +namespace NS2 { + class ExampleClass { + static initialized = false; + static initializerBlock() { + if (!ExampleClass.initialized) { + ExampleClass.initialized = true; + } + } + } +} + +namespace NS3 { + let b: number; + class ExampleClass { + static initialized = false; + static initializerBlock() { + if (!ExampleClass.initialized) { + ExampleClass.initialized = true; + } + } + } +} + +namespace NS4 { + let c: number; + let d: number; +} + +namespace NS5 { + class ExampleClass { + static initialized = false; + static initializerBlock() { + if (!ExampleClass.initialized) { + ExampleClass.initialized = true; + } + } + } + let e: number; +} + +namespace NS6 { + let f: number; + class ExampleClass { + static initialized = false; + static initializerBlock() { + if (!ExampleClass.initialized) { + ExampleClass.initialized = true; + } + } + } + let g: number; +} + +namespace NS7 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ReExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ReExportDirective.ets new file mode 100644 index 0000000000..3f2793be08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/ReExportDirective.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.9.4 + * reExportDirective: + * 'export' ('*' | selectiveBindings) 'from' importPath + * ; + */ + +export { MyClass1 } from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +export * from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SelectiveBindings.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SelectiveBindings.ets new file mode 100644 index 0000000000..8700cab2d6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SelectiveBindings.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 13.3 + * selectiveBindings: + * '{' nameBinding(','nameBinding)* ','?'}' + * ; + * + * nameBinding: + * identifier bindingAlias? + * ; + */ + +import { MyClass1, MyInterface1 } from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +import { MyInterfaceTwo } from + './SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective'; + +import { MyInterface2, } from './SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective'; + +import { MyInterfaceOne , MyClassOne,} from + './SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective'; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirective.ets new file mode 100644 index 0000000000..c8d43f2538 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirective.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 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import { MyClass1 } from "./TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface1 } from "./TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface2 } from "./TopDeclarationTopLevelStatementsExportDirective"; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective.ets new file mode 100644 index 0000000000..351bca3136 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective.ets @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import { MyClass1 } from "./TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface1 } from "./TopDeclarationTopLevelStatementsExportDirective"; + +import { MyInterface2 } from "./TopDeclarationTopLevelStatementsExportDirective"; + +interface MyInterfaceOne { + doSomethingOne(): number {} +} + +interface MyInterfaceTwo { + doSomethingTwo(): number {} +} + +interface MyInterfaceThree { + doSomethingThree(): number {} +} + +class MyClassOne implements MyInterfaceOne { + doSomethingOne(): number { + return 0; + } +} + +class MyClassTwo implements MyInterfaceTwo { + doSomethingTwo(): number { + return 1; + } +} + +class MyClassThree implements MyInterfaceThree { + doSomethingThree(): number { + return 1; + } +} + +export MyInterfaceTwo; +export default MyClassTwo; +export type { MyClassThree }; +export { MyInterfaceOne, MyClassOne } diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective.ets new file mode 100644 index 0000000000..236ec12615 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/TopDeclarationTopLevelStatementsExportDirective.ets @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +interface MyInterface1 { + doSomethingOne(): number {} +} + +interface MyInterface2 { + doSomethingTwo(): number {} +} + +interface MyInterface3 { + doSomethingThree(): number {} +} + +class MyClass1 implements MyInterface1 { + doSomethingOne(): number { + return 0; + } +} + +class MyClass2 implements MyInterface2 { + doSomethingTwo(): number { + return 1; + } +} + +class MyClass3 implements MyInterface3 { + doSomethingThree(): number { + return 1; + } +} + +export MyInterface2; +export default MyClass2; +export type { MyClass3 }; +export { MyInterface1, MyClass1 } diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SingleExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SingleExportDirective.ets new file mode 100644 index 0000000000..f218b73c91 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/SingleExportDirective.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 13.9.2 + * singleExportDirective: + * 'export' 'default'? identifier + * ; + */ + +class Class1 {} + +class Class2 {} + +export default Class1; + +export Class2; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefault.ets new file mode 100644 index 0000000000..45e8ce43ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 17.12.3 + * accessorWithReceiverDeclaration: + * 'get' identifier'('receiverParameter')'returnType block + * |'set' identifier'('receiverParameter','parameter')' block + * ; + */ + +class A {} + +export default get accessor(this: A): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..ee6267d2a7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/AccessorWithReceiverDeclarationDefaultAnnotationUsage.ets @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 17.12.3 + * accessorWithReceiverDeclaration: + * 'get' identifier'('receiverParameter')'returnType block + * |'set' identifier'('receiverParameter','parameter')' block + * ; + */ + +class A {} + +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) get accessor(this: A): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefault.ets new file mode 100644 index 0000000000..dc08e73f1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +export default const a = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..f7583c7add --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ConstantDeclarationsDefaultAnnotationUsage.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +@Retention("SOURCE") +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) const a = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ExportAnnotationUsageDeclaraction.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ExportAnnotationUsageDeclaraction.ets new file mode 100644 index 0000000000..f970a6d923 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/ExportAnnotationUsageDeclaraction.ets @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.6 + * typeDeclaration: + * classDeclaration + * | interfaceDeclaration + * | enumDeclaration + * | typeAlias + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 4.8 + * functionDeclaration: + * modifiers? 'function' identifier + * typeParameters? signature block? + * ; + * + * CHAPTER 17.12.1 + * functionWithReceiverDeclaration: + * 'function' identifier typeParameters? signatureWithReceiver block + * ; + * + * CHAPTER 17.12.3 + * accessorWithReceiverDeclaration: + * 'get' identifier'('receiverParameter')'returnType block + * |'set' identifier'('receiverParameter','parameter')' block + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock?topDeclaration* '}' + * ; + */ + +class A {} + +let a: number; + +const b = 1; + +function fooOne(): void {} + +function fooTwo(this: A) {} + +get accessorOne(this: A): number { + return 0; +} + +namespace NS1 {} + +export class B {} + +export let c: number; + +export const d = 2; + +export function fooThree(): void {} + +export function fooFour(this: A) {} + +export get accessorTwo(this: A): number { + return 0; +} + +export namespace NS2 {} + +@Retention("SOURCE") +@interface ClassPreamble { + revision: number; +} + +export @ClassPreamble({ revision: 2 }) class C {} + +export @ClassPreamble({ revision: 2 }) let e: number; + +export @ClassPreamble({ revision: 2 }) const f = 3; + +export @ClassPreamble({ revision: 2 }) function fooFive(): void {} + +export @ClassPreamble({ revision: 2 }) function fooSix(this: A) {} + +export @ClassPreamble({ revision: 2 }) get accessorThree(this: A): number { + return 0; +} + +export @ClassPreamble({ revision: 2 }) namespace NS3 {} + +@ClassPreamble({ revision: 2 }) class D {} + +@ClassPreamble({ revision: 2 }) let g: number; + +@ClassPreamble({ revision: 2 }) const h = 4; + +@ClassPreamble({ revision: 2 }) function fooSeven(): void {} + +@ClassPreamble({ revision: 2 }) function fooEight(this: A) {} + +@ClassPreamble({ revision: 2 }) get accessorFour(this: A): number { + return 0; +} + +@ClassPreamble({ revision: 2 }) namespace NS4 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefault.ets new file mode 100644 index 0000000000..ce762c4ffe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.8 + * functionDeclaration: + * modifiers? 'function' identifier + * typeParameters? signature block? + * ; + */ + +export default function foo(): void {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..5fe6bccb53 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionDeclarationDefaultAnnotationUsage.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.8 + * functionDeclaration: + * modifiers? 'function' identifier + * typeParameters? signature block? + * ; + */ + +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) function foo(): void {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefault.ets new file mode 100644 index 0000000000..1c8679e651 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 17.12.1 + * functionWithReceiverDeclaration: + * 'function' identifier typeParameters? signatureWithReceiver block + * ; + */ + +class A {} + +export default function foo(this: A) {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..aff0c5019b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/FunctionWithReceiverDeclarationDefaultAnnotationUsage.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 17.12.1 + * functionWithReceiverDeclaration: + * 'function' identifier typeParameters? signatureWithReceiver block + * ; + */ + +class A {} + +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) function foo(this: A) {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefault.ets new file mode 100644 index 0000000000..e5d0055918 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock?topDeclaration* '}' + * ; + */ + +export default namespace NS1 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..aa44f270bb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/NamespaceDeclarationDefaultAnnotationUsage.ets @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.6 + * typeDeclaration: + * classDeclaration + * | interfaceDeclaration + * | enumDeclaration + * | typeAlias + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + * + * CHAPTER 4.8 + * functionDeclaration: + * modifiers? 'function' identifier + * typeParameters? signature block? + * ; + * + * CHAPTER 17.12.1 + * functionWithReceiverDeclaration: + * 'function' identifier typeParameters? signatureWithReceiver block + * ; + * + * CHAPTER 17.12.3 + * accessorWithReceiverDeclaration: + * 'get' identifier'('receiverParameter')'returnType block + * |'set' identifier'('receiverParameter','parameter')' block + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock?topDeclaration* '}' + * ; + */ + +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) namespace NS3 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefault.ets new file mode 100644 index 0000000000..2791d363a0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.6 + * typeDeclaration: + * classDeclaration + * | interfaceDeclaration + * | enumDeclaration + * | typeAlias + * ; + */ + +export default class A {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..1c6bf06120 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/TypeDeclarationDefaultAnnotationUsage.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * + * CHAPTER 4.6 + * typeDeclaration: + * classDeclaration + * | interfaceDeclaration + * | enumDeclaration + * | typeAlias + * ; + */ + +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) class A {} diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefault.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefault.ets new file mode 100644 index 0000000000..6c507c4a69 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefault.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +export default let a: number; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefaultAnnotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefaultAnnotationUsage.ets new file mode 100644 index 0000000000..901a5175b7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopDeclaration/VariableDeclarationsDefaultAnnotationUsage.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 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +@Retention("SOURCE") +@interface ClassPreamble { + revision: number; +} + +export default @ClassPreamble({ revision: 2 }) let a: number; diff --git a/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopLevelStatements.ets new file mode 100644 index 0000000000..fc23518635 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/13_compilation_units/TopLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 13.10 + * topLevelStatements: + * statement* + * ; + */ + +type A = number | string; + +let a: A = 56; + +function foo() {} + +a = "astring"; diff --git a/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConst.ets b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConst.ets new file mode 100644 index 0000000000..2e8347fe9d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConst.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 14.1 + * ambientConst: + * identifier((':'type)|('=' + * (IntegerLiteral|FloatLiteral|StringLiteral|MultilineStringLiteral))) + * ; + */ + +declare const ambientDec13: number; +declare const ambientDec14 = 14; +declare const ambientDec15 = 1.5f; +declare const ambientDec16 = "16"; +declare const ambientDec17 = `17`; diff --git a/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConstList.ets b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConstList.ets new file mode 100644 index 0000000000..8c9f8dd2e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientConstList.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 14.1 + * ambientConstList: + * ambientConst (','ambientConst)* + * ; + * + * ambientConst: + * identifier((':'type)|('=' + * (IntegerLiteral|FloatLiteral|StringLiteral|MultilineStringLiteral))) + * ; + */ + +declare const ambientDec8: number; +declare const ambientDec9: number, ambientDec10: string, ambientDec11: number, ambientDec12: string; diff --git a/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientDeclaration.ets new file mode 100644 index 0000000000..72b06683d4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientDeclaration.ets @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 14 + * ambientDeclaration: + * 'declare' + * ( ambientConstantDeclaration + * | ambientFunctionDeclaration + * | ambientClassDeclaration + * | ambientInterfaceDeclaration + * | ambientNamespaceDeclaration + * | 'const'? enumDeclaration + * ) + * ; + * + * ambientConstantDeclaration: + * 'const' ambientConstList';' + * ; + * + * ambientFunctionDeclaration: + * 'function'identifier + * typeParameters?signature + * ; + * + * ambientClassDeclaration: + * 'class' identifier typeParameters? + * classExtendsClause? implementsClause? + * '{' ambientClassBodyDeclaration* '}' + * ; + * + * ambientInterfaceDeclaration: + * 'interface' identifier typeParameters? + * interfaceExtendsClause? + * '{' ambientInterfaceMember* '}' + * ; + * + * ambientNamespaceDeclaration: + * 'namespace' identifier'{'ambientNamespaceElement* '}' + * ; + * + * enumDeclaration: + * 'const'? 'enum' identifier '{' enumConstantList '}' + * ; + */ + +declare const ambientDec1: number; +declare function ambientDec2(x:number): void; +declare class AmbientDec3 {} +declare interface AmbientDec4 {} +declare namespace AmbientDec5 {} +declare enum AmbientDec6 { Red, Green, Blue } +declare const enum AmbientDec7 { Mon, Tue, Wed } diff --git a/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientFunctionDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientFunctionDeclaration.ets new file mode 100644 index 0000000000..cb3279da90 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/14_ambient_declarations/ambientFunctionDeclaration.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 14.2 + * ambientFunctionDeclaration: + * 'function' identifier + * typeParameters? signature + * ; + * + * identifier: Identifier; + * + * typeParameters: + * '<' typeParameterList '>' + * ; + * + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +declare function ambientDec18(): void; +declare function ambientDec19(num: T): void; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BacktickCharacter.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BacktickCharacter.ets new file mode 100644 index 0000000000..6e6d558a6d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BacktickCharacter.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 2.9.7 + * BacktickCharacter: + * ~['\\\r\n] + * | '\\' EscapeSequence + * | LineContinuation + * ; + * + * EscapeSequence: + * ['"bfnrtv0\\] + * | 'x' HexDigit HexDigit + * | 'u' HexDigit HexDigit HexDigit HexDigit + * | 'u' '{' HexDigit+ '}' + * | ~[1-9xu\r\n] + * ; + * + * LineContinuation: + * '\\' [\r\n\u2028\u2029]+ + * ; + */ + +`abcd>?! @#`; +`This is an example of \na multiline string`; +`This is an example of \\na multiline string`; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BigIntLiteral.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BigIntLiteral.ets new file mode 100644 index 0000000000..afe045e412 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BigIntLiteral.ets @@ -0,0 +1,213 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.4 + * BigIntLiteral: + * '0n' + * | [1-9] ('_'? [0-9])* 'n' + * ; + */ + +0n; +1n; +1_0n; +1_1n; +1_2n; +1_3n; +1_4n; +1_5n; +1_6n; +1_7n; +1_8n; +1_9n; +10n; +11n; +12n; +13n; +14n; +15n; +16n; +17n; +18n; +19n; +2n; +2_0n; +2_1n; +2_2n; +2_3n; +2_4n; +2_5n; +2_6n; +2_7n; +2_8n; +2_9n; +20n; +21n; +22n; +23n; +24n; +25n; +26n; +27n; +28n; +29n; +3n; +3_0n; +3_1n; +3_2n; +3_3n; +3_4n; +3_5n; +3_6n; +3_7n; +3_8n; +3_9n; +30n; +31n; +32n; +33n; +34n; +35n; +36n; +37n; +38n; +39n; +4n; +4_0n; +4_1n; +4_2n; +4_3n; +4_4n; +4_5n; +4_6n; +4_7n; +4_8n; +4_9n; +40n; +41n; +42n; +43n; +44n; +45n; +46n; +47n; +48n; +49n; +5n; +5_0n; +5_1n; +5_2n; +5_3n; +5_4n; +5_5n; +5_6n; +5_7n; +5_8n; +5_9n; +50n; +51n; +52n; +53n; +54n; +55n; +56n; +57n; +58n; +59n; +6n; +6_0n; +6_1n; +6_2n; +6_3n; +6_4n; +6_5n; +6_6n; +6_7n; +6_8n; +6_9n; +60n; +61n; +62n; +63n; +64n; +65n; +66n; +67n; +68n; +69n; +7n; +7_0n; +7_1n; +7_2n; +7_3n; +7_4n; +7_5n; +7_6n; +7_7n; +7_8n; +7_9n; +70n; +71n; +72n; +73n; +74n; +75n; +76n; +77n; +78n; +79n; +8n; +8_0n; +8_1n; +8_2n; +8_3n; +8_4n; +8_5n; +8_6n; +8_7n; +8_8n; +8_9n; +80n; +81n; +82n; +83n; +84n; +85n; +86n; +87n; +88n; +89n; +9n; +9_0n; +9_1n; +9_2n; +9_3n; +9_4n; +9_5n; +9_6n; +9_7n; +9_8n; +9_9n; +90n; +91n; +92n; +93n; +94n; +95n; +96n; +97n; +98n; +99n; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BooleanLiteral.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BooleanLiteral.ets new file mode 100644 index 0000000000..74ac72ff38 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/BooleanLiteral.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.5 + * BooleanLiteral: + * 'true' | 'false' + * ; + */ + +true; +false; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/DoubleQuoteCharacter.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/DoubleQuoteCharacter.ets new file mode 100644 index 0000000000..3fe9b90ec2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/DoubleQuoteCharacter.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 2.9.6 + * DoubleQuoteCharacter: + * ~["\\\r\n] + * | '\\' EscapeSequence + * ; + * + * EscapeSequence: + * ['"bfnrtv0\\] + * | 'x' HexDigit HexDigit + * | 'u' HexDigit HexDigit HexDigit HexDigit + * | 'u' '{' HexDigit+ '}' + * | ~[1-9xu\r\n] + * ; + */ + +"ABC!"; +"\n"; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets new file mode 100644 index 0000000000..6ecc202616 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * EscapeSequence: + * ['"bfnrtv0\\] + * | 'x' HexDigit HexDigit + * | 'u' HexDigit HexDigit HexDigit HexDigit + * | 'u' '{' HexDigit+ '}' + * | ~[1-9xu\r\n] + * ; + * + * HexDigit: + * [0-9a-fA-F] + * ; + */ + +"\'"; +"\""; +"\b"; +"\f"; +"\n"; +"\r"; +"\t"; +"\v"; +"\0"; +"\\"; +"\xFF"; +"\u039"; +"\u{1F600}"; +'\''; +'\"'; +'\b'; +'\f'; +'\n'; +'\r'; +'\t'; +'\v'; +'\0'; +'\'; +'\xFF'; +'\u039'; +'\u{1F600}'; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/LineContinuation.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/LineContinuation.ets new file mode 100644 index 0000000000..4c3f2da263 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/LineContinuation.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 2.9.7 + * LineContinuation: + * '\\' [\r\n\u2028\u2029]+ + * ; + */ + +`This is an example of \\ra multiline string`; +`This is an example of \\na multiline string`; +`This is an example of \\u2028a multiline string`; +`This is an example of \\u2029a multiline string`; +`This is an example of \\r\r\ra multiline string`; +`This is an example of \\n\n\na multiline string`; +`This is an example of \\u2028\u2028\u2028a multiline string`; +`This is an example of \\u2029\u2029\u2029a multiline string`; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/MultilineStringLiteral.ets new file mode 100644 index 0000000000..115cb3c684 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/MultilineStringLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * '`' (BacktickCharacter)* '`' + * ; + * + * BacktickCharacter: + * ~['\\\r\n] + * | '\\' EscapeSequence + * | LineContinuation + * ; + */ + +``; +`This is an example of + a multiline string`; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/SingleQuoteCharacter.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/SingleQuoteCharacter.ets new file mode 100644 index 0000000000..658a54d233 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/SingleQuoteCharacter.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 2.9.6 + * SingleQuoteCharacter: + * ~['\\\r\n] + * | '\\' EscapeSequence + * ; + * + * EscapeSequence: + * ['"bfnrtv0\\] + * | 'x' HexDigit HexDigit + * | 'u' HexDigit HexDigit HexDigit HexDigit + * | 'u' '{' HexDigit+ '}' + * | ~[1-9xu\r\n] + * ; + */ + +'ABC!'; +'\\n'; diff --git a/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/StringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/StringLiteral.ets new file mode 100644 index 0000000000..9540d48d20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/2_lexical_elements/StringLiteral.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 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * DoubleQuoteCharacter: + * ~["\\\r\n] + * | '\\' EscapeSequence + * ; + * + * SingleQuoteCharacter: + * ~['\\\r\n] + * | '\\' EscapeSequence + * ; + */ + +""; +"string"; +''; +'string'; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameter.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameter.ets new file mode 100644 index 0000000000..aafd104f92 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameter.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 3.19 + * ftParameter: + * identifier ('?')? ':' type + * ; + * + * identifier: Identifier; + * + * type: + * annotationUsage? + * ( typeReference + * |'readonly'? arrayType + * |'readonly'? tupleType + * | functionType + * | functionTypeWithReceiver + * | unionType + * | StringLiteral + * ) + * |'('type')' + * ; + */ + +let func1: (x: number) => string; +let func2: (a: number, b: string, c?: string) => boolean; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameterList.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameterList.ets new file mode 100644 index 0000000000..e08928d646 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/ftParameterList.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 3.19 + * ftParameterList: + * ftParameter (',' ftParameter)* (',' ftRestParameter)? + * | ftRestParameter + * ; + * + * ftParameter: + * identifier ('?')? ':' type + * ; + * + * ftRestParameter: + * '...' ftParameter + * ; + */ + +let func1: (x: number) => string; +let func2: (a: number, b: string, c?: string) => boolean; +let func3: (a: number, b?: string, c: string, ...rest: number[]) => void; +let func4: (first: string, ...rest: number[]) => boolean; +let func5: (...rest: number[]) => number; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/functionType.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/functionType.ets new file mode 100644 index 0000000000..4a9bd2d53b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/functionType.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 3.19 + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + * + * ftParameterList: + * ftParameter (',' ftParameter)* (',' ftRestParameter)? + * | ftRestParameter + * ; + * + * ftReturnType: + * '=>'type + * ; + */ + +let func1: () => void; +let func2: (x: number) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/tupleType.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/tupleType.ets new file mode 100644 index 0000000000..14214b8da1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/tupleType.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let tup1: []; +let tup2: [number]; +let tup3: [number,]; +let tup4: [string, number, boolean, number]; +let tup5: [string, number, boolean, number,]; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/type.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/type.ets new file mode 100644 index 0000000000..535547b7a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/type.ets @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 3.4 + * type: + * annotationUsage? + * ( typeReference + * |'readonly'? arrayType + * |'readonly'? tupleType + * | functionType + * | functionTypeWithReceiver + * | unionType + * | StringLiteral + * ) + * |'('type')' + * ; + * + * annotationUsage: + * '@' qualifiedName annotationValues? + * ; + * + * typeReference: + * typeReferencePart('.'typeReferencePart)* + * | identifier'!' + * ; + * + * arrayType: + * type '[' ']' + * ; + * + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + * + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + * + * functionTypeWithReceiver: + * '(' receiverParameter(','ftParameterList)?')'ftReturnType + * ; + * + * unionType: + * type('|'type)* + * ; + * + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + */ + +let type1: string; +let type2: number[]; +let type3: readonly number[]; +let type4: []; +let type5: readonly []; +let type6: () => void; +class MyClass {} +type type7 = (this: MyClass) => boolean; +type type8 = int | double; +let type9: "xyz"; +let type10: (number | string)[]; + +@Retention("SOURCE") +@interface TypeAnnotation {} +let type11: @TypeAnnotation() string; +let type12: @TypeAnnotation() number[]; +let type13: readonly @TypeAnnotation() number[]; +let type14: @TypeAnnotation() []; +let type15: readonly @TypeAnnotation() []; +let type16: @TypeAnnotation() () => void; +type type17 = @TypeAnnotation() (this: MyClass) => boolean; +type type18 = @TypeAnnotation() (int | double); +let type19: @TypeAnnotation() "xyz"; +let type20: @TypeAnnotation() (number | string)[]; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/typeReference.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/typeReference.ets new file mode 100644 index 0000000000..73ee40946a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/typeReference.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 3.6 + * typeReference: + * typeReferencePart('.'typeReferencePart)* + * | identifier'!' + * ; + * + * typeReferencePart: + * identifier typeArguments? + * ; + * + * identifier: Identifier; + */ + +let typeRef1: string; +namespace MyNamespace { + export namespace YourNamespace { + export class MyClass {} + } +} +let typeRef2: MyNamespace.YourNamespace.MyClass; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/typeReferencePart.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/typeReferencePart.ets new file mode 100644 index 0000000000..6421f3a15f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/typeReferencePart.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 3.6 + * typeReferencePart: + * identifier typeArguments? + * ; + * + * identifier: Identifier; + * + * typeArguments: + * '<' type(','type)* '>' + * ; + */ + +let typeRef1: string; +let typeRef2: Map; diff --git a/ets2panda/test/ast/compiler/ets/spec/3_types/unionType.ets b/ets2panda/test/ast/compiler/ets/spec/3_types/unionType.ets new file mode 100644 index 0000000000..57a201f47e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/3_types/unionType.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 3.20 + * unionType: + * type('|'type)* + * ; + * + * type: + * annotationUsage? + * ( typeReference + * |'readonly'? arrayType + * |'readonly'? tupleType + * | functionType + * | functionTypeWithReceiver + * | unionType + * | StringLiteral + * ) + * |'('type')' + * ; + */ + +let uniType1: number; +let uniType2: number | string | boolean | object; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclaration.ets new file mode 100644 index 0000000000..6307638129 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclaration.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclaration: + * identifier (':'type)? initializer + * ; + */ + +const c = "hello"; + +const d: string = "hello"; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarationList.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarationList.ets new file mode 100644 index 0000000000..2e14a31ebe --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarationList.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarationList: + * constantDeclaration (','constantDeclaration)* + * ; + */ + +const a: number = 5; + +const b: number = 1, c: string = "test"; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarations.ets new file mode 100644 index 0000000000..9864283488 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ConstantDeclarations.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const a: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/FunctionDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/FunctionDeclaration.ets new file mode 100644 index 0000000000..5a1147e643 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/FunctionDeclaration.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8 + * functionDeclaration: + * modifiers? 'function' identifier typeParameters? signature block? + * ; + */ + +function func1(x: number): number { + return 0; +} + +function func2(arg: T): T { + return arg; +} + +native function func3(): void + +async function func4(arg: string) { + return 0; +} + +native function func5(): void; + +async function func6(arg: T): Promise { + return arg; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Modifiers.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Modifiers.ets new file mode 100644 index 0000000000..2d9b706cda --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Modifiers.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8 + * modifiers: + * 'native' | 'async' + * ; + */ + +native function nativeFunction(): void; + +async function asyncFunction() {} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/OptionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/OptionalParameter.ets new file mode 100644 index 0000000000..124e8f4be3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/OptionalParameter.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.4 + * optionalParameter: + * identifier':' type '=' expression + * | identifier'?'':' type + * ; + */ + +function pair(x: number, y: number = 7) {} + +function describePerson(name: string, age?: number): string { + return name; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Parameter.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Parameter.ets new file mode 100644 index 0000000000..11315c74f6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Parameter.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameter: + * annotationUsage? (requiredParameter | optionalParameter) + * ; + * + * requiredParameter: + * identifier ':' type + * ; + */ + +function describePerson(name: string): string { + return "1"; +} + +function describePerson(age?: number): string { + return "1"; +} + +@Retention("SOURCE") +@interface add {} +function ADD (@add x: number) {}; + +@Retention("SOURCE") +@interface add1 {} +function ADD1 (@add1 x?: number) {}; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ParameterList.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ParameterList.ets new file mode 100644 index 0000000000..778c490051 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/ParameterList.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? | restParameter ','? + * ; + */ + +function greet(name: string): string { + return "name"; +} + +function greet1(name: string,): string { + return "name"; +} + +function add(x: number, y: number): number { + return x + y; +} + +function add1(x: number, y: number,): number { + return x + y; +} + +function sum(x: number, ...numbers: number[]): number { + return 0; +} + +function sum1(x: number, y: number, ...numbers: number[]): number { + return 0; +} + +function sum5(...numbers: number[]) {} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/QualifiedName.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/QualifiedName.ets new file mode 100644 index 0000000000..71b3e810a4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/QualifiedName.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.1 + * qualifiedName: + * identifier ('.' identifier )* + * ; + */ + +let name = 'Alice'; + +class MyClass { + static myStaticMethod() {} +} +MyClass.myStaticMethod(); diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/RestParameter.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/RestParameter.ets new file mode 100644 index 0000000000..d90c6c5395 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/RestParameter.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(...numbers: number[]): number { + return 0; +} + +@Retention("SOURCE") +@interface add {} +function add1(@add ...numbers: number[]): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Signature.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Signature.ets new file mode 100644 index 0000000000..bdf4cbe982 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/Signature.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + * + * returnType: + * ':' type + * ; + */ + +function example() {} + +function add(x: number, y: number) {} + +function add(): int { + return 1; +} + +function multiply(x: number, y: number): number { + return x * y; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeAlias.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeAlias.ets new file mode 100644 index 0000000000..6e4269505b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeAlias.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters? '=' type + * ; + */ + +type StringOrNumber = string | number; + +type Pair = [T, T]; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeDeclaration.ets new file mode 100644 index 0000000000..b8226ea3ab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/TypeDeclaration.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.6 + * typeDeclaration: + * classDeclaration + * | interfaceDeclaration + * | enumDeclaration + * | typeAlias + * ; + */ + +interface Person { + name: string; + age: number; +} + +class MyClass1 {} + +enum Color { + Red, + Green, + Blue +} + +type X = MyClass1; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclaration.ets new file mode 100644 index 0000000000..efccc7b0dd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclaration.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclaration: + * identifier ('?')? ':' ('readonly')? type initializer? + * | identifier initializer + * ; + * + * initializer: + * '=' expression + * ; + */ + +let myVar: number; + +let myVar0: number = 10; + +let myVar1?: number; + +let myVar2?: number = 10; + +let myVar3: readonly number[] = [1, 2, 3]; + +let myVar4?: readonly number[] = [1, 2, 3]; + +let myVar5: readonly number[]; + +let myVar6?: readonly number[]; + +let myVar7 = 3 + 4; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarationList.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarationList.ets new file mode 100644 index 0000000000..fa82b1e1f0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarationList.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarationList: + * variableDeclaration (',' variableDeclaration)* + * ; + */ + +let a: number = 5; + +let b: number = 1, c: string = "test"; diff --git a/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarations.ets new file mode 100644 index 0000000000..e5ee3fd23a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/4_names_declarations_and_scopes/VariableDeclarations.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let a: number = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/Constraint.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/Constraint.ets new file mode 100644 index 0000000000..a023df7ed5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/Constraint.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.1 + * constraint: + * 'extends'typeReference | unionType + * ; + */ + +class Constraint {} + +function logValue(value: T): void {} diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeArguments.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeArguments.ets new file mode 100644 index 0000000000..eb8a041072 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeArguments.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.2.1 + * typeArguments: + * '<' type(','type)* '>' + * ; + */ + +class KeyValuePair {} + +class KeyValuePair1 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameter.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameter.ets new file mode 100644 index 0000000000..ec6d67eae7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameter.ets @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.1 + * typeParameter: + * ('in' | 'out')? identifier constraint? typeParameterDefault? + * ; + */ + +class G0 {} + +class G1 {} + +class G2 {} + +class G3 {} + +class G4 {} + +class G5 {} + +class G6 {} + +class G7 {} + +class G8 {} + +class G9 {} + +class G10 {} + +class G11 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterDefault.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterDefault.ets new file mode 100644 index 0000000000..ab17faa49a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterDefault.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.1 + * typeParameterDefault: + * '=' typeReference ('[]')? + * ; + */ + +function printArray(values: T): void {} + +function printA(values: T): void {} diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterList.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterList.ets new file mode 100644 index 0000000000..5698d477dc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameterList.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.1 + * typeParameterList: + * typeParameter (',' typeParameter)* + * ; + */ + +class C1 {} + +class C2 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameters.ets b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameters.ets new file mode 100644 index 0000000000..07a7e80c02 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/5_generics/TypeParameters.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 {} diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/ArgumentSequence.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/ArgumentSequence.ets new file mode 100644 index 0000000000..a97f99270c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/ArgumentSequence.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 + * argumentSequence: + * restArgument + * | expression (','expression)* (','restArgument)? ','? + * ; + */ + +function myFunction0(first: string) {} +myFunction0("1"); + +function myFunction1(first: string,) {} +myFunction1("1",); + +function myFunction2(first: string, sec: string) {} +myFunction2("1", "2"); + +function myFunction3(first: string, sec: string,) {} +myFunction3("1", "2",); + +function myFunction4(first: string, sec: string, ...rest: string[]) {} +myFunction4("apple", "banana", "cherry", "date"); + +function myFunction5(first: string, ...rest: string[]) {} +myFunction5("apple", "banana"); diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/Arguments.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/Arguments.ets new file mode 100644 index 0000000000..291ab15340 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/Arguments.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 + * arguments: + * '(' argumentSequence?')' + * ; + */ + +function add(a: number, b: number) { + return a + b; +} +add(1, 2); + +function add1() { + return 1; +} +add1(); diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/BinaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/BinaryExpression.ets new file mode 100644 index 0000000000..d2331de297 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/BinaryExpression.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * binaryExpression: + * multiplicativeExpression + * | additiveExpression + * | shiftExpression + * | relationalExpression + * | equalityExpression + * | bitwiseAndLogicalExpression + * | conditionalAndExpression + * | conditionalOrExpression + * ; + */ + +let result7 = 5 * 3; + +let result8 = 5 + 3; + +let result9 = 5 << 2; + +let res1 = 5 < 3; + +let res2 = 5 == 6; + +let res3 = 5 & 3; + +let res4 = true && false; + +let res5 = false || true; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/Expression.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/Expression.ets new file mode 100644 index 0000000000..b27854550e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/Expression.ets @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +let a = 5; + +class X {} +let x1 : X = new X(); +let ob : Object = x1 as Object; +let x2 : X = ob as X; + +class Animal {} +class Dog extends Animal {} +let animal = new Animal(); +let dog = new Dog(); + +let s: string = "name"; +typeof s; + +let expression1 = null; +let expression2 = "Default Value"; +let x = expression1 ?? expression2; + +let array1 = [1, 2, 3]; +let array2 = [4, 5]; +let array3 = [...array1, ...array2]; + +let num = 1; +let inc = ++num; + +let z = 10 / 2; + +let a1 = 5; +let b1 = 10; +let c1 = 15; +a1 = b1 = c1; + +let condition = true; +let result = condition ? "True" : "False"; + +let name = "str"; +let greeting = `Hello, ${name}`; + +let add = (x: number, y: number) => x + y; + +class B { + foo() {} +} +class A { + foo() {} + bar() { + let lambda = (this: B): void => { this.foo() } + new B().lambda(); + } +} + +let res = launch cof(10); +function cof(a: int): int { + let res: int; + return res; +} + +async function complexNumberProcessing(n: number) : Promise { + return n; +} +async function foo() { + for (let i = 1; i <= 5; i++) { + await complexNumberProcessing(i); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/ObjectReference.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/ObjectReference.ets new file mode 100644 index 0000000000..a43c30348e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/ObjectReference.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +class MyClass { + static myStaticMethod() {} +} +MyClass.myStaticMethod(); + +class BaseClass { + constructor() {} +} +class DerivedClass extends BaseClass { + constructor() { + super(); + } +} +new DerivedClass(); + +class MyClass1 { + myInstanceVariable = 'Hello'; + printVariable() { + this.myInstanceVariable; + } +} +const instance = new MyClass1(); +instance.printVariable(); diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/PrimaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/PrimaryExpression.ets new file mode 100644 index 0000000000..7fd1bb837d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/PrimaryExpression.ets @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7 + * primaryExpression: + * literal + * | namedReference + * | arrayLiteral + * | objectLiteral + * | recordLiteral + * | thisExpression + * | parenthesizedExpression + * | methodCallExpression + * | fieldAccessExpression + * | indexingExpression + * | functionCallExpression + * | newExpression + * | ensureNotNullishExpression + * ; + */ + +let age = 25; + +let PI = 3.14159; + +let x5 = [1, 2, 3]; + +class Person { + name: string = ""; + age: number = 0; +} + +let map: Record = { + "John": 25, + "Mary": 21, +} + +class Person1 { + name: string; + constructor(name: string) { + this.name = name; + } + greet(): void {} +} +let person = new Person1('Alice'); + +let y6 = (5 + 3); + +person.greet(); + +person.name; + +let numbers = [1, 2, 3, 4, 5]; +numbers[0]; + +function greet(name: string): void {} +greet('Alice'); + +class D { + constructor(p: number) {} +} +new D(5); + +let name: string | null = 'Alice'; +name!; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/RestArgument.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/RestArgument.ets new file mode 100644 index 0000000000..ff6a37c805 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/RestArgument.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 + * restArgument: + * '...'? expression + * ; + */ + +function sum(...numbers: number[]): number { + return 0; +} +sum(1, 2, 3); + +function sum1(numbers: number[]): number { + return 0; +} +sum1([1, 2]); diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/constantExpression.ets new file mode 100644 index 0000000000..f95cff0ab7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/constantExpression.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const PI = 3.14; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaExpression.ets new file mode 100644 index 0000000000..ded751a3af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaExpression.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.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + * + * lambdaBody: + * expression | block + * ; + */ + +@Retention("SOURCE") +@interface MyAnnotation {} + +let result1 = @MyAnnotation (x: number, y: number, z?: number) => x + y; + +let result2 = @MyAnnotation async (x: number, y: number, z?: number): Promise => { + return null; +}; + +let result4 = (x: number, y: number, z?: number) => x + y; + +let result5 = async (x: number, y: number, z?: number): Promise => { + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameter.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameter.ets new file mode 100644 index 0000000000..41c47c29bc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameter.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 7.32 + * lambdaParameter: + * annotationUsage? (lambdaRequiredParameter | lambdaOptionalParameter) + * ; + * + * lambdaRequiredParameter: + * identifier (':' type)? + * ; + * + * lambdaOptionalParameter: + * identifier '?' (':' type)? + * ; + * + * lambdaRestParameter: + * '...' lambdaRequiredParameter + * ; + * + */ + +@Retention("SOURCE") +@interface MyAnnotation {} + +@MyAnnotation(x: number) => {}; + +(x: number) => {}; + +@MyAnnotation(y?: number) => {}; + +(y?: number) => {}; + +(...numbers: number[]) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameterList.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameterList.ets new file mode 100644 index 0000000000..624a614c8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaParameterList.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.32 + * lambdaParameterList: + * lambdaParameter (',' lambdaParameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + * + */ + +(x: number, ...numbers: number[]) => {}; + +(x: number, y: string, ...numbers: number[]) => {}; + +(x: number) => {}; + +(x: number,) => {}; + +(x: number, y: string) => {}; + +(x: number, y: string,) => {}; + +(...numbers: number[]) => {}; diff --git a/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaSignature.ets b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaSignature.ets new file mode 100644 index 0000000000..1ea3337db7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/7_expressions/lambdaSignature.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.32.1 + * lambdaSignature: + * '(' lambdaParameterList? ')' returnType? + * | identifier + * ; + * + */ + +let result1 = () => {}; + +let result2 = (): number => { + return 0; +}; + +let result3 = (x: number) => {}; + +let result4 = (x: number): number => { + return ++x; +}; + +let result5 = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/block.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/block.ets new file mode 100644 index 0000000000..88754f8a32 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/block.ets @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.3 + * block: + * '{' statement* '}' + * ; + */ + +{} + +{ 2 + 3; } diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/breakStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/breakStatement.ets new file mode 100644 index 0000000000..992d610287 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/breakStatement.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 8.10 + * breakStatement: + * 'break' identifier? + * ; + */ + +outerLoop: for (let i = 0; i < 3; i++) { + if (i === 2) { + break outerLoop; + } +} + +for (let i = 0; i < 5; i++) { + if (i === 2) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/continueStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/continueStatement.ets new file mode 100644 index 0000000000..43327cb43c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/continueStatement.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 8.11 + * continueStatement: + * 'continue' identifier? + * ; + */ + +outerLoop: for (let i = 0; i < 3; i++) { + if (i === 1) { + continue outerLoop; + } +} + +for (let i = 0; i < 10; i++) { + if (i === 1) { + continue; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/expressionStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/expressionStatement.ets new file mode 100644 index 0000000000..8be5153ddf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/expressionStatement.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.2 + * expressionStatement: + * expression + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/forOfStatement.ets new file mode 100644 index 0000000000..f2b52216f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/forOfStatement.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + * + * forVariable: + * identifier | ('let' | 'const') identifier (':' type)? + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr) { + break; +} + +for (let item2 of arr) { + break; +} + +for (let item3: number of arr) { + break; +} + +for (const item4 of arr) { + break; +} + +for (const item5: number of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/forStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/forStatement.ets new file mode 100644 index 0000000000..96feb921c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/forStatement.ets @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + * + * forInit: + * expressionSequence + * | variableDeclarations + * ; + * + * forContinue: + * expression + * ; + * + * forUpdate: + * expressionSequence + * ; + */ + +let i: number = 1; +for (; i < 10; i++) { + if (true) { + break; + } +} + +for (; i < 10;) { + if (true) { + break; + } +} +for (;; i++) { + if (true) { + break; + } +} + +for (;;) { + if (true) { + break; + } +} + +for (i = 1; i < 10; i++) { + if (true) { + break; + } +} + +for (i = 1; i < 10;) { + if (true) { + break; + } +} + +for (i = 1;; i++) { + if (true) { + break; + } +} + +for (i = 1;;) { + if (true) { + break; + } +} + +for (let j = 1; i < 10; i++) { + if (true) { + break; + } +} + +for (let j = 1; i < 10;) { + if (true) { + break; + } +} + +for (let j = 1;; i++) { + if (true) { + break; + } +} + +for (let j = 1;;) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/ifStatement.ets new file mode 100644 index 0000000000..f3fa94a60f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/ifStatement.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 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + * + * thenStatement: + * statement + * ; + * + * elseStatement: + * statement + * ; + */ + +if (true) { + console.log("true"); +} + +if (false) { + console.log("true"); +} else { + console.log("false"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/localDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/localDeclaration.ets new file mode 100644 index 0000000000..b4c9455108 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/localDeclaration.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 8.4 + * localDeclaration: + * annotationUsage? + * ( variableDeclaration + * | constantDeclaration + * | typeDeclaration + * ) + * ; + */ + +@Retention("SOURCE") +@interface MyAnnotation {} + +@MyAnnotation let a = 10; + +let b = "a"; + +@MyAnnotation const c = 20; + +const d = 20; + +@MyAnnotation type Vector1 = number[]; + +type Vector2 = number[]; diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/loopStatement.ets new file mode 100644 index 0000000000..99d308e00c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/loopStatement.ets @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +whileLoop: while(true) { + break; +} + +while(true) { + break; +} + +let n = 1; +let m = 1; +doLoop: do { + n--; +} while(n > 0) + +do { + m--; +} while(m > 0) + +forLoop: for (let i = 0; i < 5; i++) { + break; +} + +for (let i = 0; i < 5; i++) { + break; +} + +let arr = [1, 2, 3]; +let item: number = 1; +forOfLoop: for (item of arr) { + break; +} + +for (item of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/returnStatement.ets new file mode 100644 index 0000000000..6c28cabdaa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/returnStatement.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 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, number2: number) { + return number1 + number2; +} + +function nullish() { + return; +} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/statement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/statement.ets new file mode 100644 index 0000000000..1e2a176622 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/statement.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.1 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let x = 10; + +{} + +const c = 20; + +if (true) console.log("true"); + +for (let i = 0; i < 1; i++) {} + +for (let i = 0; i < 4; i++) { + if (i == 1) { + continue; + } + if (i == 3) { + break; + } +} + +function add(number1: number, number2: number) { + return number1 + number2; +} + +switch (x) {} + +function riskyFunction() {}; +try { + riskyFunction(); +} catch (error) { + throw new Error(); +} +finally {} diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/switchStatement.ets new file mode 100644 index 0000000000..cccc5eac81 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/switchStatement.ets @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + * + * switchBlock: + * '{' caseClause * defaultClause? caseClause * '}' + * ; + * + * caseClause: + * 'case' expression ':' statement * + * ; + * + * defaultClause: + * 'default' ':' statement * + * ; + */ + +let x = 10; +switch (x) {} + +switch (x) { + case 1: break; +} + +switch (x) { + default: break; +} + +switch (x) { + case 1: break; + default: break; +} + +switch (x) { + case 1: break; + case 2: break; +} + +switch (x) { + default: break; + case 2: break; +} + +switch (x) { + case 1: break; + default: break; + case 2: break; +} + + label: switch (x) {} + + label: switch (x) { + case 1: break; + } + + label: switch (x) { + default: break; + } + + label: switch (x) { + case 1: break; + default: break; + } + + label: switch (x) { + case 1: break; + case 2: break; + } + + label: switch (x) { + default: break; + case 2: break; + } + + label: switch (x) { + case 1: break; + default: break; + case 2: break; + } diff --git a/ets2panda/test/ast/compiler/ets/spec/8_statements/whileDoStatement.ets b/ets2panda/test/ast/compiler/ets/spec/8_statements/whileDoStatement.ets new file mode 100644 index 0000000000..c8f3d459ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/8_statements/whileDoStatement.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 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + * doStatement + * : 'do' statement 'while' '(' expression ')' + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + m--; +} + +do { + n--; +} while(n > 0) diff --git a/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorBody.ets b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorBody.ets new file mode 100644 index 0000000000..16692da07a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorBody.ets @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 9.9.2 + * constructorBody: + * '{' statement* constructorCall? statement* '}' + * ; + * + * constructorCall: + * 'this' arguments + * | 'super' arguments + * ; + */ + +class ExampleClass1 { + construct() {} +} + +class ExampleClass2 { + construct() { + const value: number = 10; + } +} + +class ExampleClass3 { + constructor() { + const value: number = 9; + const message: string = "message"; + } +} + +class ExampleClass4 { + public field: number; + constructor(p: number) { + const value: number = 9; + this.field = p; + } +} + +class ExampleClass5 { + public field: number; + constructor(p: number) { + this.field = p; + const value: number = 9; + } +} + +class ExampleClass6 { + public field: number; + constructor(p: number) { + const value: number = 9; + this.field = p; + const message: string = "message"; + } +} + +class ExampleClass7 { + public field: number; + constructor(p: number) { + this.field = p; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorCall.ets b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorCall.ets new file mode 100644 index 0000000000..2e4f31c3a7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorCall.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 9.9.2 + * constructorCall: + * 'this' arguments + * | 'super' arguments + * ; + * + * constructorBody: + * '{' statement* constructorCall? statement* '}' + * ; + */ + +class ThisExample { + public field: number; + constructor(p: number) { + this.field = p; + } +} + +class SuperExample extends ThisExample{ + constructor(p: number) { + super(p); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorDeclaration.ets new file mode 100644 index 0000000000..54cb857bf0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec/9_classes/ConstructorDeclaration.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 9.9 + * constructorDeclaration: + * 'constructor' parameters throwMark? constructorBody + * ; + * + * CHAPTER 9.9.2 + * constructorBody: + * '{' statement* constructorCall? statement* '}' + * ; + */ + +class ExampleClass1 { + constructor () {} +} + +class ExampleClass2 { + constructor(value: number) { + if (value < 0) { + throw new Error('Value cannot be negative'); + } + } +} diff --git a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt index 303bff6cd2..a7761fa1b3 100644 --- a/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt +++ b/ets2panda/test/test-lists/astchecker/astchecker-ets-ignored.txt @@ -5,6 +5,10 @@ ast/parser/ets/iterator_override_next.ets ast/parser/ets/switch_readonly_member_different_enum_2.ets ast/parser/ets/extension_function_tests/extension_function_not_for_class_type.ets +# Issue: #IBWNFN +ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets +ast/compiler/ets/spec/2_lexical_elements/LineContinuation.ets + # Issue: #20326 ast/compiler/ets/readonlyType_6.ets ast/parser/ets/class_interface_enum_only_top_level_5.ets diff --git a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt index 47504eb951..7f5e734415 100644 --- a/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt +++ b/ets2panda/test/test-lists/srcdumper/srcdumper-ets-ignored.txt @@ -6,6 +6,27 @@ parser/ets/string_template_2.ets parser/ets/string_template_3.ets parser/ets/string_template_4.ets +# FailKind.ES2PANDA_FAIL (Issue: #IBWNFN) +ast/compiler/ets/spec/2_lexical_elements/EscapeSequence.ets + +# FailKind.SRC_DUMPER_FAIL (Issue: #IBWNFN) +ast/compiler/ets/spec/13_compilation_units/CompilationUnit.ets +ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirective.ets +ast/compiler/ets/spec/13_compilation_units/DeclarationModule/ImportDirectiveAmbientDeclarationTypeAliasSelectiveExportDirective.ets +ast/compiler/ets/spec/13_compilation_units/DefaultBinding/DefaultAsIdentifier.ets +ast/compiler/ets/spec/13_compilation_units/DefaultBinding/Identifier.ets +ast/compiler/ets/spec/13_compilation_units/ExportDirective.ets +ast/compiler/ets/spec/13_compilation_units/ImportDirective.ets +ast/compiler/ets/spec/13_compilation_units/NameBinding.ets +ast/compiler/ets/spec/13_compilation_units/ReExportDirective.ets +ast/compiler/ets/spec/13_compilation_units/SelectiveBindings.ets +ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirective.ets +ast/compiler/ets/spec/13_compilation_units/SeparateModuleDeclaration/ImportDirectiveTopDeclarationTopLevelStatementsExportDirective.ets +ast/compiler/ets/spec/3_types/type.ets +ast/compiler/ets/spec/5_generics/TypeParameter.ets +ast/compiler/ets/spec/7_expressions/Expression.ets +ast/compiler/ets/spec/8_statements/continueStatement.ets + # FailKind.SRC_DUMPER_FAIL (Issue #20458) runtime/ets/annotation_tests/AnnotationForDifferentTypes.ets runtime/ets/annotation_tests/AnnotationForTypesInDifferentCase.ets -- Gitee