Skip to content

Commit

Permalink
dart-lang#2825. Add more grammar tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov committed Sep 16, 2024
1 parent baa1dd9 commit ee670c8
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 0 deletions.
37 changes: 37 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A02_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that `part` directive may contain a '<configurableUri>'.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

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

part 'grammar_A02_t01_part1.dart'
if (dart.library.io) 'grammar_A02_t01_part2.dart'
if (dart.library.collection) 'grammar_A02_t01_part3.dart';

main() {
Expect.isTrue(partId() == "part2" || partId() == "part3");
}
31 changes: 31 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A02_t01_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that `part` directive may contain a '<configurableUri>'.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'grammar_A02_t01.dart';

String partId() => "part1";
31 changes: 31 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A02_t01_part2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that `part` directive may contain a '<configurableUri>'.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'grammar_A02_t01.dart';

String partId() => "part2";
31 changes: 31 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A02_t01_part3.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that `part` directive may contain a '<configurableUri>'.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of 'grammar_A02_t01.dart';

String partId() => "part3";
37 changes: 37 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A03_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that it is a compile-time error to use a
/// <dottedIdentifier> in a `part of` directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

library grammar.a03.t01;
part 'grammar_A03_t01_part1.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
33 changes: 33 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A03_t01_part1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that it is a compile-time error to use a
/// <dottedIdentifier> in a `part of` directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part of grammar.a03.t01;
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
36 changes: 36 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A04_t01.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that it is a compile-time error to use more than one
/// <partHeader>.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'grammar_A04_t01_part1.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
30 changes: 30 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A04_t01_lib.dart
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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that it is a compile-time error to use more than one
/// <partHeader>.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

part 'grammar_A04_t01_part1.dart';
34 changes: 34 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A04_t01_part1.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 We extend the grammar of part files to allow import, export and
/// part file directives. We allow part files directives to use a configurable
/// URI like the other two. We restrict the part of directive to only allow the
/// string version.
///
/// -- Changed "<uri>" to "<configurableUri>".
/// <partDirective> ::= <metadata> `part' <configurableUri> `;'
///
/// -- Removed "<dottedIdentifier>" as option, retaining only "<uri>".
/// <partHeader> ::= <metadata> `part' `of' <uri> `;'
///
/// -- Added "<importOrExport>* <partDirective>*"
/// <partDeclaration> ::=
/// <partHeader> <importOrExport>* <partDirective>*
/// (<metadata> <topLevelDeclaration>)* <EOF>
///
/// The grammar change is small, mainly adding import, export and part
/// directives to part files.
///
/// @description Check that it is a compile-time error to use more than one
/// <partHeader>.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts

/**/part of 'grammar_A04_t01.dart';
/**/part of 'grammar_A04_t01_lib.dart';
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified

0 comments on commit ee670c8

Please sign in to comment.