-
Notifications
You must be signed in to change notification settings - Fork 28
#1959. Grammar tests added #2031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,33 @@ | ||
// Copyright (c) 2023, 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 The grammar is: | ||
/// | ||
/// classDeclaration ::= (classModifiers | mixinClassModifiers) 'class' typeIdentifier | ||
/// typeParameters? superclass? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | classModifiers 'class' mixinApplicationClass | ||
/// | ||
/// classModifiers ::= 'sealed' | ||
/// | 'abstract'? ('base' | 'interface' | 'final')? | ||
/// | ||
/// mixinClassModifiers ::= 'abstract'? 'base'? 'mixin' | ||
/// | ||
/// mixinDeclaration ::= 'base'? 'mixin' typeIdentifier typeParameters? | ||
/// ('on' typeNotVoidList)? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | ||
/// @description Check that it is a compile-time error if a built-in identifier | ||
/// `interface` is used as an identifier | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
class interface {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
} |
This file contains hidden or 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,34 @@ | ||
// Copyright (c) 2023, 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 The grammar is: | ||
/// | ||
/// classDeclaration ::= (classModifiers | mixinClassModifiers) 'class' typeIdentifier | ||
/// typeParameters? superclass? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | classModifiers 'class' mixinApplicationClass | ||
/// | ||
/// classModifiers ::= 'sealed' | ||
/// | 'abstract'? ('base' | 'interface' | 'final')? | ||
/// | ||
/// mixinClassModifiers ::= 'abstract'? 'base'? 'mixin' | ||
/// | ||
/// mixinDeclaration ::= 'base'? 'mixin' typeIdentifier typeParameters? | ||
/// ('on' typeNotVoidList)? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | ||
/// @description Check that it is not an error to create a class named `base` or | ||
/// `sealed` | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
class base {} | ||
|
||
class sealed {} | ||
|
||
main() { | ||
print(base); | ||
print(sealed); | ||
} |
This file contains hidden or 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,35 @@ | ||
// Copyright (c) 2023, 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 The grammar is: | ||
/// | ||
/// classDeclaration ::= (classModifiers | mixinClassModifiers) 'class' typeIdentifier | ||
/// typeParameters? superclass? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | classModifiers 'class' mixinApplicationClass | ||
/// | ||
/// classModifiers ::= 'sealed' | ||
/// | 'abstract'? ('base' | 'interface' | 'final')? | ||
/// | ||
/// mixinClassModifiers ::= 'abstract'? 'base'? 'mixin' | ||
/// | ||
/// mixinDeclaration ::= 'base'? 'mixin' typeIdentifier typeParameters? | ||
/// ('on' typeNotVoidList)? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | ||
/// @description Check that it is not an error to declare a variable named | ||
/// `base`, `sealed` or `interface` | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
main() { | ||
var base = 1; | ||
var sealed = 2; | ||
var interface = 3; | ||
|
||
print(base); | ||
print(sealed); | ||
print(interface); | ||
} |
This file contains hidden or 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,46 @@ | ||
// Copyright (c) 2023, 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 The grammar is: | ||
/// | ||
/// classDeclaration ::= (classModifiers | mixinClassModifiers) 'class' typeIdentifier | ||
/// typeParameters? superclass? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | classModifiers 'class' mixinApplicationClass | ||
/// | ||
/// classModifiers ::= 'sealed' | ||
/// | 'abstract'? ('base' | 'interface' | 'final')? | ||
/// | ||
/// mixinClassModifiers ::= 'abstract'? 'base'? 'mixin' | ||
/// | ||
/// mixinDeclaration ::= 'base'? 'mixin' typeIdentifier typeParameters? | ||
/// ('on' typeNotVoidList)? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | ||
/// @description Check that it is a compile-time error if 'base', 'interface' or | ||
/// 'final' modifiers are placed before an `abstract` modifier | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
base abstract class C1 {} | ||
//^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
interface abstract class C2 {} | ||
//^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
final abstract class C3 {} | ||
// ^^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(C1); | ||
print(C2); | ||
print(C3); | ||
} |
This file contains hidden or 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,70 @@ | ||
// Copyright (c) 2023, 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 The grammar is: | ||
/// | ||
/// classDeclaration ::= (classModifiers | mixinClassModifiers) 'class' typeIdentifier | ||
/// typeParameters? superclass? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | classModifiers 'class' mixinApplicationClass | ||
/// | ||
/// classModifiers ::= 'sealed' | ||
/// | 'abstract'? ('base' | 'interface' | 'final')? | ||
/// | ||
/// mixinClassModifiers ::= 'abstract'? 'base'? 'mixin' | ||
/// | ||
/// mixinDeclaration ::= 'base'? 'mixin' typeIdentifier typeParameters? | ||
/// ('on' typeNotVoidList)? interfaces? | ||
/// '{' (metadata classMemberDeclaration)* '}' | ||
/// | ||
/// @description Check that it is a compile-time error if 'mixin', 'base', or | ||
/// `abstract` modifiers goes in a wrong order | ||
/// @author [email protected] | ||
|
||
// SharedOptions=--enable-experiment=class-modifiers | ||
|
||
base abstract mixin class C1 {} | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
base mixin abstract class C2 {} | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin base abstract class C3 {} | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin abstract base class C4 {} | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
abstract mixin base class C5 {} | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin abstract class C6 {} | ||
// ^^^^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
mixin base class C7 {} | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
print(C1); | ||
print(C2); | ||
print(C3); | ||
print(C4); | ||
print(C5); | ||
print(C6); | ||
print(C7); | ||
} | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! The parser could get confused about these situations, e.g., it could crash, and we should test this.