diff --git a/ets2panda/test/runtime/ets/implicit_stringEnum_as_string.ets b/ets2panda/test/runtime/ets/implicit_stringEnum_as_string.ets new file mode 100644 index 0000000000000000000000000000000000000000..87b5880fb62df4b08aafd156a6326f9eb0be0c1e --- /dev/null +++ b/ets2panda/test/runtime/ets/implicit_stringEnum_as_string.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +enum StringEnum { + X = "X", + Y = "Y", + Z = "Z" +} + +interface TestInterface { + prop: string; +} + +class TestClass { + public name: string = StringEnum.X; +} + +function processString(str: string): string { + return str; +} + +function concatStrings(a: string, b: string): string { + return a + b; +} + +function main() { + let directAssignment: string = StringEnum.Y; + arktest.assertEQ(directAssignment, "Y"); + + let obj: TestInterface = { prop: StringEnum.Z }; + arktest.assertEQ(obj.prop, "Z"); + + let instance: TestClass = new TestClass(); + arktest.assertEQ(instance.name, "X"); + + arktest.assertEQ(processString(StringEnum.Y), "Y"); + + let result: string = concatStrings("Prefix", StringEnum.X); + arktest.assertEQ(result, "PrefixX"); + + let stringArray: string[] = [StringEnum.X, StringEnum.Y, StringEnum.Z]; + arktest.assertEQ(stringArray[0], "X"); + arktest.assertEQ(stringArray[1], "Y"); + arktest.assertEQ(stringArray[2], "Z"); +}