Skip to content

Commit

Permalink
dart-lang#2825. Add scope tests. Part 1. (dart-lang#2845)
Browse files Browse the repository at this point in the history
Add scope tests. Part 1. Note that import clauses in a part file are currently a syntax error, but will be supported.
  • Loading branch information
sgrekhov committed Sep 9, 2024
1 parent 9adc17e commit cae4360
Show file tree
Hide file tree
Showing 24 changed files with 819 additions and 0 deletions.
17 changes: 17 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A01_t01.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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not existing file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'scope_A01_t01_part1.dart';

main() {
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not existing file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A01_t01.dart';

import 'not_existing.dart';
// ^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

part 'scope_A01_t01_part2.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not existing file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A01_t01_part1.dart';

import 'not_existing.dart';
// ^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
17 changes: 17 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A01_t02.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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not Dart library file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'scope_A01_t02_part1.dart';

main() {
}
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not Dart library file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A01_t02.dart';

import 'scope_lib1_part.dart';
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

part 'scope_A01_t02_part2.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_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 As usual, it’s a compile-time error if any import‘s target URI
/// does not resolve to a valid Dart library file.
///
/// @description Check that it is a compile-time error if an import‘s target
/// URI from a `part` file resolves to a not Dart library file.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A01_t02_part1.dart';

import 'scope_lib1_part.dart';
// ^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
24 changes: 24 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t01.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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that if unprefixed imports of a part file contain
/// conflicting names it is not an error if those names are not referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'scope_A02_t01_part1.dart';

main() {
testPart1();
testPart2();
}
29 changes: 29 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t01_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that if unprefixed imports of a part file contain
/// conflicting names it is not an error if those names are not referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A02_t01.dart';

import 'scope_lib1.dart';
import 'parts_lib.dart';

part 'scope_A02_t01_part2.dart';

testPart1() {
print(scope); // From scope_lib1.dart
print(counter); // From parts_lib.dart
}
27 changes: 27 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t01_part2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that if unprefixed imports of a part file contain
/// conflicting names it is not an error if those names are not referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A02_t01_part1.dart';

import 'scope_lib1.dart';
import 'parts_lib.dart';

testPart2() {
print(scope); // From scope_lib1.dart
print(counter); // From parts_lib.dart
}
24 changes: 24 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t02.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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that it is a compile-time error if unprefixed imports of
/// a part file contain conflicting names and those names are referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'scope_A02_t01_part1.dart';

main() {
testPart1();
testPart2();
}
63 changes: 63 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t02_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that it is a compile-time error if unprefixed imports of
/// a part file contain conflicting names and those names are referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A02_t02.dart';

import 'scope_lib1.dart';
import 'parts_lib.dart';

part 'scope_A02_t02_part2.dart';

testPart1() {
print(libVar);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(libGetter);
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
libSetter = "";
//^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(libFunc);
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(LibClass);
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
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
}
61 changes: 61 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t02_part2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// 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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that it is a compile-time error if unprefixed imports of
/// a part file contain conflicting names and those names are referenced.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'scope_A02_t02_part1.dart';

import 'scope_lib1.dart';
import 'parts_lib.dart';

testPart2() {
print(libVar);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(libGetter);
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
libSetter = "";
//^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(libFunc);
// ^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
print(LibClass);
// ^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
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
}
25 changes: 25 additions & 0 deletions LanguageFeatures/Parts-with-imports/scope_A02_t03.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 Let’s introduce importsOf(S), where S is a set of `import`
/// directives from a single Dart file, to refer to that computation, which
/// introduces a scope containing the declarations introduced by all the
/// `import`s (the declarations of the export scope of each imported library,
/// minus those hidden by a `show` or `hide` operator, combined such that a name
/// conflicts of different declarations is not an error, but the name is marked
/// as conflicted in the scope, and then referencing it is an error.)
///
/// @description Check that unprefixed import scope contains all top-level
/// declarations introduced by all the `import` directives.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

import '../../Utils/expect.dart';
part 'scope_A02_t03_part1.dart';

main() {
testPart1();
testPart2();
}
Loading

0 comments on commit cae4360

Please sign in to comment.