-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for metadata in all locations, cf. grammar
Change-Id: Ibaa2bcd014257c6ec7c756d352e55d48f8a4a902 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167801 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
- Loading branch information
Showing
2 changed files
with
124 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,2 @@ | ||
@m | ||
part of 'metadata_location_test.dart'; |
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,122 @@ | ||
// Copyright (c) 2020, 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. | ||
|
||
// Test that metadata can be located everywhere the grammar specifies that | ||
// it can occur, with a few variants especially for parameter locations. | ||
|
||
@m | ||
library metadata.location.test; | ||
|
||
@m | ||
import 'dart:async'; | ||
|
||
@m | ||
export 'dart:async'; | ||
|
||
@m | ||
part 'metadata_location_part.dart'; | ||
|
||
@m | ||
const m = 0; | ||
|
||
@m | ||
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {} | ||
|
||
@m | ||
void f2({@m p1, @m int? p2}) {} | ||
|
||
@m | ||
void f3(@m p1(), @m int p2()) {} | ||
|
||
@m | ||
class C { | ||
@m | ||
var x, y, z, w; | ||
|
||
@m | ||
covariant var u, v; | ||
|
||
@m | ||
C(@m this.x, @m int this.y, | ||
{@m this.z, @m int? this.w, @m this.u()?, @m int this.v()?}); | ||
|
||
@m | ||
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {} | ||
|
||
@m | ||
void f2({@m p1, @m int? p2}) {} | ||
|
||
@m | ||
void f3(@m covariant p1, @m covariant int p2, | ||
[@m covariant p3, @m covariant int? p4]) {} | ||
|
||
@m | ||
void f4({@m covariant p1, @m covariant int? p2}) {} | ||
|
||
@m | ||
int get prop => 0; | ||
|
||
@m | ||
set prop(int _) {} | ||
|
||
@m | ||
bool operator ==(other) => true; | ||
} | ||
|
||
@m | ||
mixin M { | ||
@m | ||
var x, y, z, w, u, v; | ||
|
||
@m | ||
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {} | ||
|
||
@m | ||
void f2({@m p1, @m int p2 = 0}) {} | ||
|
||
@m | ||
void f3(@m covariant p1, @m covariant int p2, | ||
[@m covariant p3, @m covariant int p4 = 0]) {} | ||
|
||
@m | ||
void f4({@m covariant p1, @m covariant int p2 = 0}) {} | ||
} | ||
|
||
@m | ||
extension Extension on int { | ||
@m | ||
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {} | ||
|
||
@m | ||
void f2({@m p1, @m int p2 = 0}) {} | ||
} | ||
|
||
@m | ||
enum E { | ||
@m | ||
one, | ||
@m | ||
two, | ||
} | ||
|
||
void f<@m X>() {} | ||
|
||
class D<@m X> {} | ||
|
||
@m | ||
typedef void F<@m X>(); | ||
|
||
void main() { | ||
@m | ||
var x; | ||
|
||
@m | ||
void f() {} | ||
|
||
for (@m | ||
int i = 0; | ||
i < 1; | ||
i++) {} | ||
for (@m int i in []) {} | ||
} |