diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a.ets index 907966dfc65255244e17ae5857208cf52c850f7c..eb82a5e5d55593da98d416b80a4a5d99503a2bcf 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a.ets @@ -17,5 +17,10 @@ limitations under the License. tags: [not-a-test, compile-only] ---*/ -class ClassA {} +class ClassA { + f: int + constructor(f: int) { + this.f = f + } +} export type {ClassA} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b.ets index 9aff77765e2634765da642fa197848dacfbc0a0a..b671a67357009d6875bc93564b1cefcfad4728c3 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b.ets @@ -17,5 +17,10 @@ limitations under the License. tags: [not-a-test, compile-only] ---*/ -class ClassA {} +class ClassA { + f: int + constructor(f: int) { + this.f = f + } +} export type ClassB = ClassA diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b_twice.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b_twice.ets index b386e5881f7fc9b258292eceea34af4f5aad41d6..b161de33e1c436895f457c956c827d7f8c167d8b 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b_twice.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/class_a_as_b_twice.ets @@ -17,6 +17,11 @@ limitations under the License. tags: [not-a-test, compile-only] ---*/ -class ClassA {} +class ClassA { + f: int + constructor(f: int) { + this.f = f + } +} export type ClassB = ClassA export type {ClassB} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_already_declared.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_already_declared.ets index 75e5174ac2cab11121d4fc19f9d3f40885f8f525..8127b6c037e674bdf0170caebe062eb2fb456c34 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_already_declared.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_already_declared.ets @@ -15,11 +15,13 @@ limitations under the License. /*--- desc: Export type directive -tags: [compile-only] +files: +- ./class_a.ets ---*/ import { ClassA } from './class_a' -function main(): int { - return 0 +function main() { + let a: ClassA = new ClassA(2) + arktest.assertEQ(a.f, 2) } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_as_already_declared.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_as_already_declared.ets index 79e0250c75a71e86170598748219bfd96b654e73..5e350301495a3fd40cfd81c787f3db9e50f2ce09 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_as_already_declared.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_as_already_declared.ets @@ -15,11 +15,13 @@ limitations under the License. /*--- desc: Export type directive -tags: [compile-only] +files: +- ./class_a_as_b.ets ---*/ import { ClassB } from './class_a_as_b' -function main(): int { - return 0 +function main() { + let i: ClassB = new ClassB(3) + arktest.assertEQ(i.f, 3) } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_multiple_types.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_multiple_types.ets new file mode 100644 index 0000000000000000000000000000000000000000..93fa721ad657e024ddd2b5428cf1946a2f922ddf --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_multiple_types.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. +---*/ + +/*--- +desc: Export multiple types with binding +tags: [compile-only, not-a-test] +---*/ + +class B { + f: int = 7 +} + +class C { + f: int = 8 +} + +class D { + f: int = 9 +} + +export type {C as D, B, D as E} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type.ets new file mode 100644 index 0000000000000000000000000000000000000000..fee9bd15d7e8f264376e47e843ca1e566f4daab9 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type.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. +---*/ + +/*--- +desc: Export type with binding +tags: [compile-only, not-a-test] +---*/ + +class C { + f: int = 8 +} + +class D { + f: int = 9 +} + +export type {C as D} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type.ets index 9808bced6c4d1a8c8517f5ac6a9fe6d4f70cd38d..dbbdd979e8cb5d3f913c82850617538ade6c66f4 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type.ets @@ -14,11 +14,14 @@ limitations under the License. ---*/ /*--- -desc: Export type directive, type is applied to classes and interfaces +desc: Export const variable type directive +files: +- ./const_as_type.ets ---*/ import { FOO } from './const_as_type' -function main(): int { - return 0 +function main() { + let i = FOO + arktest.assertEQ(i, 42) } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type_neg.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type_neg.ets new file mode 100644 index 0000000000000000000000000000000000000000..54ed4d2f8d4e9ce6a437c4af3cad25a9667c4c21 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/export_type_of_as_type_neg.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. +---*/ + +/*--- +desc: Edit value of the exported const variable type +files: +- ./const_as_type.ets +tags: [compile-only, negative] +---*/ + +import { FOO } from './const_as_type' + +function main() { + let i = FOO + i = 43 +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_by_old_name.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_by_old_name.ets index f105b7443632f61b94332ee499c2786a3fc92b8b..41a1d02e8396a8b43e14509e16ed5ee8f5ea13e1 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_by_old_name.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_by_old_name.ets @@ -16,10 +16,8 @@ limitations under the License. /*--- desc: Export type directive, ClassA is exported as ClassB, therefore is not available tags: [compile-only, negative] +files: +- ./class_a_as_b.ets ---*/ import { ClassA } from './class_a_as_b' - -function main(): int { - return 0 -} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_twice.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_twice.ets index fff2a942be169478ec7390369673d23404acd4b7..7ad031694b8c35a64018fe31cfd41f06c6c9e5e7 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_twice.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/negative_export_as_twice.ets @@ -16,10 +16,8 @@ limitations under the License. /*--- desc: Export type directive, ClassA is exported as ClassB twice, therefore must fail tags: [compile-only, negative] +files: +- ./class_a_as_b_twice.ets ---*/ import { ClassA } from './class_a_as_b_twice' - -function main(): int { - return 0 -} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding.ets new file mode 100644 index 0000000000000000000000000000000000000000..accbf3217034bbbc3e96e5d599cfca81c39f36fe --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding.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. +---*/ + +/*--- +desc: >- + An export directive can have a type modifier exclusively for a better syntactic compatibility with TypeScript + (also see Import Type Directive). +files: +- ./export_type.ets +---*/ + +import type {D} from "./export_type" + +function main() { + let a: D = new D() + arktest.assertEQ(a.f, 8) +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_multiple.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_multiple.ets new file mode 100644 index 0000000000000000000000000000000000000000..039c559d5545a949933221875a3a67ce8939dcb5 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_multiple.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. +---*/ + +/*--- +desc: >- + An export directive can have a type modifier exclusively for a better syntactic compatibility with TypeScript + (also see Import Type Directive). +files: +- ./export_multiple_types.ets +---*/ + +import type {E, D as exC, B} from "./export_multiple_types" + +function main() { + let i: E = new E() + arktest.assertEQ(i.f, 9) + let j: exC = new exC() + arktest.assertEQ(j.f, 8) + let k: B = new B() + arktest.assertEQ(k.f, 7) +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg.ets new file mode 100644 index 0000000000000000000000000000000000000000..344ab63be8be8f523fc8164b7b31853afd2b8fd5 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg.ets @@ -0,0 +1,23 @@ +/*--- +Copyright (c) 2025 Huawei Device Co., Ltd. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +---*/ + +/*--- +desc: If a binding uses type, then a compile-time error occurs. +tags: [compile-only, negative] +---*/ + +class C {} + +export {type C} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg_2.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee05887cc25f834e21d6f354137c650a231ab282 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg_2.ets @@ -0,0 +1,24 @@ +/*--- +Copyright (c) 2025 Huawei Device Co., Ltd. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +---*/ + +/*--- +desc: If a binding uses type, then a compile-time error occurs. +tags: [compile-only, negative] +---*/ + +class C {} +class D {} + +export {C, type D} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01b/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/default_module.ets similarity index 85% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01b/a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/default_module.ets index e060847b5bdbb6b32dd328b29eb238a55ce641bd..6c661cbd7eeb8a1e9d03b396fcd64b23fbb22b3d 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01b/a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/default_module.ets @@ -14,9 +14,10 @@ */ /*--- +desc: module contains default exported entity tags: [not-a-test, compile-only] ---*/ -package pkg01b; - -export { ClassA, InterfaceA, foo, BAR } from '../pkg01a' // re-export from package module +export default class A { + f: int = 3 +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_a.ets similarity index 95% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_a.ets index b687e262cf403a0a9918853faf5c0319d6d33b43..9f847a7a90a34453d6e39d8f5d23d2843a1c7e45 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_a.ets @@ -17,7 +17,9 @@ tags: [not-a-test, compile-only] ---*/ -export class ClassA {} +export class ClassA { + f: int = 1 +} export interface InterfaceA {} export function foo(): void {} export const BAR: int = 146 diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_all.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all.ets similarity index 100% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_all.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all.ets diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_all_renamed.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all_renamed.ets similarity index 100% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_all_renamed.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all_renamed.ets diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b.ets similarity index 98% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b.ets index dc9690febd253c6a8a6fdfa2385216b9efb38c35..a4ca7c801da3f258f2baa978b532fd05d5b5d73d 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b.ets @@ -55,4 +55,4 @@ export numExported; export @interface MyAnno {} type fooCls = foo; -export fooCls; \ No newline at end of file +export fooCls; diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b_re-export.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b_re-export.ets similarity index 94% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b_re-export.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b_re-export.ets index c17c06acda5be064e519bbaced15c15f01047397..c07bc6c68ab375138e73585da0a4b23631ea3490 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/module_b_re-export.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b_re-export.ets @@ -17,4 +17,4 @@ tags: [not-a-test, compile-only] ---*/ -export * as name from "./module_b"; \ No newline at end of file +export * as name from "./module_b"; diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03b/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default.ets similarity index 89% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03b/a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default.ets index 817160d22628f94bb1316b42537aa6d5d3d95edc..35f1d1f1764c53f43c8d64af040b6453474cc0e2 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03b/a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default.ets @@ -15,8 +15,8 @@ /*--- tags: [not-a-test, compile-only] +files: +- ./default_module.ets ---*/ -package pkg03b; - -export * from '../pkg03a' // re-export from package module +export {default} from "./default_module" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01a/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default_rename.ets similarity index 83% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01a/a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default_rename.ets index c3ffeb97c3a5aa1088e53229f18bed525a21ab1a..c9924e44adfb284d2ecc1f1f722352171bbd012f 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01a/a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default_rename.ets @@ -15,11 +15,8 @@ /*--- tags: [not-a-test, compile-only] +files: +- ./default_module.ets ---*/ -package pkg01a; - -export class ClassA {} -export interface InterfaceA {} -export function foo(): void {} -export const BAR: int = 146 +export {default as B} from "./default_module" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02a/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_non-default.ets similarity index 83% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02a/a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_non-default.ets index dfa7c23e23101ef2c82d2b190f967e37e09a16ae..4248d137c23070cd0282252f7338beb7e27b0ae4 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02a/a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_non-default.ets @@ -15,11 +15,8 @@ /*--- tags: [not-a-test, compile-only] +files: +- ./module_a.ets ---*/ -package pkg02a; - -export class ClassA {} -export interface InterfaceA {} -export function foo(): void {} -export const BAR: int = 146 +export {ClassA as default} from "./module_a" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03a/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03a/a.ets deleted file mode 100644 index ce793ddad1563bd5f8c6a5d2fa1d44a836820b87..0000000000000000000000000000000000000000 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03a/a.ets +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2025 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -tags: [not-a-test, compile-only] ----*/ - -package pkg03a; - -export class ClassA {} -export interface InterfaceA {} -export function foo(): void {} -export const BAR: int = 146 diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all.ets index 63222519dbf75989df757d3cb95f78b99b8860d8..c0031cb582d27de5e7d156c4e009f32969d88e5e 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all.ets @@ -15,10 +15,10 @@ /*--- desc: Re-export directive, all names should be available -files: ['./module_a.ets', './module_all.ets'] +files: ['./modules/module_a.ets', './modules/module_all.ets'] ---*/ -import { ClassA, InterfaceA, foo, BAR } from './module_all' +import { ClassA, InterfaceA, foo, BAR } from './modules/module_all' function main() { arktest.assertEQ(BAR, 146) diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_by_old_names.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_by_old_names.ets index 2d63d7e6d7f1b1418b329ba15c26eaf6f49580fc..afb3ab4dee4b9c7cc4bb741032124f3cd595585d 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_by_old_names.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_by_old_names.ets @@ -15,10 +15,10 @@ /*--- desc: Re-export directive, old names should be available -files: ['./module_a.ets'] +files: ['./modules/module_a.ets'] ---*/ -import { ClassA, InterfaceA, foo, BAR } from './module_a' +import { ClassA, InterfaceA, foo, BAR } from './modules/module_a' function main() { arktest.assertEQ(BAR, 146) diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_namespace.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_namespace.ets index c7737fd8d8e20ee501262d782f33ed743797e5db..d6f8edd92316c22eff07d2138888ecb9594d2943 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_namespace.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_namespace.ets @@ -15,10 +15,10 @@ /*--- desc: Re-export directive -files: ['./module_b_re-export.ets', './module_b.ets'] +files: ['./modules/module_b_re-export.ets', './modules/module_b.ets'] ---*/ -import { name } from "./module_b_re-export" +import { name } from "./modules/module_b_re-export" function main() : void { @@ -52,4 +52,4 @@ function main() : void // Export type alias let foo_cls1 : name.fooCls = new name.foo(); arktest.assertEQ(foo_cls1.foo_bar(), 101); -} \ No newline at end of file +} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_with_rename.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_with_rename.ets index cf2199444477f9dec212f7043aab109af817b467..87dc3f22b4bf848795ab4d6c8e969407a66409aa 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_with_rename.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_all_with_rename.ets @@ -15,10 +15,10 @@ /*--- desc: Re-export directive, new names should be available -files: ['./module_all_renamed.ets', './module_a.ets'] +files: ['./modules/module_all_renamed.ets', './modules/module_a.ets'] ---*/ -import { NewClassA, NewInterfaceA, newFoo, NEW_BAR } from './module_all_renamed' +import { NewClassA, NewInterfaceA, newFoo, NEW_BAR } from './modules/module_all_renamed' function main() { arktest.assertEQ(NEW_BAR, 146) diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02b/a.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_multiple_default.ets similarity index 75% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02b/a.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_multiple_default.ets index 2b712b05e2d5ce44eba91f3e8c0b193f79c320fe..80da2492bc8d3454d151a9ae761c12334833d989 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02b/a.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/re-export_multiple_default.ets @@ -14,9 +14,11 @@ */ /*--- -tags: [not-a-test, compile-only] +desc: Only single item per file could be exported as default +tags: [compile-only, negative] +files: +- ./modules/default_module.ets ---*/ -package pkg02b; - -export { ClassA as NewClassA, InterfaceA as NewInterfaceA, foo as newFoo, BAR as NEW_BAR } from '../pkg02a' // re-export from package module +export {default} from "./modules/default_module" +export default class B {} diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self.ets new file mode 100644 index 0000000000000000000000000000000000000000..732dab3663cf1a965c4916181360d28ed6715257 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +desc: An importPath cannot refer to the file the current module is stored in. Otherwise, a compile-time error occurs. +tags: [negative, compile-only] +---*/ + +export class A {} + +export A from "./modules/reexport_from_self" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self_2.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..86fc421260ac12291305665444244914870c3993 --- /dev/null +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self_2.ets @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +desc: An importPath cannot refer to the file the current module is stored in. Otherwise, a compile-time error occurs. +tags: [negative, compile-only] +---*/ + +export class A {} + +export {A as B} from "./modules/reexport_from_self" diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03_re-export_all.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default.ets similarity index 74% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03_re-export_all.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default.ets index 4af9334f01d133f3dd986b1eba901750a0aeec8d..cf220e17069a2e34bb9c484337ed22c235c51fea 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg03_re-export_all.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default.ets @@ -14,12 +14,15 @@ */ /*--- -desc: Re-export directive, all names should be available -files: ['./pkg03a/a.ets', './pkg03b/a.ets'] +desc: re-export default declaration from the other module +files: +- ./modules/re-export_default.ets +- ./modules/default_module.ets ---*/ -import { ClassA, InterfaceA, foo, BAR } from './pkg03b' +import {A} from "./modules/re-export_default" function main() { - arktest.assertEQ(BAR, 146) + let i = new A() + arktest.assertEQ(i.f, 3) } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02_re-export_all_with_rename.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_2.ets similarity index 72% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02_re-export_all_with_rename.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_2.ets index 292098eeed082ad19dc163c9f459dc1eeb163feb..99cffe358a022630b772d9511f346e0428d486c3 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg02_re-export_all_with_rename.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_2.ets @@ -14,12 +14,15 @@ */ /*--- -desc: Re-export directive, new names should be available -files: ['./pkg02a/a.ets', './pkg02b/a.ets'] +desc: re-export default declaration from the other module under 'name' +files: +- ./modules/re-export_default_rename.ets +- ./modules/default_module.ets ---*/ -import { NewClassA, NewInterfaceA, newFoo, NEW_BAR } from './pkg02b' +import {C} from "./modules/re-export_default_rename" function main() { - arktest.assertEQ(NEW_BAR, 146) + let i = new C() + arktest.assertEQ(i.f, 3) } diff --git a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01_re-export_all_by_old_names.ets b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_3.ets similarity index 77% rename from static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01_re-export_all_by_old_names.ets rename to static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_3.ets index a2623bb24e4dccc462489827bb38f62434abce5d..964ba83f93361cf356d6d01e1e7c7efa9201b3d7 100644 --- a/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/pkg01_re-export_all_by_old_names.ets +++ b/static_core/plugins/ets/tests/ets-templates/13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_3.ets @@ -14,12 +14,15 @@ */ /*--- -desc: Re-export directive, old names should be available -files: ['./pkg01a/a.ets', './pkg01b/a.ets'] +desc: TBD +files: +- ./modules/re-export_non-default.ets +- ./modules/module_a.ets ---*/ -import { ClassA, InterfaceA, foo, BAR } from './pkg01b' +import {ClassA} from "./modules/re-export_non-default" function main() { - arktest.assertEQ(BAR, 146) + let i = new ClassA() + arktest.assertEQ(i.f, 3) } diff --git a/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt index 4349e54ce974b64577a83a90d483f965da653b39..21a97206d5c9f4bd1a2e384424b8f9a829b64c73 100644 --- a/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/declgenets2ts/ets-cts/declgen-ets2ts-cts-ignored.txt @@ -1360,17 +1360,24 @@ 13.compilation_units/07.export_directives/02.single_export_directive/export_source/re_export_4.ets 13.compilation_units/07.export_directives/02.single_export_directive/export_source/re_export_5.ets 13.compilation_units/07.export_directives/02.single_export_directive/export_source/re_export_6.ets +13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg.ets +13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg_2.ets #29393 13.compilation_units/07.export_directives/02.single_export_directive/re_export_test_3.ets 13.compilation_units/07.export_directives/02.single_export_directive/re_export_test_4.ets 13.compilation_units/07.export_directives/02.single_export_directive/re_export_test_5.ets #end of 29393 -13.compilation_units/07.export_directives/04.re-export_directive/module_all.ets -13.compilation_units/07.export_directives/04.re-export_directive/module_all_renamed.ets -13.compilation_units/07.export_directives/04.re-export_directive/module_b_re-export.ets -13.compilation_units/07.export_directives/04.re-export_directive/pkg01b/a.ets -13.compilation_units/07.export_directives/04.re-export_directive/pkg02b/a.ets -13.compilation_units/07.export_directives/04.re-export_directive/pkg03b/a.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/default_module.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/module_a.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/module_all_renamed.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/module_b_re-export.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_default_rename.ets +13.compilation_units/07.export_directives/04.re-export_directive/modules/re-export_non-default.ets +13.compilation_units/07.export_directives/04.re-export_directive/re-export_multiple_default.ets +13.compilation_units/07.export_directives/04.re-export_directive/reexport_from_self_2.ets 14.ambient_declarations/02.function_declarations/function_declarations_n_0.ets 14.ambient_declarations/02.function_declarations/function_declarations_n_1.ets 14.ambient_declarations/02.function_declarations/function_declarations_n_2.ets diff --git a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt index a94893f7dabfe1008c8788b45d0633e9a10ec63c..2db561a4a5136a3ddeb8009aefaa4e72c1ffb4a4 100644 --- a/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt +++ b/static_core/plugins/ets/tests/test-lists/ets-cts/ets-cts-ignored.txt @@ -1559,11 +1559,20 @@ 13.compilation_units/07.export_directives/02.single_export_directive/re_export_test_4.ets 13.compilation_units/07.export_directives/02.single_export_directive/re_export_test_5.ets +#29735 +13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg.ets +13.compilation_units/07.export_directives/03.export_type_directive/type_binding_neg_2.ets + #28243 13.compilation_units/07.export_directives/04.re-export_directive/pkg01_re-export_all_by_old_names.ets 13.compilation_units/07.export_directives/04.re-export_directive/pkg02_re-export_all_with_rename.ets 13.compilation_units/07.export_directives/04.re-export_directive/pkg03_re-export_all.ets +#29725 +13.compilation_units/07.export_directives/04.re-export_directive/reexported_default.ets +13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_2.ets +13.compilation_units/07.export_directives/04.re-export_directive/reexported_default_3.ets + #28847 14.ambient_declarations/bad_ambient_declarations_18.ets 14.ambient_declarations/bad_ambient_declarations_19.ets