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#1400. [Views] Syntax tests added
- Loading branch information
Showing
11 changed files
with
446 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,36 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a function | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
void view() {} | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
view(); | ||
} |
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,37 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a class | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
class view { | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
view(); | ||
} |
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,39 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a mixin | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
mixin view on Object { | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
class VA = Object with view; | ||
|
||
main() { | ||
VA(); | ||
} |
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) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a variable | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
main() { | ||
int view = 42; | ||
// ^^^^ | ||
// [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,41 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a constant | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
const view = 42; | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
@view class View { | ||
final int id; | ||
View(this.id); | ||
} | ||
|
||
main() { | ||
View(0); | ||
} |
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,36 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error import a library with | ||
/// import prefix `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
import "views_lib.dart" as view; | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
view.x; | ||
} |
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,36 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// The token `view` is made a built-in identifier. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare a type alias | ||
/// named `view` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
typedef view = String; | ||
// ^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
||
main() { | ||
view s = ""; | ||
} |
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,59 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// ... | ||
/// If a view declaration named View includes a <viewPrimaryConstructor> then it | ||
/// is a compile-time error if the declaration includes a constructor | ||
/// declaration named View. (But it can still contain other constructors.) | ||
/// | ||
/// @description Checks that it is a compile-time error if a view declaration | ||
/// named `View` includes a <viewPrimaryConstructor> and includes a constructor | ||
/// named `View` | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
view class View1(int id) { | ||
View1(this.id); | ||
//^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
view class View2(int id) { | ||
int _x; | ||
View2(int id, this._x) {} | ||
//^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
view class View3(int id) { | ||
View3(); | ||
//^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
View1(1); | ||
View2(2); | ||
View3(3); | ||
} |
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,62 @@ | ||
// Copyright (c) 2022, 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 rule for <viewDeclaration> is added to the grammar, along with | ||
/// some rules for elements used in view declarations: | ||
/// | ||
/// <viewDeclaration> ::= | ||
/// 'view' 'class' <typeIdentifier> <typeParameters>? | ||
/// <viewPrimaryConstructor>? | ||
/// <interfaces>? | ||
/// '{' | ||
/// (<metadata> <viewMemberDeclaration>)* | ||
/// '}' | ||
/// | ||
/// <viewPrimaryConstructor> ::= | ||
/// '(' <type> <identifier> ')' | ||
/// | ||
/// <viewMemberDeclaration> ::= | ||
/// <classMemberDefinition> | ||
/// ... | ||
/// If a view declaration named View includes a <viewPrimaryConstructor> then it | ||
/// is a compile-time error if the declaration includes a constructor | ||
/// declaration named View. (But it can still contain other constructors.) | ||
/// | ||
/// @description Checks that it is a compile-time error if a view declaration | ||
/// named `View` includes a <viewPrimaryConstructor> with zero or more than one | ||
/// parameters | ||
/// @author sgrekhov22@gmail.com | ||
// SharedOptions=--enable-experiment=extension-types | ||
|
||
view class View1() { | ||
// ^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
view class View2(int id, String name) { | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
view class View3(int id, {String name}) { | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
view class View4(int id, [String name]) { | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(View1); | ||
print(View2); | ||
print(View3); | ||
print(View4); | ||
} |
Oops, something went wrong.