From de20a8a66c571ddbe9562037dc4cd208cfb8d5ce Mon Sep 17 00:00:00 2001 From: liujia178 Date: Tue, 8 Apr 2025 16:07:59 +0800 Subject: [PATCH] =?UTF-8?q?Identifier&&Literal=20=E7=89=B9=E6=80=A7?= =?UTF-8?q?=E6=AD=A3=E4=BA=A4=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liujia178 --- .../Literal/Literal_BooleanLiteral.ets | 36 +++++++++++++ .../Literal/Literal_FloatLiteral.ets | 38 ++++++++++++++ .../Literal/Literal_IntegerLiterals.ets | 39 +++++++++++++++ .../Literal_MultilineStringLiteral.ets | 40 +++++++++++++++ .../Literal/Literal_NullLiteral.ets | 39 +++++++++++++++ .../Literal/Literal_StringLiteral.ets | 40 +++++++++++++++ .../Literal/Literal_UndefinedLiteral.ets | 39 +++++++++++++++ .../Literal/Literal_additiveExpression.ets | 37 ++++++++++++++ .../Literal/Literal_annotationDeclaration.ets | 38 ++++++++++++++ .../Literal/Literal_annotationUsage.ets | 44 ++++++++++++++++ .../Literal/Literal_arrayLiteral.ets | 36 +++++++++++++ .../Literal/Literal_arrayType.ets | 36 +++++++++++++ .../Literal/Literal_assignmentExpression.ets | 36 +++++++++++++ .../Literal/Literal_awaitExpression.ets | 39 +++++++++++++++ .../Literal_bitwiseAndLogicalExpression.ets | 38 ++++++++++++++ .../Literal/Literal_classInitializer.ets | 43 ++++++++++++++++ .../Literal_conditionalAndExpression.ets | 36 +++++++++++++ .../Literal/Literal_conditionalExpression.ets | 36 +++++++++++++ .../Literal_conditionalOrExpression.ets | 36 +++++++++++++ .../Literal/Literal_constantDeclarations.ets | 36 +++++++++++++ .../Literal/Literal_constantExpression.ets | 36 +++++++++++++ .../Literal_ensureNotNullishExpression.ets | 36 +++++++++++++ .../Literal/Literal_equalityExpression.ets | 36 +++++++++++++ .../Literal/Literal_exportDirective.ets | 40 +++++++++++++++ .../Literal/Literal_expression.ets | 50 +++++++++++++++++++ .../Literal/Literal_fieldAccessExpression.ets | 41 +++++++++++++++ .../Literal/Literal_finallyClause.ets | 43 ++++++++++++++++ .../Literal/Literal_forOfStatement.ets | 40 +++++++++++++++ .../Literal/Literal_forStatement.ets | 41 +++++++++++++++ .../Literal_functionCallExpression.ets | 40 +++++++++++++++ .../Literal/Literal_ifStatement.ets | 39 +++++++++++++++ .../Literal/Literal_importDirective.ets | 37 ++++++++++++++ .../Literal/Literal_indexingExpression.ets | 37 ++++++++++++++ .../Literal/Literal_initializerBlock.ets | 40 +++++++++++++++ .../Literal/Literal_instanceOfExpression.ets | 36 +++++++++++++ .../Literal/Literal_lambdaExpression.ets | 38 ++++++++++++++ .../Literal_lambdaExpressionWithReceiver.ets | 39 +++++++++++++++ .../Literal/Literal_loopStatement.ets | 42 ++++++++++++++++ .../Literal/Literal_methodCallExpression.ets | 44 ++++++++++++++++ .../Literal_multiplicativeExpression.ets | 38 ++++++++++++++ .../Literal/Literal_namespaceDeclaration.ets | 39 +++++++++++++++ .../Literal/Literal_newArrayInstance.ets | 37 ++++++++++++++ .../Literal/Literal_newExpression.ets | 41 +++++++++++++++ .../Literal_nullishCoalescingExpression.ets | 36 +++++++++++++ .../Literal/Literal_objectLiteral.ets | 39 +++++++++++++++ .../Literal/Literal_objectReference.ets | 38 ++++++++++++++ .../Literal/Literal_optionalParameter.ets | 37 ++++++++++++++ .../Literal/Literal_parameterList.ets | 39 +++++++++++++++ .../Literal_parenthesizedExpression.ets | 36 +++++++++++++ .../Literal/Literal_reExportDirective.ets | 36 +++++++++++++ .../Literal/Literal_recordLiteral.ets | 39 +++++++++++++++ .../Literal/Literal_relationalExpression.ets | 39 +++++++++++++++ .../Literal/Literal_restParameter.ets | 38 ++++++++++++++ .../Literal/Literal_returnStatement.ets | 38 ++++++++++++++ .../Literal_separateModuleDeclaration.ets | 36 +++++++++++++ .../Literal/Literal_shiftExpression.ets | 38 ++++++++++++++ .../Literal/Literal_siganture.ets | 38 ++++++++++++++ .../Literal/Literal_spreadExpression.ets | 39 +++++++++++++++ .../Literal/Literal_statement.ets | 46 +++++++++++++++++ .../Literal/Literal_stringInterpolation.ets | 37 ++++++++++++++ .../Literal/Literal_switchStatement.ets | 39 +++++++++++++++ .../Literal/Literal_thisExpression.ets | 41 +++++++++++++++ .../Literal/Literal_throwStatement.ets | 36 +++++++++++++ .../Literal/Literal_topDeclaration.ets | 45 +++++++++++++++++ .../Literal/Literal_topLevelStatements.ets | 36 +++++++++++++ .../Literal/Literal_trailingLambdaCall.ets | 47 +++++++++++++++++ .../Literal/Literal_tryStatement.ets | 43 ++++++++++++++++ .../Literal/Literal_tupleType.ets | 36 +++++++++++++ .../Literal/Literal_typeOfExpression.ets | 37 ++++++++++++++ .../Literal/Literal_typeParameters.ets | 38 ++++++++++++++ .../Literal/Literal_unaryExpression.ets | 43 ++++++++++++++++ .../Literal/Literal_unionType.ets | 36 +++++++++++++ .../Literal/Literal_variableDeclarations.ets | 36 +++++++++++++ .../Literal/Literal_whileStatement.ets | 40 +++++++++++++++ 74 files changed, 2874 insertions(+) create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_BooleanLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_FloatLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_IntegerLiterals.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_MultilineStringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_NullLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_StringLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_UndefinedLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_additiveExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationUsage.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_assignmentExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_awaitExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_bitwiseAndLogicalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_classInitializer.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalAndExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalOrExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ensureNotNullishExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_equalityExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_exportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_expression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_fieldAccessExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_finallyClause.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forOfStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_functionCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ifStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_importDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_indexingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_initializerBlock.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_instanceOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpressionWithReceiver.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_loopStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_methodCallExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_multiplicativeExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_namespaceDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newArrayInstance.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_nullishCoalescingExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectReference.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_optionalParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parameterList.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parenthesizedExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_reExportDirective.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_recordLiteral.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_relationalExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_restParameter.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_returnStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_separateModuleDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_shiftExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_siganture.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_spreadExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_statement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_stringInterpolation.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_switchStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_thisExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_throwStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topDeclaration.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topLevelStatements.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_trailingLambdaCall.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tryStatement.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tupleType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeOfExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeParameters.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unaryExpression.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unionType.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_variableDeclarations.ets create mode 100644 ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_whileStatement.ets diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_BooleanLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_BooleanLiteral.ets new file mode 100644 index 0000000000..43f0fb635b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_BooleanLiteral.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.5 + * BooleanLiteral: + * 'true' | 'false' + * ; + */ + +true && false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_FloatLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_FloatLiteral.ets new file mode 100644 index 0000000000..fd23d85fb9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_FloatLiteral.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.3 + * FloatLiteral: + * DecimalIntegerLiteral'.' FractionalPart? ExponentPart?FloatTypeSuffix? + * |'.'FractionalPart ExponentPart? FloatTypeSuffix? + * | DecimalIntegerLiteral ExponentPart FloatTypeSuffix? + * ; + */ + +2 + 3.14; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_IntegerLiterals.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_IntegerLiterals.ets new file mode 100644 index 0000000000..339313deb6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_IntegerLiterals.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * |HexIntegerLiteral + * |OctalIntegerLiteral + * |BinaryIntegerLiteral + * ; + */ + +2 + 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_MultilineStringLiteral.ets new file mode 100644 index 0000000000..e61522de20 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_MultilineStringLiteral.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * ' ` ' (BacktickCharacter)* ' ` ' + * ; + */ + +let mulStr = `This is a +multi-line string literal.`; +let str = "abc"; + +let result = str + mulStr; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_NullLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_NullLiteral.ets new file mode 100644 index 0000000000..2520107085 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_NullLiteral.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + */ + +let n = null; +let str = "abc"; + +let result = str + n; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_StringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_StringLiteral.ets new file mode 100644 index 0000000000..759563adbf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_StringLiteral.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter * '\'' + * ; + */ + +let num = 123; +let str = "abc"; + +let result = num + str; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_UndefinedLiteral.ets new file mode 100644 index 0000000000..b8a8f1044b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_UndefinedLiteral.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let und = undefined; +let str = "abc"; + +let result = str + und; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_additiveExpression.ets new file mode 100644 index 0000000000..110cfee3ad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_additiveExpression.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +3 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationDeclaration.ets new file mode 100644 index 0000000000..101f2ad3e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationDeclaration.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface A { + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationUsage.ets new file mode 100644 index 0000000000..33d2fbdf72 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_annotationUsage.ets @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface DetailedAnnotation { + authorName: string; + creationDate: string; +} +@DetailedAnnotation({ + authorName: "张三", + creationDate: "2025-03-19" +}) +class DocumentedClass {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayLiteral.ets new file mode 100644 index 0000000000..bb3ca6f024 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayLiteral.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let x5 = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayType.ets new file mode 100644 index 0000000000..bd0a1da95d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_arrayType.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let arr: number[] = [10, 11]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_assignmentExpression.ets new file mode 100644 index 0000000000..00493c6d46 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_assignmentExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_awaitExpression.ets new file mode 100644 index 0000000000..61bfdc6220 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_awaitExpression.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function processString(text: string): Promise { + return "Processed: " + text; +} +const result1 = await processString("Hello"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000..aae96b4856 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_bitwiseAndLogicalExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.26 + * bitwiseAndLogicalExpression: + * expression '&' expression + * | expression '^' expression + * | expression '|' expression + * ; + */ + +5 & 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_classInitializer.ets new file mode 100644 index 0000000000..a2bc799096 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_classInitializer.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = false; + static initializerBlock() { + if (!ExampleClass1.initialized) { + ExampleClass1.initialized = true; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalAndExpression.ets new file mode 100644 index 0000000000..b0151b092c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalAndExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +true && true; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalExpression.ets new file mode 100644 index 0000000000..d857580ba0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +(7 > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalOrExpression.ets new file mode 100644 index 0000000000..3fea1b2ea2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_conditionalOrExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +true || false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantDeclarations.ets new file mode 100644 index 0000000000..26aa426f40 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantDeclarations.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const c: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantExpression.ets new file mode 100644 index 0000000000..da1fbf4d54 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_constantExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const PI = 3.14; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ensureNotNullishExpression.ets new file mode 100644 index 0000000000..e72e344f90 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ensureNotNullishExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +1!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_equalityExpression.ets new file mode 100644 index 0000000000..cd6e134dd2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_equalityExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +5 == 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_exportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_exportDirective.ets new file mode 100644 index 0000000000..20c2448c40 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_exportDirective.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.9 + * exportDirective: + * selectiveExportDirective + * | singleExportDirective + * | exportTypeDirective + * | reExportDirective + * ; + */ + +class A {} +export type {A}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_expression.ets new file mode 100644 index 0000000000..7a9ed310fd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_expression.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const PI = 3.14; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_fieldAccessExpression.ets new file mode 100644 index 0000000000..b6ff046bd9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_fieldAccessExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + name: string = 'Alice'; +} + +let person = new Person1(); +person.name = 'Bob'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_finallyClause.ets new file mode 100644 index 0000000000..15b9ed4cbb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_finallyClause.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(a: number): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally {} +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forOfStatement.ets new file mode 100644 index 0000000000..d30be8035a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forOfStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [1, 2, 3]; +let item: number = 1; +for (item of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forStatement.ets new file mode 100644 index 0000000000..28a882ddb0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_forStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: number = 1; +for (; i < 10; i++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_functionCallExpression.ets new file mode 100644 index 0000000000..df97da2515 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_functionCallExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function func1(x: number): number { + return 0; +} + +func1(1); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ifStatement.ets new file mode 100644 index 0000000000..0c9f994b5d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_ifStatement.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (true) { + console.log("true"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_importDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_importDirective.ets new file mode 100644 index 0000000000..859d3e8f9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.3 + * importDirective: + * 'import' allBinding|selectiveBindings|defaultBinding|typeBinding + * 'from' importPath + * ; + */ + +import { A } from "./Literal_exportDirective"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_indexingExpression.ets new file mode 100644 index 0000000000..3252ac77b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_indexingExpression.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.12 + * indexingExpression : + * expression ('?.')? '[' expression ']' + * ; + */ + +let numbers = [1, 2, 3, 4, 5]; +numbers[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_initializerBlock.ets new file mode 100644 index 0000000000..381248eb5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_initializerBlock.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let sum = 1 + 2 ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_instanceOfExpression.ets new file mode 100644 index 0000000000..4937bc3ed6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_instanceOfExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +"string" instanceof string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpression.ets new file mode 100644 index 0000000000..9ec8afa0a3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: number, y: number, z?: number): Promise => { + return null; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000..deab61763c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_lambdaExpressionWithReceiver.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A): number => { return 0; }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_loopStatement.ets new file mode 100644 index 0000000000..6b16a770cf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_loopStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(true) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_methodCallExpression.ets new file mode 100644 index 0000000000..584fa5cb2a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_methodCallExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: string = 'Alice'; + setName(name: string): void { + this.name = name; + } +} + +let person = new Person2(); +person.setName('Bob'); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_multiplicativeExpression.ets new file mode 100644 index 0000000000..c2a43e1a21 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_multiplicativeExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.21 + * multiplicativeExpression: + * expression '*' expression + * | expression '/' expression + * | expression '%' expressionc + * ; + */ + +3 * 4; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_namespaceDeclaration.ets new file mode 100644 index 0000000000..4b170ddd4a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_namespaceDeclaration.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: number; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newArrayInstance.ets new file mode 100644 index 0000000000..6e215d5573 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newArrayInstance.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +let a = new string[1]; +a[0] = "a"; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newExpression.ets new file mode 100644 index 0000000000..902cc6c9bd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_newExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: number) {} +} + +new D(5); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_nullishCoalescingExpression.ets new file mode 100644 index 0000000000..9349a9b808 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_nullishCoalescingExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +null ?? 42; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectLiteral.ets new file mode 100644 index 0000000000..859d394fe7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectLiteral.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: string = "NAME"; + age: number = 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectReference.ets new file mode 100644 index 0000000000..5fdeb85eb7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_objectReference.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +let a: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_optionalParameter.ets new file mode 100644 index 0000000000..fed49a04d7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_optionalParameter.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function pair(x: number, y: number = 7) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parameterList.ets new file mode 100644 index 0000000000..42927cb6e8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parameterList.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function func1(x: number, y: string): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parenthesizedExpression.ets new file mode 100644 index 0000000000..6c1a4c1748 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_parenthesizedExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let y6 = (5 + 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_reExportDirective.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_reExportDirective.ets new file mode 100644 index 0000000000..28fbd3ce8e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_reExportDirective.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.9.4 + * reExportDirective: + * 'export' ('*' | selectiveBindings) 'from' importPath + * ; + */ + +export * from './Literal_expression'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_recordLiteral.ets new file mode 100644 index 0000000000..c1479eea10 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_recordLiteral.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.5.3 + * recordLiteral: + * '{' keyValueSequence? '}' + * ; + */ + +let map: Record = { + "John": 25, + "Mary": 21, +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_relationalExpression.ets new file mode 100644 index 0000000000..06c2068c0a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_relationalExpression.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +5 < 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_restParameter.ets new file mode 100644 index 0000000000..3f80ae1490 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_restParameter.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(...numbers: number[]): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_returnStatement.ets new file mode 100644 index 0000000000..bdbc20a2c6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_returnStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, number2: number) { + return number1 + number2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_separateModuleDeclaration.ets new file mode 100644 index 0000000000..57de3be217 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_separateModuleDeclaration.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +let v2 = 2 + 3 * 4; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_shiftExpression.ets new file mode 100644 index 0000000000..f7b9a8ccdd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_shiftExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.23 + * shiftExpression: + * expression '<<' expression + * | expression '>>' expression + * | expression '>>>' expression + * ; + */ + +5 << 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_siganture.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_siganture.ets new file mode 100644 index 0000000000..9932de988a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_siganture.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +function func1(x: number): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_spreadExpression.ets new file mode 100644 index 0000000000..9519f8f037 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_spreadExpression.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let array1 = [1, 2, 3]; +let array2 = [4, 5]; +let array3 = [...array1, ...array2]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_statement.ets new file mode 100644 index 0000000000..0207f0abc6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_statement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let x = 10; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_stringInterpolation.ets new file mode 100644 index 0000000000..aa393f0caf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_stringInterpolation.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = 'Alice'; +`Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_switchStatement.ets new file mode 100644 index 0000000000..22a44bf73d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_switchStatement.ets @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.13 + * switchStatement: + * (identifier ':')? 'switch' '(' expression ')' switchBlock + * ; + */ + +let x = 10; +switch (x) { + case 1: break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_thisExpression.ets new file mode 100644 index 0000000000..87fcbcd2f2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_thisExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public field: number; + constructor() { + this.field = 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_throwStatement.ets new file mode 100644 index 0000000000..58c9b39550 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_throwStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error("error"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topDeclaration.ets new file mode 100644 index 0000000000..dbd1f53134 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topDeclaration.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +let v2 = 2 + 3 * 4; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topLevelStatements.ets new file mode 100644 index 0000000000..9f5cecbf5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_topLevelStatements.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: number = 56; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_trailingLambdaCall.ets new file mode 100644 index 0000000000..2d48cc9d9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_trailingLambdaCall.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + + * CHAPTER 17.13 + * trailingLambdaCall: + * ( objectReference '.' identifier typeArguments? + * | expression ('?.' | typeArguments)? + * ) + * arguments block + * ; + */ + +class A { + methodTwo(arg: T, callback: (result: T) => void): void { + const result = arg; + callback(result); + } +} +let a = new A(); +a.methodTwo("Hi") {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tryStatement.ets new file mode 100644 index 0000000000..0e2c7d2012 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tryStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processOne(a: number): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tupleType.ets new file mode 100644 index 0000000000..5157302fcb --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_tupleType.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let tup: [string, number, boolean, number] = ['s', 1, true, 10]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeOfExpression.ets new file mode 100644 index 0000000000..1ead1e0572 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeOfExpression.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 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let s: string = 'a'; +typeof s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeParameters.ets new file mode 100644 index 0000000000..eed05d455e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_typeParameters.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + public a: string = "StringLiteral"; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unaryExpression.ets new file mode 100644 index 0000000000..1987276bf3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unaryExpression.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unionType.ets new file mode 100644 index 0000000000..a5413014c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_unionType.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +let u: string | number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_variableDeclarations.ets new file mode 100644 index 0000000000..7205408daa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_variableDeclarations.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let v: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_whileStatement.ets new file mode 100644 index 0000000000..0db9b6c5d0 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/Literal/Literal_whileStatement.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 2.9 + * Literal: + * IntegerLiteral + * | FloatLiteral + * | BigIntLiteral + * | BooleanLiteral + * | StringLiteral + * | MultilineStringLiteral + * | NullLiteral + * | UndefinedLiteral + * | CharLiteral + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + m--; +} -- Gitee