Skip to content

Commit

Permalink
dart-lang#2825. Add export directive tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Sep 10, 2024
1 parent a572236 commit 4b9484e
Show file tree
Hide file tree
Showing 15 changed files with 374 additions and 0 deletions.
34 changes: 34 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t01.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// 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());
}
17 changes: 17 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t01_lib.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'export_A01_t01_part1.dart';
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t01_part1.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A01_t01_lib.dart';

export 'parts_lib.dart';

part 'export_A01_t01_part2.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t01_part2.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A01_t01_part1.dart';

export 'scope_lib2.dart';
60 changes: 60 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t02.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// 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
}
17 changes: 17 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t02_lib.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'export_A01_t02_part1.dart';
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t02_part1.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A01_t02_lib.dart';

export 'parts_lib.dart' show LibClass;

part 'export_A01_t02_part2.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A01_t02_part2.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A01_t02_part1.dart';

export 'scope_lib2.dart' hide lib2Func;
35 changes: 35 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t01.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// 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());
}
18 changes: 18 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t01_lib.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'export_A02_t01_part1.dart';
24 changes: 24 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t01_part1.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// 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';
20 changes: 20 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t01_part2.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A02_t01_part1.dart';

export 'scope_lib2.dart';
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t02.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'export_A02_t02_part1.dart';

main() {
}
25 changes: 25 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t02_part1.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// 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';
23 changes: 23 additions & 0 deletions LanguageFeatures/Parts-with-imports/export_A02_t02_part2.dart
Original file line number Diff line number Diff line change
@@ -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 [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'export_A02_t02_part1.dart';

export 'scope_lib1.dart';
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

0 comments on commit 4b9484e

Please sign in to comment.