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#1959. Grammar tests added (dart-lang#2031)
Add grammar tests
- Loading branch information
Showing
5 changed files
with
218 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,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 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 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 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 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); | ||
} |