forked from dart-lang/co19
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dart-lang#2825. Add scope tests. Part 2. (dart-lang#2847)
Add scope tests. Part 2
- Loading branch information
Showing
21 changed files
with
689 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. Test `import` | ||
/// directives with `export`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import '../../Utils/expect.dart'; | ||
part 'scope_A02_t06_part1.dart'; | ||
|
||
main() { | ||
testPart1(); | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Parts-with-imports/scope_A02_t06_part1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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. Test `import` | ||
/// directives with `export`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A02_t06.dart'; | ||
|
||
import 'scope_lib3.dart'; | ||
|
||
testPart1() { | ||
// From scope_lib2.dart | ||
Expect.equals("scope_lib2", libId); | ||
Expect.equals("scope_lib2 lib2Func", lib2Func()); | ||
// From scope_lib3.dart | ||
Expect.equals("scope_lib3 lib3Func", lib3Func()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 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 to access exported | ||
/// members hidden by `hide` and `show`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'scope_A02_t07_part1.dart'; | ||
|
||
main() { | ||
testPart1(); | ||
} |
68 changes: 68 additions & 0 deletions
68
LanguageFeatures/Parts-with-imports/scope_A02_t07_part1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// 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 to access exported | ||
/// members hidden by `hide` and `show`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A02_t07.dart'; | ||
|
||
import 'scope_lib4.dart'; | ||
|
||
testPart1() { | ||
// From scope_lib1.dart | ||
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); // 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 | ||
|
||
// From scope_lib4.dart | ||
print(lib4Func()); // Ok | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that a prefix scope contains an entry for each name where | ||
/// the current file has an `import` directive with that name as prefix, | ||
/// `as name`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import '../../Utils/expect.dart'; | ||
part 'scope_A03_t01_part1.dart'; | ||
|
||
main() { | ||
testPart1(); | ||
testPart2(); | ||
} |
43 changes: 43 additions & 0 deletions
43
LanguageFeatures/Parts-with-imports/scope_A03_t01_part1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// 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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that a prefix scope contains an entry for each name where | ||
/// the current file has an `import` directive with that name as prefix, | ||
/// `as name`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A03_t01.dart'; | ||
|
||
import 'scope_lib1.dart' as l1; | ||
import 'scope_lib2.dart' as l2; | ||
|
||
part 'scope_A03_t01_part2.dart'; | ||
|
||
testPart1() { | ||
// From scope_lib1.dart | ||
Expect.equals("scope_lib1 libVar", l1.libVar); | ||
Expect.equals("scope_lib1 libGetter", l1.libGetter); | ||
l1.libSetter = "x"; | ||
Expect.equals("scope_lib1 libFunc", l1.libFunc); | ||
Expect.equals("scope_lib1 LibClass", l1.LibClass.id); | ||
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id); | ||
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id); | ||
Expect.equals("scope_lib1 LibExt", l1.LibExt.id); | ||
Expect.equals("scope_lib1 LibET", l1.LibET.id); | ||
|
||
// From scope_lib2.dart | ||
Expect.equals("scope_lib2", l2.libId); | ||
Expect.equals("scope_lib2 lib2Func", l2.lib2Func()); | ||
} |
55 changes: 55 additions & 0 deletions
55
LanguageFeatures/Parts-with-imports/scope_A03_t01_part2.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// 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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that a prefix scope contains an entry for each name where | ||
/// the current file has an `import` directive with that name as prefix, | ||
/// `as name`. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A03_t01_part1.dart'; | ||
|
||
import 'scope_lib1.dart' as l3; | ||
import 'scope_lib2.dart' as l4; | ||
|
||
part 'scope_A03_t01_part2.dart'; | ||
|
||
testPart2() { | ||
// From scope_lib1.dart | ||
Expect.equals("scope_lib1 libVar", l1.libVar); | ||
Expect.equals("scope_lib1 libGetter", l1.libGetter); | ||
l1.libSetter = "x"; | ||
Expect.equals("scope_lib1 libFunc", l1.libFunc); | ||
Expect.equals("scope_lib1 LibClass", l1.LibClass.id); | ||
Expect.equals("scope_lib1 LibMixin", l1.LibMixin.id); | ||
Expect.equals("scope_lib1 LibEnum", l1.LibEnum.id); | ||
Expect.equals("scope_lib1 LibExt", l1.LibExt.id); | ||
Expect.equals("scope_lib1 LibET", l1.LibET.id); | ||
|
||
Expect.equals("scope_lib1 libVar", l3.libVar); | ||
Expect.equals("scope_lib1 libGetter", l3.libGetter); | ||
l3.libSetter = "x"; | ||
Expect.equals("scope_lib1 libFunc", l3.libFunc); | ||
Expect.equals("scope_lib1 LibClass", l3.LibClass.id); | ||
Expect.equals("scope_lib1 LibMixin", l3.LibMixin.id); | ||
Expect.equals("scope_lib1 LibEnum", l3.LibEnum.id); | ||
Expect.equals("scope_lib1 LibExt", l3.LibExt.id); | ||
Expect.equals("scope_lib1 LibET", l3.LibET.id); | ||
|
||
// From scope_lib2.dart | ||
Expect.equals("scope_lib2", l2.libId); | ||
Expect.equals("scope_lib2 lib2Func", l2.lib2Func()); | ||
Expect.equals("scope_lib2", l4.libId); | ||
Expect.equals("scope_lib2 lib2Func", l4.lib2Func()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that it’s a compile-time error if two deferred `import` | ||
/// directives in the same part file have the same prefix name. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'scope_A03_t02_part1.dart'; | ||
|
||
main() { | ||
testPart1(); | ||
testPart2(); | ||
} |
32 changes: 32 additions & 0 deletions
32
LanguageFeatures/Parts-with-imports/scope_A03_t02_part1.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that it’s a compile-time error if two deferred `import` | ||
/// directives in the same part file have the same prefix name. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A03_t02.dart'; | ||
|
||
import 'scope_lib1.dart' deferred as d; | ||
import 'scope_lib2.dart' deferred as d; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
part 'scope_A03_t02_part2.dart' | ||
|
||
testPart1() { | ||
print("Part 1"); | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Parts-with-imports/scope_A03_t02_part2.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// 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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that it’s a compile-time error if two deferred `import` | ||
/// directives in the same part file have the same prefix name. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'scope_A03_t02_part1.dart'; | ||
|
||
import 'scope_lib1.dart' deferred as d; | ||
import 'scope_lib2.dart' deferred as d; | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
testPart2() { | ||
print("Part 2"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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 P be a prefix scope containing all the import prefixes | ||
/// declared by the current file. The parent scope of P is I. | ||
/// - The P scope contains an entry for each name where the current file has an | ||
/// `import` directive with that name as prefix, `as name`. (If an import is | ||
/// `deferred`, it’s a compile-time error if more than one `import` directive | ||
/// in the same file has that prefix name, as usual. It’s not an error if two | ||
/// import deferred prefixes have the same name if they occur in different | ||
/// files, other file’s imports are only suggestions.) | ||
/// | ||
/// @description Check that it is not an error if two deferred `import` | ||
/// directives have the same prefix name but occurs in a different files. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import '../../Utils/expect.dart'; | ||
part 'scope_A03_t03_part1.dart'; | ||
|
||
main() { | ||
testPart1(); | ||
testPart2(); | ||
} |
Oops, something went wrong.