From 4b9484e23ebfcf40f73f5669f5c0f304f55ee75b Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 10 Sep 2024 14:25:58 +0300 Subject: [PATCH] #2825. Add export directive tests. --- .../Parts-with-imports/export_A01_t01.dart | 34 +++++++++++ .../export_A01_t01_lib.dart | 17 ++++++ .../export_A01_t01_part1.dart | 21 +++++++ .../export_A01_t01_part2.dart | 19 ++++++ .../Parts-with-imports/export_A01_t02.dart | 60 +++++++++++++++++++ .../export_A01_t02_lib.dart | 17 ++++++ .../export_A01_t02_part1.dart | 21 +++++++ .../export_A01_t02_part2.dart | 19 ++++++ .../Parts-with-imports/export_A02_t01.dart | 35 +++++++++++ .../export_A02_t01_lib.dart | 18 ++++++ .../export_A02_t01_part1.dart | 24 ++++++++ .../export_A02_t01_part2.dart | 20 +++++++ .../Parts-with-imports/export_A02_t02.dart | 21 +++++++ .../export_A02_t02_part1.dart | 25 ++++++++ .../export_A02_t02_part2.dart | 23 +++++++ 15 files changed, 374 insertions(+) create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t01.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t01_lib.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t01_part1.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t01_part2.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t02.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t02_lib.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t02_part1.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A01_t02_part2.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t01.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t01_lib.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t01_part1.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t01_part2.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t02.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t02_part1.dart create mode 100644 LanguageFeatures/Parts-with-imports/export_A02_t02_part2.dart diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t01.dart b/LanguageFeatures/Parts-with-imports/export_A01_t01.dart new file mode 100644 index 0000000000..e9739222a1 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t01.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that export directive contained in a part files of a +/// library is added to the library's export scope. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +import 'export_A01_t01_lib.dart'; +import '../../Utils/expect.dart'; + +main() { + // From parts_lib.dart + Expect.equals("libVar", libVar); + Expect.equals("libGetter", libGetter); + libSetter = "x"; + Expect.equals("libFunc", libFunc); + Expect.equals("LibClass", LibClass.id); + Expect.equals("LibMixin", LibMixin.id); + Expect.equals("LibEnum", LibEnum.id); + Expect.equals("LibExt", LibExt.id); + Expect.equals("LibET", LibET.id); + // From scope_lib2.dart + Expect.equals("scope_lib2", libId); + Expect.equals("scope_lib2 lib2Func", lib2Func()); +} diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t01_lib.dart b/LanguageFeatures/Parts-with-imports/export_A01_t01_lib.dart new file mode 100644 index 0000000000..4f0628659b --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t01_lib.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that export directive contained in a part files of a +/// library is added to the library's export scope. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part 'export_A01_t01_part1.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t01_part1.dart b/LanguageFeatures/Parts-with-imports/export_A01_t01_part1.dart new file mode 100644 index 0000000000..75731ed5a2 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t01_part1.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that export directive contained in a part files of a +/// library is added to the library's export scope. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A01_t01_lib.dart'; + +export 'parts_lib.dart'; + +part 'export_A01_t01_part2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t01_part2.dart b/LanguageFeatures/Parts-with-imports/export_A01_t01_part2.dart new file mode 100644 index 0000000000..fe92be5968 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t01_part2.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that export directive contained in a part files of a +/// library is added to the library's export scope. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A01_t01_part1.dart'; + +export 'scope_lib2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t02.dart b/LanguageFeatures/Parts-with-imports/export_A01_t02.dart new file mode 100644 index 0000000000..c005c70f45 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t02.dart @@ -0,0 +1,60 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that it is a compile-time error to access members of an +/// exported library hidden by `show` and `hide`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +import 'export_A01_t02_lib.dart'; + +main() { + // From parts_lib.dart + print(libVar); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(libGetter); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + libSetter = "x"; +//^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(libFunc); +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(LibClass); // Ok + print(LibMixin); +// ^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(LibEnum); +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(LibExt.id); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(LibET); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + // From scope_lib2.dart + print(libId); // Ok + print(lib2Func()); +// ^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t02_lib.dart b/LanguageFeatures/Parts-with-imports/export_A01_t02_lib.dart new file mode 100644 index 0000000000..808b3adfdb --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t02_lib.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that it is a compile-time error to access members of an +/// exported library hidden by `show` and `hide`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part 'export_A01_t02_part1.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t02_part1.dart b/LanguageFeatures/Parts-with-imports/export_A01_t02_part1.dart new file mode 100644 index 0000000000..c76bebf727 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t02_part1.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that it is a compile-time error to access members of an +/// exported library hidden by `show` and `hide`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A01_t02_lib.dart'; + +export 'parts_lib.dart' show LibClass; + +part 'export_A01_t02_part2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A01_t02_part2.dart b/LanguageFeatures/Parts-with-imports/export_A01_t02_part2.dart new file mode 100644 index 0000000000..b3e618ed83 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A01_t02_part2.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. +/// +/// @description Check that it is a compile-time error to access members of an +/// exported library hidden by `show` and `hide`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A01_t02_part1.dart'; + +export 'scope_lib2.dart' hide lib2Func; diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t01.dart b/LanguageFeatures/Parts-with-imports/export_A02_t01.dart new file mode 100644 index 0000000000..6d2aa1c8b3 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t01.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it's not an error to export the same declaration +/// more than once. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +import 'export_A02_t01_lib.dart'; +import '../../Utils/expect.dart'; + +main() { + // From parts_lib.dart + Expect.equals("libVar", libVar); + Expect.equals("libGetter", libGetter); + libSetter = "x"; + Expect.equals("libFunc", libFunc); + Expect.equals("LibClass", LibClass.id); + Expect.equals("LibMixin", LibMixin.id); + Expect.equals("LibEnum", LibEnum.id); + Expect.equals("LibExt", LibExt.id); + Expect.equals("LibET", LibET.id); + // From scope_lib2.dart + Expect.equals("scope_lib2", libId); + Expect.equals("scope_lib2 lib2Func", lib2Func()); +} diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t01_lib.dart b/LanguageFeatures/Parts-with-imports/export_A02_t01_lib.dart new file mode 100644 index 0000000000..b5e3d06ae7 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t01_lib.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it's not an error to export the same declaration +/// more than once. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part 'export_A02_t01_part1.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t01_part1.dart b/LanguageFeatures/Parts-with-imports/export_A02_t01_part1.dart new file mode 100644 index 0000000000..6c2d9a3322 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t01_part1.dart @@ -0,0 +1,24 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it's not an error to export the same declaration +/// more than once. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A02_t01_lib.dart'; + +export 'parts_lib.dart'; +export 'parts_lib.dart'; +export 'scope_lib2.dart'; + +part 'export_A02_t01_part2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t01_part2.dart b/LanguageFeatures/Parts-with-imports/export_A02_t01_part2.dart new file mode 100644 index 0000000000..e41de4e0d1 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t01_part2.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it's not an error to export the same declaration +/// more than once. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A02_t01_part1.dart'; + +export 'scope_lib2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t02.dart b/LanguageFeatures/Parts-with-imports/export_A02_t02.dart new file mode 100644 index 0000000000..e09f4a925c --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t02.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it is a compile-time error if exported libraries +/// have a name conflict. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part 'export_A02_t02_part1.dart'; + +main() { +} diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t02_part1.dart b/LanguageFeatures/Parts-with-imports/export_A02_t02_part1.dart new file mode 100644 index 0000000000..51ba3987a9 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t02_part1.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it is a compile-time error if exported libraries +/// have a name conflict. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A02_t02.dart'; + +export 'parts_lib.dart'; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +part 'export_A02_t02_part2.dart'; diff --git a/LanguageFeatures/Parts-with-imports/export_A02_t02_part2.dart b/LanguageFeatures/Parts-with-imports/export_A02_t02_part2.dart new file mode 100644 index 0000000000..0140e57e71 --- /dev/null +++ b/LanguageFeatures/Parts-with-imports/export_A02_t02_part2.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion Any Dart file can contain an `export` directive. It makes no +/// difference which file an `export` is in, its declarations (filtered by any +/// `hide` or `show` modifiers) are added to the library’s single export scope, +/// along with those of any other `exports` in the library and the non-private +/// declarations of the library itself. Conflicts are handled as usual (as an +/// error if it’s not the same declaration). +/// +/// @description Check that it is a compile-time error if exported libraries +/// have a name conflict. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=enhanced-parts + +part of 'export_A02_t02_part1.dart'; + +export 'scope_lib1.dart'; +// ^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified