Skip to content

Commit

Permalink
#2825. Add more grammar and terminology tests (#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrekhov authored Sep 27, 2024
1 parent 698701f commit 7f3439d
Show file tree
Hide file tree
Showing 18 changed files with 331 additions and 4 deletions.
36 changes: 36 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A05_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 Checks that it is a compile-time error if a part file contains
/// an unnamed library directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

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

main() {
}
35 changes: 35 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A05_t01_lib.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 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 Checks that it is a compile-time error if a part file contains
/// an unnamed library directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

library;

/**/part of 'grammar_A05_t01.dart';
// ^^^^
// [analyzer] unspecified
// [cfe] unspecified
37 changes: 37 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A05_t02.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 Checks that it is a compile-time error if a part file contains
/// a normal library directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

library grammar_A05_t02;
part 'grammar_A05_t02_lib.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

main() {
}
32 changes: 32 additions & 0 deletions LanguageFeatures/Parts-with-imports/grammar_A05_t02_lib.dart
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 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 Checks that it is a compile-time error if a part file contains
/// a normal library directive.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

library grammar_A05_t02;

part of 'grammar_A05_t02.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion It’s a compile-time error if a part file is a sub-part of itself.
/// That is, if the includes relation has a cycle.
///
/// @description Check that it is a compile-time error if a part file is a
/// sub-part of itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

/// @assertion It’s a compile-time error if a part file is a sub-part of itself.
/// That is, if the includes relation has a cycle.
///
/// @description Check that it is a compile-time error if a part file is a
/// sub-part of itself.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// 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 `part` directive denotes a file
/// which is not a part file.
/// @assertion It’s a compile-time error if a part file is a sub-part of itself.
/// That is, if the includes relation has a cycle.
///
/// @description Check that it is a compile-time error if a `part` directive
/// denotes a file which is not a part file.
/// @description Check that it is a compile-time error if a part file is a
/// sub-part of itself.
/// @author [email protected]
// SharedOptions=--enable-experiment=enhanced-parts
Expand Down
20 changes: 20 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t01.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` directive
/// refers to a Dart file which is not a library.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

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

main() {
}
14 changes: 14 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t01_lib1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t01_lib2.dart';
14 changes: 14 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t01_lib2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` directive
/// refers to a Dart file which is not a library.
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part 'terminology_A05_t01_lib1.dart';
18 changes: 18 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t02.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part 'terminology_A05_t02_lib1.dart';
part 'terminology_A05_t02_lib2.dart';

main() {
}
14 changes: 14 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t02_lib1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t02.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t02_lib2.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `import` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t02.dart';

import 'terminology_A05_t02_lib1.dart';
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
21 changes: 21 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t03.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `export` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

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

main() {
}
14 changes: 14 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t03_lib.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `export` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t03.dart';
18 changes: 18 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t04.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `export` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part 'terminology_A05_t04_lib1.dart';
part 'terminology_A05_t04_lib2.dart';

main() {
}
14 changes: 14 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t04_lib1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `export` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t04.dart';
19 changes: 19 additions & 0 deletions LanguageFeatures/Parts-with-imports/terminology_A05_t04_lib2.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 A Dart file is either a library file or a part file, each having
/// its own grammar.
///
/// @description Checks that it is a compile-time error if an `export` refers to
/// an entity which is not a library
/// @author [email protected]
// SharedOptions=--enable-experiment=macros

part of 'terminology_A05_t04.dart';

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

0 comments on commit 7f3439d

Please sign in to comment.