diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_BooleanLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_BooleanLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..f231a75cdb38f8d7243421ca730cebb3b6b833e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_BooleanLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 2.9.5 + * BooleanLiteral: + * 'true' | 'false' + * ; + */ + +1 && false; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_FloatLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_FloatLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..e0f65736da25a88a63b18e87f12bec074e9626d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_FloatLiteral.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_MultilineStringLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..20837920cbcdff406a6285b40ab44af9853ee584 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_MultilineStringLiteral.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * ' ` ' (BacktickCharacter)* ' ` ' + * ; + */ + +let mulStr = `This is a +multi-line string literal.`; +let f = 1; + +let result = 1 + mulStr; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_StringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_StringLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..3982f43d2f49031381e94fa78fa051632a1e3d37 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_StringLiteral.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter * '\'' + * ; + */ + +let num = 1; +let str = "abc"; + +let result = num + str; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_UndefinedLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..c8dfc15d69420ce97362129d175c3eb078800285 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_UndefinedLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let und = undefined; +let flo = 20; + +let result = flo && und; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..94e9bc6d9ccad4af5bc8f2523d654ce29298af7a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_additiveExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +3 + 2; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..e96467cbb3e2e7092af1b6d93e7003cee29f417a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationDeclaration.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface test { + value: number = 10; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationUsage.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationUsage.ets new file mode 100644 index 0000000000000000000000000000000000000000..185a2b9971ef50d37fd76e093b402ed7b819ce87 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_annotationUsage.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 18.2 + * annotationUsage: + * 'at' qualifiedName annotationValues? + * ; + */ + +@interface DetailedAnnotation { + authorAge: number; +} +@DetailedAnnotation({ + authorAge: 22, +}) +class DocumentedClass {}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..1742ebb08dfafc91dc5f546af24244a6b6b8f2af --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let x5 = [1, 2, 3]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayType.ets new file mode 100644 index 0000000000000000000000000000000000000000..06fb4351e0c60ba416cbe5d7a07eeda03d0584e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_arrayType.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let arr: number[] = [10, 11]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b8292c55f82d8acdb0d77b1183676cfb17f6b9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_assignmentExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..818883189e336cfd59070aba7df4acbe859fa189 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_awaitExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(name: number): Promise { + return Promise.resolve(2); +} + +await foo(2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_bitwiseAndLogicalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_bitwiseAndLogicalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0947e3134822d9e92d47797f7a863ab58e82b553 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_bitwiseAndLogicalExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6c60c16aa37732fb7d55262aa9b4406e2e1fd3e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_classInitializer.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = 1; + static initializerBlock() { + if (!ExampleClass1.initialized) { + ExampleClass1.initialized = 1; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..84baeb6b1c457fe4603c35a93c46dc07fa39959f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalAndExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +1 && 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..203461e214c40b925e7b3b30f072bfdb61ff93c4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +(7 > 5) ? 7 : 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..17dc34f1a28e062faa1ce4bdaa768f67b91c0df1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_conditionalOrExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +1 || 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..dffafaebc2e29fc2575c8be1607505b767700da8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantDeclarations.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const c: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..5f35050a55116422f58373874940fd462b5100a9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_constantExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const PI = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ca2234f5617326b4dd4a72723145166b8d3dca19 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_ensureNotNullishExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +1!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e9e015b6b27eda9895c8b97234d0c0003f65988f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_equalityExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +5 == 5; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..023d33b6c632755d53b27af01f0000c3c4b23b08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_expression.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const PI = 3; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e37d1b077a46f628533e452be84d1b5917b71db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_fieldAccessExpression.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + age: number = 1; +} + +let person = new Person1(); +person.age = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..e84ef1a2a22b5a78130845d83336fbf384c021bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_finallyClause.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +function processOne(a: number): number { + try { + const res = 1; + return res; + } catch (error) { + return -1; + } finally { + let res1 = 1; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..271edae9822094df01b16a30b1da35a7dcb6e35c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_forOfStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8bbbf3ad55dda23b9832ac740d69fa78fcc84e08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_forStatement.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a7c3a6da74b756ec066a0453590fa280c957fd8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_functionCallExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6d7d2d74fe083617106f5dbdd582e2d9e6927cca --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_ifStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (3 < 5) { + console.log("true"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f368d062b10205398088d458814c9b5b03dc8311 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_indexingExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6d68ea52a25e1b0f9516e381e62b17b47f43d5f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_initializerBlock.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..61e91cf982a7bb5b0ca896628c8ab0fdffa66141 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_lambdaExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: int): Promise => { + return 0; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..3644737e2a015a1bf387d371130edb15be84017b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ced19f12cfe32ef007a8242c585e34d1b6dc48b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_loopStatement.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(3 < 5) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9a51ebb54f913e4872b70d2a0c5b4fd02fd1464c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_methodCallExpression.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + age: number = 1; + setName(age: number): void { + this.age = age; + } +} + +let person = new Person2(); +person.setName(2); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_multiplicativeExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_multiplicativeExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..03570bf3f4b3a445ef7031d3d9bd795b8d3614f5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_multiplicativeExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd1ea03f83db7f068dd5bd71b207e4aa9e2ebc2f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_namespaceDeclaration.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + export let variable = 1234; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ce99a5e2442601e3f82f9f5e5e1678de5f42605 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_newArrayInstance.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..3538a721686e0161542da81fecae8a462e515df8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_newExpression.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.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3818dc52ac833f90e7ee33f56b43f37506c6c3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_nullishCoalescingExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +null ?? 42; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..9bd094c09b1b229f5b83fe01b922234cff66d08b --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_objectLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..175c7b56c728f47842c40f671fa472a05e03a7e5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_objectReference.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +let a: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..a31608d277f9275b40fb15e57db6a1fbc91dd44f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_optionalParameter.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_parameterList.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6835d32e8ed34bc20dd520bc8afa0aa53de80b2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_parameterList.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9fe63fae9dc482334b141a105fcc4c6d197dcbef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_parenthesizedExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let y6 = (5 + 3); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..022e56f629f9603582bb9de3fe2be789ba6bea98 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_recordLiteral.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f60e168e0537a55bc5d8808b7a15335c98ed2b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_relationalExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a0f152f18bd1a837241e5e98c0c6d1316175c62 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_restParameter.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..adf5823fd6e51377250681063414c9be5f490a4d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_returnStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(number1: number, number2: number) { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3d2b629b735aeaec56065c7c060d940548c8aa3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_separateModuleDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_shiftExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_shiftExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..deefb395078dc68e334a6a22643b4b2f1fc9a427 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_shiftExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9083c1850199eb557dcb5a127911c27667e926e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_signature.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..85e5c7e697b4151d2b0f414ae44ff739f37d1a1f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_spreadExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + *Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c589ca7f4407f353a760d32c7618d27cbd17567 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_statement.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..258ffd0277e696ab7024147434b5e0467d4ad9c1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_switchStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..12922125a6715906bca62a580cbf6d04b176facd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_thisExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..74866464f91f3cce330d55c0f253331ea990f904 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_topDeclaration.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..55acebe35ecffd7e2c9fafce6238f10ba1b362c7 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_topLevelStatements.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: number = 56; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..25473c74e3236ed5a56081ef0ee328e2af415e33 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_trailingLambdaCall.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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(1) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd5afa666ccb44aca6dd640a82dc0d6ff8c8a411 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_tryStatement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_tupleType.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ced1036cf0dcbe3d870d3f57841645d89fcde0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_tupleType.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..0c9e12c22eda26d9689843ecb799124ab32a672c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_typeOfExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let s: number = 1; +typeof s; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..640d1e4b2fa93192b8164b34e2a5a1e17f54d588 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_typeParameters.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +class C1 { + public a: number = 1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..525ce12e10f10562c440cd8fa99c41ee94306370 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_unaryExpression.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * 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/IntegerLiteral/IntegerLiteral_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_unionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..fa93b7b40a72a1e22ad84ad6b36b9983cf5b6638 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_unionType.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +let u: string | number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_variableDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..1bd12409a26981a5fc9db8f71a35712a9c408f77 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_variableDeclarations.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let v: number = 1; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc1bb48536f5256c27b55e8bad5e259ec26bd994 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/IntegerLiteral/IntegerLiteral_whileStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.2 + * IntegerLiteral: + * DecimalIntegerLiteral + * | HexIntegerLiteral + * | OctalIntegerLiteral + * | BinaryIntegerLiteral + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = 5; +let n = 3; +while(m < n) { + m--; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_UndefinedLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b05d2a4320b9192c6be4f7a8886e08e462b803 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_UndefinedLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let und = undefined; +let nul = null; + +console.info('und '+ und + ' null '+ nul) diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..dfc950b0658bffce5e1b96bd802bb39b9750a237 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayLiteral.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let x5 = ['1', null, null]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayType.ets new file mode 100644 index 0000000000000000000000000000000000000000..b62eda7bb4b9527246245a72521178b39eb7a56a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_arrayType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let arr: null[] = [null, null]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8cae0a1d681ebf64e583fb99fa82129cfaec2f4e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_assignmentExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e13fd3cf92f4dbbbe129678ede920c98ceba4bab --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_awaitExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(name: null): Promise { + return Promise.resolve(2.1); +} + +await foo(null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..12773e356762e4be3f2bd62a7512f6ea2b97474a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_classInitializer.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = null; + static initializerBlock() { + if (ExampleClass1.initialized == null) { + ExampleClass1.initialized = null; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..b1f8edb7a44a2c6726ee15e027430112763b355d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalAndExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +null && null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d74115931077c8a3887cbd143d053c3bbf64fb42 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +('7' > '5') ? null : '5'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d9310a334a9f7d55f48c757fdf98fd18c6540b8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_conditionalOrExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +null || null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..755d9af73393d5e79d9087c348091bb4f9c8c786 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantDeclarations.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const c: null = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..43dab1e39f1369e6a646f4bf38b5678c8d5cc6ae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_constantExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const str = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..59a994cb7f77a7e0d79d5d2f27a017034f750a17 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ensureNotNullishExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let value: null[] = [null]; +value!.length; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..aef0034f3e2ab0025dd11a3a4c2ea1e97483a592 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_equalityExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +null == null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d598d292a246566757d6dcd7c3d607ce280e568d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_expression.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const cat: null = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..47a2c072774c765ff64c44f4aa11f89b22132b49 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_fieldAccessExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.9 + * fieldAccessExpression: + * objectReference ('.' | '?.') identifier + * ; + */ + +class Person1 { + name: null = null; +} + +let person = new Person1(); +person.name = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ac307d2ab7d4e00895ca5bbd6d895ab5acf3a08 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_finallyClause.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.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A { + close() {} +} + +function processOne(): null { + let r = new A(); + try { + const res = null; + return res; + } catch (error) { + return null; + } finally { + r.close() + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b973f710d7fe2d6f928a0ad76969136b980530e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forOfStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = [null, null]; +let item: null = null; +for (item of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..4cda9b492a77af7836dced75f5511e2c17220eb4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_forStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let i: null = null; +for (; i != null; i = null) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e8ed755ccf99d2ea0315f89e0d4dd1d1e49f2f1e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionCallExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function func1(x: null): number { + return 0; +} + +func1(null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1599336264681a1a798ac040c4e36551c30b270 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_functionType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 3.19 + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + */ + +type t = () => null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..dae78f2d8605829baed7f24de068b8ca56883c0c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_ifStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.5 + * ifStatement: + * 'if' '(' expression ')' thenStatement + * ('else' elseStatement)? + * ; + */ + +if (null) { + console.log("null"); +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fda8d7b0ac1c9a271d85a0d66792ad195ecafc1c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_indexingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +let strings = [null, '2', '3', null, '5']; +strings[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..d62762a5cb6e06415c55df2156e15c3746133482 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_initializerBlock.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 15.10 + * initializerBlock: + * 'static' block + * ; + */ + +class Test { + static initializerBlock() { + let sum = null ; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4f4ea6f834d80efe02489b16a2215bd3cfb4267 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_instanceOfExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +null instanceof null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdbfbec9ff3ffa9a1fa0afcec0fa829eecbfb636 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: null): Promise => { + return x; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..42f04ecc9baed465e55b36f8390bc37fb3aa6efc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A): null => { return null; }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0e031af32f3f1d64d97d4c57036894f0a0ca7c9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_loopStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.6 + * loopStatement: + * (identifier ':')? + * whileStatement + * | doStatement + * | forStatement + * | forOfStatement + * ; + */ + +while(null) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..a46eaac301fa23d8a5d9b6395d784b7bc2013831 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_methodCallExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.10 + * methodCallExpression: + * objectReference ('.' | '?.') identifier typeArguments? arguments block? + * ; + */ + +class Person2 { + name: null = null; + setName(name: null): void { + this.name = name; + } +} + +let person = new Person2(); +person.setName(null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..b36fbd02c46606a5e7ab8a1699ce312f99898c30 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_namespaceDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdba607e1f9518b4ae3b40400d5f80dea36d90e3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newArrayInstance.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 17.3 + * newArrayInstance: + * 'new' arrayElementType dimensionExpression+ (arrayElement)? + * ; + */ + +const arr: null[] = []; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0100c8fcf1b76b860f02ece6a037763f5baa285 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_newExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: null) {} +} + +new D(null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..e81762817e7f0dccef12c418b0a8fd477073b9b9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_nullishCoalescingExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +null ?? 42; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..2254b5fab170010c971ee8f22a110277f93c2981 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectLiteral.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.5 + * objectLiteral: + * '{' valueSequence? '}' + * ; + */ + +class Person { + name: null = null; + age: null = null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd8ed0a2c0a78b4614e414e9d9ef1eb8c7aa53b1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_objectReference.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +let a: null = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..8345ef730f5fde3866a443f296c650c7bf367c26 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_optionalParameter.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function pair(x: null, y: null = null) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parameterList.ets new file mode 100644 index 0000000000000000000000000000000000000000..fce9f012173242d4bc1344fe52debb8a14afffcf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parameterList.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function func1(x: null, y: null): null { + return null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8c238b77dd8c7b4f7780198d2cf2441b66ad1d78 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_parenthesizedExpression.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let y6 = (null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..e912371272319d3112cca371ac0300cb61503c3f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_restParameter.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(...aaa: null[]): null { + return null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..922428f687e0f5e9d2c581e5dad18ead3bd58987 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_returnStatement.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(null1: null, null2: null) { + return null1; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cafb72093fbd2996ac86e417e3c2f2cc178740d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_separateModuleDeclaration.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +interface MyInterface { + doSomething(): null +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..d68c0aa582705aeeb8908bd042943d9af0b24aad --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_signature.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +function func1(x: null): null { + return null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2a2271900eb89673312cd18b97c083359b6acfa6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_spreadExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + *Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.6 + * spreadExpression: + * '...' expression + * ; + */ + +let array1 = [null, '2', '3']; +let array2 = ['4', null]; +let array3 = [...array1, ...array2]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..0d96002da32bbe546b3b13dce83a837b3399da41 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_statement.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let x = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d3ac563f545df7591153de056701cce50a12650 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_stringInterpolation.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.31 + * stringInterpolation: + * ' ` ' (BacktickCharacter | embeddedExpression)* ' ` ' + * ; + */ + +let name = null; +`Hello, my name is ${name}.`; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..37cd748d2f34d44694c1e79e6d4faf6b89e10b4f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_thisExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public field: null; + constructor() { + this.field = null; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb7ea82f6901eeaffcc82674b46c19d553b95aa2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_throwStatement.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error("null " + null); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe5d1dae4f2335faaff9c8b20d69b5bd5e43874f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topDeclaration.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export let x: null[], y: null diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..26b92edde6c55b01f1237c367eb6e9029a4e6da6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_topLevelStatements.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: null = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..6659c48ca2ca0f9706eeaecbc5b790da9514f74e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_trailingLambdaCall.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * 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(null) {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3b361c61104989735b4332d3b0b5f486ddc6edf5 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tryStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processOne(): null { + try { + const res = null; + return res; + } catch (error) { + return null; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tupleType.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5bc3ac2b6e88d7a0baf64942d79f4cc130a6057 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_tupleType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let tup: [null, number, boolean, string] = [null, 1, true, '10']; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeAlias.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeAlias.ets new file mode 100644 index 0000000000000000000000000000000000000000..718886eb59d95072942a6ebf96a48bb6f96fa510 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeAlias.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters? '=' type + * ; + */ + +let a: null | number = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..10d6a6b82a92b5f05386263b3edc322810573c99 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeArguments.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type(','type)* '>' + * ; + */ + +let a: Array<[number, null, boolean]>; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa3d71fcb076fe2a142d13ad8c00c17131c89af9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.17 + * typeOfExpression: + * 'typeof' expression + * ; + */ + +let s: null = null; +typeof null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..d4300cb4e9ffe34f8eea08f1b4b6458ada691ac4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_typeParameters.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +type nul = null | 'warn' | 'error'; +class C1 { + public a: null = null; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c3ba5516a1a4ac1d497ef08e205127c130cd45c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unaryExpression.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +!null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..0b65fe417f30bbc4ba625582d6a69f430d4a19f9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_unionType.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +let u: null | number = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_variableDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..1f5678fca82931ed291bcfccec050c4e93768de8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_variableDeclarations.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let v: null = null; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..3beb6526a124dc7edf8ac804aa819ea8ca1f8b85 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/NullLiteral/NullLiteral_whileStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = null; +let n = null; +while(m) { + m = n; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_MultilineStringLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_MultilineStringLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..aaa2da7d6b10021720aab5ad3e6284cbe8b474cd --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_MultilineStringLiteral.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 2.9.7 + * MultilineStringLiteral: + * ' ` ' (BacktickCharacter)* ' ` ' + * ; + */ + +let mulStr = `This is a +multi-line string literal.`; +let str = "This is a string literal."; + +let result = str + mulStr; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_NullLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_NullLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..1de4b8973322ef8f98144b031db6a031c9e95faa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_NullLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 2.9.8 + * NullLiteral: + * 'null' + * ; + */ + +let n = null; +let str = "This is a string literal."; + +let result = str + n; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_UndefinedLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_UndefinedLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..50061a92e7e8c4e2bdb488b0d40ecb99ef33282c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_UndefinedLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 2.9.9 + * UndefinedLiteral: + * 'undefined' + * ; + */ + +let und = undefined; +let str = "This is a string literal."; + +let result = str + und; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_additiveExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_additiveExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..9da9fe00f0244f43e04051bc5cf0b5af934ee76e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_additiveExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.22 + * additiveExpression: + * expression '+' expression + * | expression '-' expression + * ; + */ + +'string1' + 'string2'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_annotationDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_annotationDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9fa8e9eafbc61ebbd01a849a33e12e49b905531 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_annotationDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 18.1 + * annotationDeclaration: + * '@interface' identifier '{' annotationField* '}' + * ; + */ + +@interface str { + value: string = '10'; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d9cb42d69a5666245e1b072081b7f62579f7602 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayLiteral.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.4 + * arrayLiteral: + * '[' expressionSequence? ']' + * ; + */ + +let x5 = ['1', '2', '3']; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayType.ets new file mode 100644 index 0000000000000000000000000000000000000000..d86944bed2189adfee1ec8ece9914e094b1724ff --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_arrayType.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 3.17.1 + * arrayType: + * type '[' ']' + * ; + */ + +let arr: string[] = ['10', '11']; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_assignmentExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_assignmentExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..56bcf310f15169d059e78395b6c13a5bede03af3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_assignmentExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.29 + * assignmentExpression: + * lhsExpression assignmentOperator rhsExpression + * ; + */ + +let a = '5'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_awaitExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_awaitExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6541a477d44830a3376a8536d7532e716d65fbc8 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_awaitExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 17.16.2 + * awaitExpression: + * 'await' expression + * ; + */ + +async function foo(name: string): Promise { + return Promise.resolve(2); +} + +await foo("ggb"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_classInitializer.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_classInitializer.ets new file mode 100644 index 0000000000000000000000000000000000000000..40d2951ace2c7655a232f31cdc835182c96a7661 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_classInitializer.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 9.8 + * classInitializer: + * initializerBlock + * ; + */ + +class ExampleClass1 { + static initialized = 'false'; + static initializerBlock() { + if (ExampleClass1.initialized == 'false') { + ExampleClass1.initialized = 'true'; + } + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalAndExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalAndExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..75a6c3a02d1859f8f6650fb7fc692a01534f822e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalAndExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.27 + * conditionalAndExpression: + * expression '&&' expression + * ; + */ + +'true' && 'true'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..99c91142a81da20a5ae74df153cf77ad7053ff53 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.30 + * conditionalExpression: + * expression '?' expression ':' expression + * ; + */ + +('7' > '5') ? '7' : '5'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalOrExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalOrExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..2109da13b0cf557870c8bf831d21133a53ac1522 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_conditionalOrExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.28 + * conditionalOrExpression: + * expression '||' expression + * ; + */ + +'true' || 'false'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..a13955b601e533546a19fe5494d8e1af1a50f7e1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantDeclarations.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.7.2 + * constantDeclarations: + * 'const' constantDeclarationList + * ; + */ + +const c: string = '1'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6874ca7491ea2d6ddd87de772f9138497f037ea --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_constantExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.33 + * constantExpression: + * expression + * ; + */ + +const str = 'string'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ensureNotNullishExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ensureNotNullishExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..c0574f2d533c7d059d6bd5b8dc0850875c1c6f12 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ensureNotNullishExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.18 + * ensureNotNullishExpression: + * expression '!' + * ; + */ + +let name: string = 'Alice'; +name!; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_equalityExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_equalityExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ac37da5cdff27c7a41581c8edeec8bb0e82a13fa --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_equalityExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.25 + * equalityExpression: + * expression ('==' | '===' | '!=' | '!==') expression + * ; + */ + +'5' == '5'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_expression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_expression.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b368b983571f22744dbed27f0409d50e1a0ae25 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_expression.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7 + * expression: + * primaryExpression + * | castExpression + * | instanceOfExpression + * | typeOfExpression + * | nullishCoalescingExpression + * | spreadExpression + * | unaryExpression + * | binaryExpression + * | assignmentExpression + * | conditionalExpression + * | stringInterpolation + * | lambdaExpression + * | lambdaExpressionWithReceiver + * | launchExpression + * | awaitExpression + * ; + */ + +const cat: string = 'cat'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_fieldAccessExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_fieldAccessExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9285dc0a19e6eb5054ed2260d9fca5119fb83da --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_fieldAccessExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_finallyClause.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_finallyClause.ets new file mode 100644 index 0000000000000000000000000000000000000000..6b7b2247a05c10f0b1b4b6ff188f72aba8fb9f99 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_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.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.15.2 + * finallyClause: + * 'finally' block + * ; + */ + +class A { + close() {} +} + +function processOne(): string { + let r = new A(); + try { + const res = '1'; + return res; + } catch (error) { + return '-1'; + } finally { + r.close(); + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forOfStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forOfStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..671f95dfcf0b8274760c89b4a3be274284e5f3db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forOfStatement.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.9 + * forOfStatement: + * 'for' '(' forVariable 'of' expression ')' statement + * ; + */ + +let arr = ['1', '2', '3']; +let item: string = '1'; +for (item of arr) { + break; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..87d7b59edcd701ade8fb711a9fadebda9f4bb77a --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_forStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.8 + * forStatement: + * 'for' '(' forInit? ';' forContinue? ';' forUpdate? ')' statement + * ; + */ + +let a = 'Hello123World'; +for (let i = 0; i < a.length; i++) { + if (true) { + break; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..1ae83768b6a4e8416a07f402cedae64f1410def9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionCallExpression.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.11 + * functionCallExpression: + * expression ('?.' | typeArguments)? arguments block? + * ; + */ + +function func1(x: string): number { + return 0; +} + +func1('1'); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..da65bd02a5898c9fa163c88ea72ae8c85947ec87 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_functionType.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 3.19 + * functionType: + * '(' ftParameterList? ')' ftReturnType + * ; + */ + +type AllowedAction = "uppercase" | "lowercase" | "reverse"; + +type StringProcessor = (input: string, action: AllowedAction) => string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ifStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ifStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..9149f4e540ef800b846499ebe6137cdafc4482a6 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_ifStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_indexingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_indexingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc543f2bbe8e0e02c3bb19638f8500103ad23ae9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_indexingExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.12 + * indexingExpression: + * expression ('?.')? '[' expression ']' + * ; + */ + +let strings = ['1', '2', '3', '4', '5']; +strings[0]; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_initializerBlock.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_initializerBlock.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab9d08f4b17f804acbba8d5797e817ca4115cf74 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_initializerBlock.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_instanceOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_instanceOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..caaf7413406a38ec82eec0ad1080b3b0f5d9ca21 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_instanceOfExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.16 + * instanceOfExpression: + * expression 'instanceof' type + * ; + */ + +"string" instanceof string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..07bafdd26e9c708a12eb3f4d366e9800680b0e06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpression.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.32 + * lambdaExpression: + * annotationUsage? ('async'|typeParameters)? lambdaSignature '=>' lambdaBody + * ; + */ + +let result = async (x: string, y: string, z?: string): Promise => { + return x + y + z; +}; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpressionWithReceiver.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpressionWithReceiver.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a78d0529096be6171ec2dd19c7fa7b7b7d1f2db --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_lambdaExpressionWithReceiver.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 17.12.5 + * lambdaExpressionWithReceiver: + * annotationUsage? typeParameters? + * '(' receiverParameter (',' lambdaParameterList)? ')' + * returnType? throwMark? '=>' lambdaBody + * ; + */ + +class A {} +let result4 = (this: A): string => { return 'string'; }; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_loopStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_loopStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..1728c9c6636c5d3cdff8288fb60013b427350151 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_loopStatement.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_methodCallExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_methodCallExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff0628c3de17b710cb988de30c7895790dfc9762 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_methodCallExpression.ets @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_namespaceDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_namespaceDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..9ea98ce8d93c876850446a4af84079ca319aac56 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_namespaceDeclaration.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 13.8 + * namespaceDeclaration: + * 'namespace' qualifiedName + * '{' topDeclaration* initializerBlock? topDeclaration* '}' + * ; + */ + +namespace NS1 { + let a: string; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_newArrayInstance.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_newArrayInstance.ets new file mode 100644 index 0000000000000000000000000000000000000000..fe3700cd724b25dbc0c0703e54e157ea00857bb1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_newArrayInstance.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_newExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_newExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f61a303850e675e31600b08a97009cb5b3914ba3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_newExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.14 + * newExpression: + * newClassInstance + * | newArrayInstance + * ; + */ + +class D { + constructor(p: string) {} +} + +new D('5'); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_nullishCoalescingExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_nullishCoalescingExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ba99d6d297efc4e473283722c60d104240393c2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_nullishCoalescingExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.19 + * nullishCoalescingExpression: + * expression '??' expression + * ; + */ + +'string' ?? 42; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_objectLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_objectLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..92be7db6afcad0c1a683715e3827e7c5cb6de99c --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_objectLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_objectReference.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_objectReference.ets new file mode 100644 index 0000000000000000000000000000000000000000..6fc07603d6725c31f0fbc13c8b3d6429a2ef9b36 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_objectReference.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7 + * objectReference: + * typeReference + * |'super' + * | primaryExpression + * ; + */ + +let a: string = '1'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_optionalParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_optionalParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2e008f2b5c769af846ce87f7227995ea7a956d9 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_optionalParameter.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.8.4 + * optionalParameter: + * identifier ':' type '=' expression + * | identifier '?' ':' type + * ; + */ + +function pair(x: string, y: string = '7') {} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parameterList.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parameterList.ets new file mode 100644 index 0000000000000000000000000000000000000000..5b12baad0b82616ec47c8e207157ad5c00ae0378 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parameterList.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.8.2 + * parameterList: + * parameter (',' parameter)* (',' restParameter)? ','? + * | restParameter ','? + * ; + */ + +function func1(x: string, y: string): string { + return x + y; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parenthesizedExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parenthesizedExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c43bac5f9736147e40802dd714748bf0fb9b335 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_parenthesizedExpression.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.7 + * parenthesizedExpression: + * '(' expression ')' + * ; + */ + +let y6 = ('5' + '3'); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_recordLiteral.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_recordLiteral.ets new file mode 100644 index 0000000000000000000000000000000000000000..b561f6b5f02f57740b635b2e1faa9a7ca1b75bac --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_recordLiteral.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_relationalExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_relationalExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..d1080906969871f51ab21b75c0412353085e3f61 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_relationalExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.24 + * relationalExpression: + * expression '<' expression + * | expression '>' expression + * | expression '<=' expression + * | expression '>=' expression + * ; + */ + +'i' > '10'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_restParameter.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_restParameter.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e5bf3613e52e21f24475dba667f374cc2916fae --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_restParameter.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.8.5 + * restParameter: + * annotationUsage? '...' identifier ':' type + * ; + */ + +function sum(...string: string[]): number { + return 0; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_returnStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_returnStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..598b213d3ff100e10b2d494c5c38ecb1af352d9e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_returnStatement.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.12 + * returnStatement: + * 'return' expression? + * ; + */ + +function add(str1: string, str2: string) { + return str1 + str2; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_separateModuleDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_separateModuleDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..98a03ea5c4bfa57249589880b512442c104a6665 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_separateModuleDeclaration.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 13.1 + * separateModuleDeclaration: + * importDirective* (topDeclaration | topLevelStatements | exportDirective)* + * ; + */ + +interface MyInterface { + doSomething(): string; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_signature.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_signature.ets new file mode 100644 index 0000000000000000000000000000000000000000..07097c06aef88ba5a41a8d8e084023675e3b6cc2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_signature.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.8.1 + * signature: + * '(' parameterList? ')' returnType? + * ; + */ + +function func1(x: string): string { + return '0'; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_spreadExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_spreadExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..95ec8225e89e6e32344aa33c56fbef4ec11b0f0e --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_spreadExpression.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * + *Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_statement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_statement.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb3fd092562b56fea9dc5c1bdc4c2aa6c7e8c069 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_statement.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.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8 + * statement: + * expressionStatement + * | block + * | localDeclaration + * | ifStatement + * | loopStatement + * | breakStatement + * | continueStatement + * | returnStatement + * | switchStatement + * | throw Statement + * | tryStatement + * ; + */ + +let x = 'string'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_stringInterpolation.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_stringInterpolation.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea0a06ada56d2918242bbf739649cb1da3e1db06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_stringInterpolation.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_switchStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_switchStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..55e52740cbd456a9ae9881ad6f23003ed7209189 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_switchStatement.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_thisExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_thisExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc92a2a31cea5572a095e58f2798ac160a63c28f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_thisExpression.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.8 + * thisExpression: + * 'this' + * ; + */ + +class ThisExample { + public field: string; + constructor() { + this.field = '1'; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_throwStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_throwStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..d80a3ce4cc0e274467a5822891a873a26e478eef --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_throwStatement.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.14 + * throwStatement: + * 'throw' expression + * ; + */ + +throw new Error("error"); diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topDeclaration.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topDeclaration.ets new file mode 100644 index 0000000000000000000000000000000000000000..39077cac66550d8729408f934b422fe764b3b251 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topDeclaration.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.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 13.7 + * topDeclaration: + * ('export' 'default'?)? + * annotationUsage? + * ( typeDeclaration + * | variableDeclarations + * | constantDeclarations + * | functionDeclaration + * | functionWithReceiverDeclaration + * | accessorWithReceiverDeclaration + * | namespaceDeclaration + * ) + * ; + */ + +export let x: string[], y: string; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topLevelStatements.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topLevelStatements.ets new file mode 100644 index 0000000000000000000000000000000000000000..e32b5067c2daa08fac7c65658936f9450e5943fc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_topLevelStatements.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 13.10 + * topLevelStatements: + * statement * + * ; + */ + +let a: string = '56'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_trailingLambdaCall.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_trailingLambdaCall.ets new file mode 100644 index 0000000000000000000000000000000000000000..22594f0c71ef2934f31bf936f6262a4270be78d3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_trailingLambdaCall.ets @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + + * 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/StringLiteral/StringLiteral_tryStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_tryStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6f2ed854a7b5aaf489048de0d3424dbfcfd0ccf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_tryStatement.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.15 + * tryStatement: + * 'try' block catchClauses finallyClause? + * ; + */ + +function processOne(): string { + try { + const res = '1'; + return res; + } catch (error) { + return '-1'; + } +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_tupleType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_tupleType.ets new file mode 100644 index 0000000000000000000000000000000000000000..788f50c097e639e758b3b76b94d997d21cc1b08d --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_tupleType.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 3.18 + * tupleType: + * '[' (type (',' type)* ','?)? ']' + * ; + */ + +let tup: [string, number, boolean, string] = ['s', 1, true, '10']; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeAlias.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeAlias.ets new file mode 100644 index 0000000000000000000000000000000000000000..b03d5d316c39ad02981510d7804f0c63190d0a06 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeAlias.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.6.1 + * typeAlias: + * 'type' identifier typeParameters? '=' type + * ; + */ + +let a: string | number = '100'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeArguments.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeArguments.ets new file mode 100644 index 0000000000000000000000000000000000000000..31ab3405bc433957eda3835eb7274aca514d2374 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeArguments.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 5.2.1 + * typeArguments: + * '<' type(','type)* '>' + * ; + */ + +let a: Array<[number, string, boolean]>; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeOfExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeOfExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba06c6d5fa010eaaa943bd666065bb0554206ae1 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeOfExpression.ets @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * 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/StringLiteral/StringLiteral_typeParameters.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeParameters.ets new file mode 100644 index 0000000000000000000000000000000000000000..81e3837971163f650767c335508e88c0e4e4dbd3 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_typeParameters.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 5.1 + * typeParameters: + * '<' typeParameterList '>' + * ; + */ + +type str = 'debug' | 'info' | 'warn' | 'error'; +class C1 { + public a: string = "StringLiteral"; +} diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unaryExpression.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unaryExpression.ets new file mode 100644 index 0000000000000000000000000000000000000000..f44ff802d6d1b5dceca0e20587f6753239aea3e2 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unaryExpression.ets @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 7.20 + * unaryExpression: + * expression '++' + * | expression '--' + * | '++' expression + * | '--' expression + * | '+' expression + * | '-' expression + * | '~' expression + * | '!' expression + * ; + */ + +'string1' + 'string2'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unionType.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unionType.ets new file mode 100644 index 0000000000000000000000000000000000000000..d6bdaeb5b88f897eb16932f845e5befd9672f3e4 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_unionType.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 3.20 + * unionType: + * type ('|' type)* + * ; + */ + +let u: string | number = '1'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_variableDeclarations.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_variableDeclarations.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a3bfca2c21946f87549f799e82f883138c65c6f --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_variableDeclarations.ets @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 4.7.1 + * variableDeclarations: + * 'let' variableDeclarationList + * ; + */ + +let v: string = '1'; diff --git a/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_whileStatement.ets b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_whileStatement.ets new file mode 100644 index 0000000000000000000000000000000000000000..24edd351d50c81c9e03fba8f376663fdb16b0ecc --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/spec_orthogonality/2_lexical_elements/StringLiteral/StringLiteral_whileStatement.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * CHAPTER 2.9.6 + * StringLiteral: + * '"' DoubleQuoteCharacter* '"' + * | '\'' SingleQuoteCharacter* '\'' + * ; + * + * CHAPTER 8.7 + * whileStatement: + * 'while' '(' expression ')' statement + * ; + */ + +let m = '5'; +let n = '3'; +while(m < n) { + m = n; + break; +}