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 import inheritance and grammar tests
- Loading branch information
Showing
18 changed files
with
425 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,22 @@ | ||
// 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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a not existing file in its `part` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'grammar_A01_t01_part1.dart'; | ||
|
||
main() { | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Parts-with-imports/grammar_A01_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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a not existing file in its `part` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'grammar_A01_t01.dart'; | ||
part 'grammar_A01_t01_part2.dart'; | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified |
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,22 @@ | ||
// 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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file without `part of` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'grammar_A01_t02_part1.dart'; | ||
|
||
main() { | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Parts-with-imports/grammar_A01_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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file without `part of` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'grammar_A01_t02.dart'; | ||
part 'grammar_A01_t02_part2.dart'; | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Parts-with-imports/grammar_A01_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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file without `part of` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
foo() {} |
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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file with `part of` directive pointing | ||
/// back to another file. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'grammar_A01_t03_part1.dart'; | ||
|
||
main() { | ||
} |
23 changes: 23 additions & 0 deletions
23
LanguageFeatures/Parts-with-imports/grammar_A01_t03_lib.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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file with `part of` directive pointing | ||
/// back to another file. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part 'grammar_A01_t03_part2.dart'; | ||
|
||
main() { | ||
} |
24 changes: 24 additions & 0 deletions
24
LanguageFeatures/Parts-with-imports/grammar_A01_t03_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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file with `part of` directive pointing | ||
/// back to another file. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'grammar_A01_t03.dart'; | ||
part 'grammar_A01_t03_part2.dart'; | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified |
19 changes: 19 additions & 0 deletions
19
LanguageFeatures/Parts-with-imports/grammar_A01_t03_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,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 It’s a compile-time error if a Dart (parent) file with URI P has | ||
/// a `part` directive with a URI U, and the source content for the URI U does | ||
/// not parse as a `<partDirective>`, or if its leading `<partHeader>`'s `<uri>` | ||
/// string, resolved as a URI reference against the URI U, does not denote the | ||
/// library of P. That is, if a Dart file has a part directive, its target must | ||
/// be a part file whose “part of” directive points back to the first Dart file. | ||
/// Nothing new, except that now the parent file may not be a library file.) | ||
/// | ||
/// @description Check that it is a compile-time error if a parent file which is | ||
/// not a library file points to a part file without `part of` directive. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
part of 'grammar_A01_t03_lib.dart'; |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Parts-with-imports/import_inheritance_A01_t01.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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file import, inherited from the parent, | ||
/// can be overridden by it's own import. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import 'parts_lib.dart'; | ||
import '../../Utils/expect.dart'; | ||
|
||
part 'import_inheritance_A01_t01_part1.dart'; | ||
|
||
main() { | ||
Expect.equals("libVar", libVar); | ||
Expect.equals("LibClass", LibClass.id); | ||
Expect.equals("libGetter", libGetter); | ||
Expect.equals("LibMixin", LibMixin.id); | ||
testPart1(); | ||
testPart2(); | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Parts-with-imports/import_inheritance_A01_t01_lib1.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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file import, inherited from the parent, | ||
/// can be overridden by it's own import. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
// Overrides parts_lib.dart | ||
String libVar = "libVar lib1"; | ||
|
||
class LibClass { | ||
static final String id = "LibClass lib1"; | ||
} | ||
|
||
// Own declarations | ||
String foo() => "foo lib1"; | ||
|
||
class C { | ||
static final String id = "C lib1"; | ||
} |
30 changes: 30 additions & 0 deletions
30
LanguageFeatures/Parts-with-imports/import_inheritance_A01_t01_lib2.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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file import, inherited from the parent, | ||
/// can be overridden by it's own import. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
// Overrides parts_lib.dart | ||
String get libGetter => "libGetter lib2"; | ||
|
||
mixin LibMixin { | ||
static final String id = "LibMixin lib2"; | ||
} | ||
|
||
// Overrides import_inheritance_A01_t01_lib1.dart | ||
String foo() => "foo lib2"; | ||
|
||
class C { | ||
static final String id = "C lib2"; | ||
} |
28 changes: 28 additions & 0 deletions
28
LanguageFeatures/Parts-with-imports/import_inheritance_A01_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,28 @@ | ||
// 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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file import, inherited from the parent, | ||
/// can be overridden by it's own import. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import 'import_inheritance_A01_t01_lib1.dart'; | ||
|
||
part of 'import_inheritance_A01_t01.dart'; | ||
part 'import_inheritance_A01_t01_part2.dart'; | ||
|
||
void testPart1() { | ||
Expect.equals("libVar lib1", libVar); | ||
Expect.equals("LibClass lib1", LibClass.id); | ||
Expect.equals("foo lib1", foo()); | ||
Expect.equals("C lib1", C.id); | ||
} |
26 changes: 26 additions & 0 deletions
26
LanguageFeatures/Parts-with-imports/import_inheritance_A01_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,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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file import, inherited from the parent, | ||
/// can be overridden by it's own import. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import 'import_inheritance_A01_t01_lib2.dart'; | ||
part of 'import_inheritance_A01_t01_part1.dart'; | ||
|
||
void testPart2() { | ||
Expect.equals("libGetter lib2", libGetter); | ||
Expect.equals("LibMixin lib2", LibMixin.id); | ||
Expect.equals("foo lib2", foo()); | ||
Expect.equals("C lib2", C.id); | ||
} |
27 changes: 27 additions & 0 deletions
27
LanguageFeatures/Parts-with-imports/import_inheritance_A01_t02.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,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 Import inheritance is a only suggestion: Aka. other files’ | ||
/// imports cannot break your code (at least if you’re not depending on them). A | ||
/// part file is never restricted by the imports it inherits from its parent | ||
/// file. It can ignore and override all of them with imports of its own. That | ||
/// allows a file, like a macro generated file, to import all its own | ||
/// dependencies and be completely self-contained when it comes to imports. | ||
/// | ||
/// @description Check that for the part file may import its own copy of the | ||
/// library already imported by the parent. | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=enhanced-parts | ||
|
||
import 'parts_lib.dart'; | ||
import '../../Utils/expect.dart'; | ||
|
||
part 'import_inheritance_A01_t02_part1.dart'; | ||
|
||
main() { | ||
Expect.equals(0, counter); | ||
testPart1(); | ||
testPart2(); | ||
} |
Oops, something went wrong.