Skip to content

Commit 016ebdd

Browse files
eernstgcommit-bot@chromium.org
authored andcommitted
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 <[email protected]> Reviewed-by: Lasse R.H. Nielsen <[email protected]>
1 parent 1e5f4ec commit 016ebdd

File tree

2 files changed

+124
-0
lines changed

2 files changed

+124
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@m
2+
part of 'metadata_location_test.dart';
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// Test that metadata can be located everywhere the grammar specifies that
6+
// it can occur, with a few variants especially for parameter locations.
7+
8+
@m
9+
library metadata.location.test;
10+
11+
@m
12+
import 'dart:async';
13+
14+
@m
15+
export 'dart:async';
16+
17+
@m
18+
part 'metadata_location_part.dart';
19+
20+
@m
21+
const m = 0;
22+
23+
@m
24+
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {}
25+
26+
@m
27+
void f2({@m p1, @m int? p2}) {}
28+
29+
@m
30+
void f3(@m p1(), @m int p2()) {}
31+
32+
@m
33+
class C {
34+
@m
35+
var x, y, z, w;
36+
37+
@m
38+
covariant var u, v;
39+
40+
@m
41+
C(@m this.x, @m int this.y,
42+
{@m this.z, @m int? this.w, @m this.u()?, @m int this.v()?});
43+
44+
@m
45+
void f1(@m p1, @m int p2, [@m p3, @m int? p4]) {}
46+
47+
@m
48+
void f2({@m p1, @m int? p2}) {}
49+
50+
@m
51+
void f3(@m covariant p1, @m covariant int p2,
52+
[@m covariant p3, @m covariant int? p4]) {}
53+
54+
@m
55+
void f4({@m covariant p1, @m covariant int? p2}) {}
56+
57+
@m
58+
int get prop => 0;
59+
60+
@m
61+
set prop(int _) {}
62+
63+
@m
64+
bool operator ==(other) => true;
65+
}
66+
67+
@m
68+
mixin M {
69+
@m
70+
var x, y, z, w, u, v;
71+
72+
@m
73+
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {}
74+
75+
@m
76+
void f2({@m p1, @m int p2 = 0}) {}
77+
78+
@m
79+
void f3(@m covariant p1, @m covariant int p2,
80+
[@m covariant p3, @m covariant int p4 = 0]) {}
81+
82+
@m
83+
void f4({@m covariant p1, @m covariant int p2 = 0}) {}
84+
}
85+
86+
@m
87+
extension Extension on int {
88+
@m
89+
void f1(@m p1, @m int p2, [@m p3, @m int p4 = 0]) {}
90+
91+
@m
92+
void f2({@m p1, @m int p2 = 0}) {}
93+
}
94+
95+
@m
96+
enum E {
97+
@m
98+
one,
99+
@m
100+
two,
101+
}
102+
103+
void f<@m X>() {}
104+
105+
class D<@m X> {}
106+
107+
@m
108+
typedef void F<@m X>();
109+
110+
void main() {
111+
@m
112+
var x;
113+
114+
@m
115+
void f() {}
116+
117+
for (@m
118+
int i = 0;
119+
i < 1;
120+
i++) {}
121+
for (@m int i in []) {}
122+
}

0 commit comments

Comments
 (0)