OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library test.metadata_allowed_values; | 5 library test.metadata_allowed_values; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 import 'metadata_allowed_values_import.dart'; // Unprefixed. | 10 import 'metadata_allowed_values_import.dart'; // Unprefixed. |
11 import 'metadata_allowed_values_import.dart' as prefix; | 11 import 'metadata_allowed_values_import.dart' as prefix; |
12 | 12 |
13 @A // /// 01: compile-time error | 13 @A // //# 01: compile-time error |
14 class A {} | 14 class A {} |
15 | 15 |
16 @B.CONSTANT | 16 @B.CONSTANT |
17 class B { | 17 class B { |
18 static const CONSTANT = 3; | 18 static const CONSTANT = 3; |
19 } | 19 } |
20 | 20 |
21 @C(3) | 21 @C(3) |
22 class C { | 22 class C { |
23 final field; | 23 final field; |
24 const C(this.field); | 24 const C(this.field); |
25 } | 25 } |
26 | 26 |
27 @D.named(4) | 27 @D.named(4) |
28 class D { | 28 class D { |
29 final field; | 29 final field; |
30 const D.named(this.field); | 30 const D.named(this.field); |
31 } | 31 } |
32 | 32 |
33 @E.NOT_CONSTANT // /// 02: compile-time error | 33 @E.NOT_CONSTANT // //# 02: compile-time error |
34 class E { | 34 class E { |
35 static var NOT_CONSTANT = 3; | 35 static var NOT_CONSTANT = 3; |
36 } | 36 } |
37 | 37 |
38 @F(6) // /// 03: compile-time error | 38 @F(6) // //# 03: compile-time error |
39 class F { | 39 class F { |
40 final field; | 40 final field; |
41 F(this.field); | 41 F(this.field); |
42 } | 42 } |
43 | 43 |
44 @G.named(4) // /// 04: compile-time error | 44 @G.named(4) // //# 04: compile-time error |
45 class G { | 45 class G { |
46 final field; | 46 final field; |
47 G.named(this.field); | 47 G.named(this.field); |
48 } | 48 } |
49 | 49 |
50 @H<int>() // /// 05: compile-time error | 50 @H<int>() // //# 05: compile-time error |
51 class H<T> { | 51 class H<T> { |
52 const H(); | 52 const H(); |
53 } | 53 } |
54 | 54 |
55 @I[0] // /// 06: compile-time error | 55 @I[0] // //# 06: compile-time error |
56 class I {} | 56 class I {} |
57 | 57 |
58 @this.toString // /// 07: compile-time error | 58 @this.toString // //# 07: compile-time error |
59 class J {} | 59 class J {} |
60 | 60 |
61 @super.toString // /// 08: compile-time error | 61 @super.toString // //# 08: compile-time error |
62 class K {} | 62 class K {} |
63 | 63 |
64 @L.func() // /// 09: compile-time error | 64 @L.func() // //# 09: compile-time error |
65 class L { | 65 class L { |
66 static func() => 6; | 66 static func() => 6; |
67 } | 67 } |
68 | 68 |
69 @Imported // /// 10: compile-time error | 69 @Imported // //# 10: compile-time error |
70 class M {} | 70 class M {} |
71 | 71 |
72 @Imported() | 72 @Imported() |
73 class N {} | 73 class N {} |
74 | 74 |
75 @Imported.named() | 75 @Imported.named() |
76 class O {} | 76 class O {} |
77 | 77 |
78 @Imported.CONSTANT | 78 @Imported.CONSTANT |
79 class P {} | 79 class P {} |
80 | 80 |
81 @prefix.Imported // /// 11: compile-time error | 81 @prefix.Imported // //# 11: compile-time error |
82 class Q {} | 82 class Q {} |
83 | 83 |
84 @prefix.Imported() | 84 @prefix.Imported() |
85 class R {} | 85 class R {} |
86 | 86 |
87 @prefix.Imported.named() | 87 @prefix.Imported.named() |
88 class S {} | 88 class S {} |
89 | 89 |
90 @prefix.Imported.CONSTANT | 90 @prefix.Imported.CONSTANT |
91 class T {} | 91 class T {} |
92 | 92 |
93 @U..toString() // /// 12: compile-time error | 93 @U..toString() // //# 12: compile-time error |
94 class U {} | 94 class U {} |
95 | 95 |
96 @V.tearOff // /// 13: compile-time error | 96 @V.tearOff // //# 13: compile-time error |
97 class V { | 97 class V { |
98 static tearOff() {} | 98 static tearOff() {} |
99 } | 99 } |
100 | 100 |
101 topLevelTearOff() => 4; | 101 topLevelTearOff() => 4; |
102 | 102 |
103 @topLevelTearOff // /// 14: compile-time error | 103 @topLevelTearOff // //# 14: compile-time error |
104 class W {} | 104 class W {} |
105 | 105 |
106 @TypeParameter // /// 15: compile-time error | 106 @TypeParameter // //# 15: compile-time error |
107 class X<TypeParameter> {} | 107 class X<TypeParameter> {} |
108 | 108 |
109 @TypeParameter.member // /// 16: compile-time error | 109 @TypeParameter.member // //# 16: compile-time error |
110 class Y<TypeParameter> {} | 110 class Y<TypeParameter> {} |
111 | 111 |
112 @1 // /// 17: compile-time error | 112 @1 // //# 17: compile-time error |
113 class Z {} | 113 class Z {} |
114 | 114 |
115 @3.14 // /// 18: compile-time error | 115 @3.14 // //# 18: compile-time error |
116 class AA {} | 116 class AA {} |
117 | 117 |
118 @'string' // /// 19: compile-time error | 118 @'string' // //# 19: compile-time error |
119 class BB {} | 119 class BB {} |
120 | 120 |
121 @#symbol // /// 20: compile-time error | 121 @#symbol // //# 20: compile-time error |
122 class CC {} | 122 class CC {} |
123 | 123 |
124 @['element'] // /// 21: compile-time error | 124 @['element'] // //# 21: compile-time error |
125 class DD {} | 125 class DD {} |
126 | 126 |
127 @{'key': 'value'} // /// 22: compile-time error | 127 @{'key': 'value'} // //# 22: compile-time error |
128 class EE {} | 128 class EE {} |
129 | 129 |
130 @true // /// 23: compile-time error | 130 @true // //# 23: compile-time error |
131 class FF {} | 131 class FF {} |
132 | 132 |
133 @false // /// 24: compile-time error | 133 @false // //# 24: compile-time error |
134 class GG {} | 134 class GG {} |
135 | 135 |
136 @null // /// 25: compile-time error | 136 @null // //# 25: compile-time error |
137 class HH {} | 137 class HH {} |
138 | 138 |
139 const a = const [1, 2, 3]; | 139 const a = const [1, 2, 3]; |
140 @a | 140 @a |
141 class II {} | 141 class II {} |
142 | 142 |
143 @a[0] // /// 26: compile-time error | 143 @a[0] // //# 26: compile-time error |
144 class JJ {} | 144 class JJ {} |
145 | 145 |
146 @kk // /// 27: compile-time error | 146 @kk // //# 27: compile-time error |
147 class KK { | 147 class KK { |
148 const KK(); | 148 const KK(); |
149 } | 149 } |
150 get kk => const KK(); | 150 get kk => const KK(); |
151 | 151 |
152 @LL(() => 42) // /// 28: compile-time error | 152 @LL(() => 42) // //# 28: compile-time error |
153 class LL { | 153 class LL { |
154 final field; | 154 final field; |
155 const LL(this.field); | 155 const LL(this.field); |
156 } | 156 } |
157 | 157 |
158 @MM((x) => 42) // /// 29: compile-time error | 158 @MM((x) => 42) // //# 29: compile-time error |
159 class MM { | 159 class MM { |
160 final field; | 160 final field; |
161 const MM(this.field); | 161 const MM(this.field); |
162 } | 162 } |
163 | 163 |
164 @NN(() {}) // /// 30: compile-time error | 164 @NN(() {}) // //# 30: compile-time error |
165 class NN { | 165 class NN { |
166 final field; | 166 final field; |
167 const NN(this.field); | 167 const NN(this.field); |
168 } | 168 } |
169 | 169 |
170 @OO(() { () {} }) // /// 31: compile-time error | 170 @OO(() { () {} }) // //# 31: compile-time error |
171 class OO { | 171 class OO { |
172 final field; | 172 final field; |
173 const OO(this.field); | 173 const OO(this.field); |
174 } | 174 } |
175 | 175 |
176 checkMetadata(DeclarationMirror mirror, List expectedMetadata) { | 176 checkMetadata(DeclarationMirror mirror, List expectedMetadata) { |
177 Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata); | 177 Expect.listEquals(expectedMetadata.map(reflect).toList(), mirror.metadata); |
178 } | 178 } |
179 | 179 |
180 main() { | 180 main() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 reflectClass(GG).metadata; | 213 reflectClass(GG).metadata; |
214 reflectClass(HH).metadata; | 214 reflectClass(HH).metadata; |
215 reflectClass(II).metadata; | 215 reflectClass(II).metadata; |
216 reflectClass(JJ).metadata; | 216 reflectClass(JJ).metadata; |
217 reflectClass(KK).metadata; | 217 reflectClass(KK).metadata; |
218 reflectClass(LL).metadata; | 218 reflectClass(LL).metadata; |
219 reflectClass(MM).metadata; | 219 reflectClass(MM).metadata; |
220 reflectClass(NN).metadata; | 220 reflectClass(NN).metadata; |
221 reflectClass(OO).metadata; | 221 reflectClass(OO).metadata; |
222 } | 222 } |
OLD | NEW |