OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 smoke.test.codegen.recorder_test; | 5 library smoke.test.codegen.recorder_test; |
6 | 6 |
7 import 'package:analyzer/src/generated/element.dart'; | 7 import 'package:analyzer/src/generated/element.dart'; |
8 import 'package:smoke/codegen/generator.dart'; | 8 import 'package:smoke/codegen/generator.dart'; |
9 import 'package:smoke/codegen/recorder.dart'; | 9 import 'package:smoke/codegen/recorder.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 11 matching lines...) Expand all Loading... |
22 }); | 22 }); |
23 | 23 |
24 group('parents', () { | 24 group('parents', () { |
25 test('simple subclassing', () { | 25 test('simple subclassing', () { |
26 var lib = provider.libraryFor('/a.dart'); | 26 var lib = provider.libraryFor('/a.dart'); |
27 recorder.lookupParent(lib.getType('A')); | 27 recorder.lookupParent(lib.getType('A')); |
28 recorder.lookupParent(lib.getType('C')); | 28 recorder.lookupParent(lib.getType('C')); |
29 | 29 |
30 checkResults(generator, | 30 checkResults(generator, |
31 imports: [ | 31 imports: [ |
32 "import '/a.dart' as smoke_0;", | 32 "import '/a.dart' as smoke_0;", |
33 "import '/b.dart' as smoke_1;", | 33 "import '/b.dart' as smoke_1;", |
34 ], | 34 ], |
35 initCall: | 35 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
36 'useGeneratedCode(new StaticConfiguration(\n' | 36 ' checkedMode: false,\n' |
37 ' checkedMode: false,\n' | 37 ' parents: {\n' |
38 ' parents: {\n' | 38 ' smoke_0.A: smoke_1.B,\n' |
39 ' smoke_0.A: smoke_1.B,\n' | 39 ' smoke_0.C: smoke_0.A,\n' |
40 ' smoke_0.C: smoke_0.A,\n' | 40 ' }));\n'); |
41 ' }));\n'); | |
42 }); | 41 }); |
43 | 42 |
44 test('single mixin', () { | 43 test('single mixin', () { |
45 var lib = provider.libraryFor('/a.dart'); | 44 var lib = provider.libraryFor('/a.dart'); |
46 recorder.lookupParent(lib.getType('E')); | 45 recorder.lookupParent(lib.getType('E')); |
47 | 46 |
48 checkResults(generator, | 47 checkResults(generator, |
49 imports: [ | 48 imports: ["import '/a.dart' as smoke_0;",], |
50 "import '/a.dart' as smoke_0;", | |
51 ], | |
52 topLevel: 'abstract class _M0 {} // A & D1\n', | 49 topLevel: 'abstract class _M0 {} // A & D1\n', |
53 initCall: | 50 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
54 'useGeneratedCode(new StaticConfiguration(\n' | 51 ' checkedMode: false,\n' |
55 ' checkedMode: false,\n' | 52 ' parents: {\n' |
56 ' parents: {\n' | 53 ' smoke_0.E: _M0,\n' |
57 ' smoke_0.E: _M0,\n' | 54 ' _M0: smoke_0.A,\n' |
58 ' _M0: smoke_0.A,\n' | 55 ' }));\n'); |
59 ' }));\n'); | |
60 }); | 56 }); |
61 | 57 |
62 test('multiple mixins', () { | 58 test('multiple mixins', () { |
63 var lib = provider.libraryFor('/a.dart'); | 59 var lib = provider.libraryFor('/a.dart'); |
64 recorder.lookupParent(lib.getType('F')); | 60 recorder.lookupParent(lib.getType('F')); |
65 | 61 |
66 checkResults(generator, | 62 checkResults(generator, |
67 imports: [ | 63 imports: ["import '/a.dart' as smoke_0;",], |
68 "import '/a.dart' as smoke_0;", | 64 topLevel: 'abstract class _M0 {} // A & D1\n' |
69 ], | 65 'abstract class _M1 {} // _M0 & D2\n' |
70 topLevel: | 66 'abstract class _M2 {} // _M1 & D3\n', |
71 'abstract class _M0 {} // A & D1\n' | 67 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
72 'abstract class _M1 {} // _M0 & D2\n' | 68 ' checkedMode: false,\n' |
73 'abstract class _M2 {} // _M1 & D3\n', | 69 ' parents: {\n' |
74 initCall: | 70 ' smoke_0.F: _M2,\n' |
75 'useGeneratedCode(new StaticConfiguration(\n' | 71 ' _M0: smoke_0.A,\n' |
76 ' checkedMode: false,\n' | 72 ' _M1: _M0,\n' |
77 ' parents: {\n' | 73 ' _M2: _M1,\n' |
78 ' smoke_0.F: _M2,\n' | 74 ' }));\n'); |
79 ' _M0: smoke_0.A,\n' | |
80 ' _M1: _M0,\n' | |
81 ' _M2: _M1,\n' | |
82 ' }));\n'); | |
83 }); | 75 }); |
84 | 76 |
85 test('same as common_test', () { | 77 test('same as common_test', () { |
86 var lib = provider.libraryFor('/common.dart'); | 78 var lib = provider.libraryFor('/common.dart'); |
87 recorder.lookupParent(lib.getType('Annot')); | 79 recorder.lookupParent(lib.getType('Annot')); |
88 recorder.lookupParent(lib.getType('AnnotB')); | 80 recorder.lookupParent(lib.getType('AnnotB')); |
89 recorder.lookupParent(lib.getType('A')); | 81 recorder.lookupParent(lib.getType('A')); |
90 recorder.lookupParent(lib.getType('B')); | 82 recorder.lookupParent(lib.getType('B')); |
91 recorder.lookupParent(lib.getType('C')); | 83 recorder.lookupParent(lib.getType('C')); |
92 recorder.lookupParent(lib.getType('D')); | 84 recorder.lookupParent(lib.getType('D')); |
93 recorder.lookupParent(lib.getType('E')); | 85 recorder.lookupParent(lib.getType('E')); |
94 recorder.lookupParent(lib.getType('E2')); | 86 recorder.lookupParent(lib.getType('E2')); |
95 recorder.lookupParent(lib.getType('F')); | 87 recorder.lookupParent(lib.getType('F')); |
96 recorder.lookupParent(lib.getType('F2')); | 88 recorder.lookupParent(lib.getType('F2')); |
97 recorder.lookupParent(lib.getType('G')); | 89 recorder.lookupParent(lib.getType('G')); |
98 recorder.lookupParent(lib.getType('H')); | 90 recorder.lookupParent(lib.getType('H')); |
99 var coreLib = lib.visibleLibraries.firstWhere( | 91 var coreLib = |
100 (l) => l.displayName == 'dart.core'); | 92 lib.visibleLibraries.firstWhere((l) => l.displayName == 'dart.core'); |
101 recorder.lookupParent(coreLib.getType('int')); | 93 recorder.lookupParent(coreLib.getType('int')); |
102 recorder.lookupParent(coreLib.getType('num')); | 94 recorder.lookupParent(coreLib.getType('num')); |
103 | 95 |
104 checkResults(generator, | 96 checkResults(generator, |
105 imports: [ | 97 imports: ["import '/common.dart' as smoke_0;",], |
106 "import '/common.dart' as smoke_0;", | 98 topLevel: 'abstract class _M0 {} // C & A\n', |
107 ], | 99 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
108 topLevel: | 100 ' checkedMode: false,\n' |
109 'abstract class _M0 {} // C & A\n', | 101 ' parents: {\n' |
110 initCall: | 102 ' smoke_0.AnnotB: smoke_0.Annot,\n' |
111 'useGeneratedCode(new StaticConfiguration(\n' | 103 ' smoke_0.D: _M0,\n' |
112 ' checkedMode: false,\n' | 104 ' smoke_0.E2: smoke_0.E,\n' |
113 ' parents: {\n' | 105 ' smoke_0.F2: smoke_0.F,\n' |
114 ' smoke_0.AnnotB: smoke_0.Annot,\n' | 106 ' smoke_0.H: smoke_0.G,\n' |
115 ' smoke_0.D: _M0,\n' | 107 ' int: num,\n' |
116 ' smoke_0.E2: smoke_0.E,\n' | 108 ' _M0: smoke_0.C,\n' |
117 ' smoke_0.F2: smoke_0.F,\n' | 109 ' }));\n'); |
118 ' smoke_0.H: smoke_0.G,\n' | |
119 ' int: num,\n' | |
120 ' _M0: smoke_0.C,\n' | |
121 ' }));\n'); | |
122 }); | 110 }); |
123 }); | 111 }); |
124 | 112 |
125 test('add static method, no declaration', () { | 113 test('add static method, no declaration', () { |
126 var lib = provider.libraryFor('/common.dart'); | 114 var lib = provider.libraryFor('/common.dart'); |
127 recorder.addStaticMethod(lib.getType('A'), 'sM'); | 115 recorder.addStaticMethod(lib.getType('A'), 'sM'); |
128 checkResults(generator, | 116 checkResults(generator, |
129 imports: [ | 117 imports: ["import '/common.dart' as smoke_0;",], |
130 "import '/common.dart' as smoke_0;", | 118 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
131 ], | 119 ' checkedMode: false,\n' |
132 initCall: | 120 ' staticMethods: {\n' |
133 'useGeneratedCode(new StaticConfiguration(\n' | 121 ' smoke_0.A: {\n' |
134 ' checkedMode: false,\n' | 122 ' #sM: smoke_0.A.sM,\n' |
135 ' staticMethods: {\n' | 123 ' },\n' |
136 ' smoke_0.A: {\n' | 124 ' }));\n'); |
137 ' #sM: smoke_0.A.sM,\n' | |
138 ' },\n' | |
139 ' }));\n'); | |
140 }); | 125 }); |
141 | 126 |
142 group('lookup member', () { | 127 group('lookup member', () { |
143 var lib; | 128 var lib; |
144 setUp(() { | 129 setUp(() { |
145 lib = provider.libraryFor('/common.dart'); | 130 lib = provider.libraryFor('/common.dart'); |
146 }); | 131 }); |
147 | 132 |
148 test('missing declaration', () { | 133 test('missing declaration', () { |
149 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false); | 134 recorder.lookupMember(lib.getType('A'), 'q', includeAccessors: false); |
150 checkResults(generator, | 135 checkResults(generator, |
151 imports: [ | 136 imports: ["import '/common.dart' as smoke_0;",], |
152 "import '/common.dart' as smoke_0;", | 137 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
153 ], | 138 ' checkedMode: false,\n' |
154 initCall: | 139 ' declarations: {\n' |
155 'useGeneratedCode(new StaticConfiguration(\n' | 140 ' smoke_0.A: {},\n' |
156 ' checkedMode: false,\n' | 141 ' }));\n'); |
157 ' declarations: {\n' | |
158 ' smoke_0.A: {},\n' | |
159 ' }));\n'); | |
160 }); | 142 }); |
161 | 143 |
162 test('field declaration', () { | 144 test('field declaration', () { |
163 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false); | 145 recorder.lookupMember(lib.getType('A'), 'i', includeAccessors: false); |
164 checkResults(generator, | 146 checkResults(generator, |
165 imports: [ | 147 imports: ["import '/common.dart' as smoke_0;",], |
166 "import '/common.dart' as smoke_0;", | 148 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
167 ], | 149 ' checkedMode: false,\n' |
168 initCall: | 150 ' declarations: {\n' |
169 'useGeneratedCode(new StaticConfiguration(\n' | 151 ' smoke_0.A: {\n' |
170 ' checkedMode: false,\n' | 152 ' #i: const Declaration(#i, int),\n' |
171 ' declarations: {\n' | 153 ' },\n' |
172 ' smoke_0.A: {\n' | 154 ' }));\n'); |
173 ' #i: const Declaration(#i, int),\n' | |
174 ' },\n' | |
175 ' }));\n'); | |
176 }); | 155 }); |
177 | 156 |
178 test('sattic field declaration', () { | 157 test('sattic field declaration', () { |
179 recorder.lookupMember(lib.getType('A'), 'sI', includeAccessors: false); | 158 recorder.lookupMember(lib.getType('A'), 'sI', includeAccessors: false); |
180 checkResults(generator, | 159 checkResults(generator, |
181 imports: [ | 160 imports: ["import '/common.dart' as smoke_0;",], |
182 "import '/common.dart' as smoke_0;", | 161 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
183 ], | 162 ' checkedMode: false,\n' |
184 initCall: | 163 ' declarations: {\n' |
185 'useGeneratedCode(new StaticConfiguration(\n' | 164 ' smoke_0.A: {\n' |
186 ' checkedMode: false,\n' | 165 ' #sI: const Declaration(#sI, int, isStatic: true),\n' |
187 ' declarations: {\n' | 166 ' },\n' |
188 ' smoke_0.A: {\n' | 167 ' }));\n'); |
189 ' #sI: const Declaration(#sI, int, isStatic: true),\n' | |
190 ' },\n' | |
191 ' }));\n'); | |
192 }); | 168 }); |
193 | 169 |
194 test('property declaration', () { | 170 test('property declaration', () { |
195 recorder.lookupMember(lib.getType('A'), 'j2', includeAccessors: false); | 171 recorder.lookupMember(lib.getType('A'), 'j2', includeAccessors: false); |
196 checkResults(generator, | 172 checkResults(generator, |
197 imports: [ | 173 imports: ["import '/common.dart' as smoke_0;",], |
198 "import '/common.dart' as smoke_0;", | 174 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
199 ], | 175 ' checkedMode: false,\n' |
200 initCall: | 176 ' declarations: {\n' |
201 'useGeneratedCode(new StaticConfiguration(\n' | 177 ' smoke_0.A: {\n' |
202 ' checkedMode: false,\n' | 178 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
203 ' declarations: {\n' | 179 ' },\n' |
204 ' smoke_0.A: {\n' | 180 ' }));\n'); |
205 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | |
206 ' },\n' | |
207 ' }));\n'); | |
208 }); | 181 }); |
209 | 182 |
210 test('static property declaration', () { | 183 test('static property declaration', () { |
211 recorder.lookupMember(lib.getType('A'), 'sJ', includeAccessors: false); | 184 recorder.lookupMember(lib.getType('A'), 'sJ', includeAccessors: false); |
212 final details = 'kind: PROPERTY, isFinal: true, isStatic: true'; | 185 final details = 'kind: PROPERTY, isFinal: true, isStatic: true'; |
213 checkResults(generator, | 186 checkResults(generator, |
214 imports: [ | 187 imports: ["import '/common.dart' as smoke_0;",], |
215 "import '/common.dart' as smoke_0;", | 188 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
216 ], | 189 ' checkedMode: false,\n' |
217 initCall: | 190 ' declarations: {\n' |
218 'useGeneratedCode(new StaticConfiguration(\n' | 191 ' smoke_0.A: {\n' |
219 ' checkedMode: false,\n' | 192 ' #sJ: const Declaration(#sJ, int, $details),\n' |
220 ' declarations: {\n' | 193 ' },\n' |
221 ' smoke_0.A: {\n' | 194 ' }));\n'); |
222 ' #sJ: const Declaration(#sJ, int, $details),\n' | |
223 ' },\n' | |
224 ' }));\n'); | |
225 }); | 195 }); |
226 | 196 |
227 test('field and property of dynamic type', () { | 197 test('field and property of dynamic type', () { |
228 recorder.lookupMember(lib.getType('I'), 'i1', includeAccessors: false); | 198 recorder.lookupMember(lib.getType('I'), 'i1', includeAccessors: false); |
229 recorder.lookupMember(lib.getType('I'), 'i2', includeAccessors: false); | 199 recorder.lookupMember(lib.getType('I'), 'i2', includeAccessors: false); |
230 checkResults(generator, | 200 checkResults(generator, |
231 imports: [ | 201 imports: ["import '/common.dart' as smoke_0;",], |
232 "import '/common.dart' as smoke_0;", | 202 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
233 ], | 203 ' checkedMode: false,\n' |
234 initCall: | 204 ' declarations: {\n' |
235 'useGeneratedCode(new StaticConfiguration(\n' | 205 ' smoke_0.I: {\n' |
236 ' checkedMode: false,\n' | 206 ' #i1: const Declaration(#i1, dynamic),\n' |
237 ' declarations: {\n' | 207 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' |
238 ' smoke_0.I: {\n' | 208 ' },\n' |
239 ' #i1: const Declaration(#i1, dynamic),\n' | 209 ' }));\n'); |
240 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' | |
241 ' },\n' | |
242 ' }));\n'); | |
243 }); | 210 }); |
244 | 211 |
245 test('property of concrete type', () { | 212 test('property of concrete type', () { |
246 recorder.lookupMember(lib.getType('I'), 'i3', includeAccessors: false); | 213 recorder.lookupMember(lib.getType('I'), 'i3', includeAccessors: false); |
247 checkResults(generator, | 214 checkResults(generator, |
248 imports: [ | 215 imports: ["import '/common.dart' as smoke_0;",], |
249 "import '/common.dart' as smoke_0;", | 216 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
250 ], | 217 ' checkedMode: false,\n' |
251 initCall: | 218 ' declarations: {\n' |
252 'useGeneratedCode(new StaticConfiguration(\n' | 219 ' smoke_0.I: {\n' |
253 ' checkedMode: false,\n' | 220 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' |
254 ' declarations: {\n' | 221 'isFinal: true),\n' |
255 ' smoke_0.I: {\n' | 222 ' },\n' |
256 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' | 223 ' }));\n'); |
257 'isFinal: true),\n' | |
258 ' },\n' | |
259 ' }));\n'); | |
260 }); | 224 }); |
261 | 225 |
262 test('method declaration', () { | 226 test('method declaration', () { |
263 recorder.lookupMember(lib.getType('A'), 'inc0', includeAccessors: false); | 227 recorder.lookupMember(lib.getType('A'), 'inc0', includeAccessors: false); |
264 checkResults(generator, | 228 checkResults(generator, |
265 imports: [ | 229 imports: ["import '/common.dart' as smoke_0;",], |
266 "import '/common.dart' as smoke_0;", | 230 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
267 ], | 231 ' checkedMode: false,\n' |
268 initCall: | 232 ' declarations: {\n' |
269 'useGeneratedCode(new StaticConfiguration(\n' | 233 ' smoke_0.A: {\n' |
270 ' checkedMode: false,\n' | 234 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' |
271 ' declarations: {\n' | 235 ' },\n' |
272 ' smoke_0.A: {\n' | 236 ' }));\n'); |
273 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' | |
274 ' },\n' | |
275 ' }));\n'); | |
276 }); | 237 }); |
277 | 238 |
278 test('static method declaration', () { | 239 test('static method declaration', () { |
279 recorder.lookupMember(lib.getType('A'), 'sM', includeAccessors: false); | 240 recorder.lookupMember(lib.getType('A'), 'sM', includeAccessors: false); |
280 const details = 'kind: METHOD, isStatic: true'; | 241 const details = 'kind: METHOD, isStatic: true'; |
281 checkResults(generator, | 242 checkResults(generator, |
282 imports: [ | 243 imports: ["import '/common.dart' as smoke_0;",], |
283 "import '/common.dart' as smoke_0;", | 244 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
284 ], | 245 ' checkedMode: false,\n' |
285 initCall: | 246 ' declarations: {\n' |
286 'useGeneratedCode(new StaticConfiguration(\n' | 247 ' smoke_0.A: {\n' |
287 ' checkedMode: false,\n' | 248 ' #sM: const Declaration(#sM, Function, $details),\n' |
288 ' declarations: {\n' | 249 ' },\n' |
289 ' smoke_0.A: {\n' | 250 ' }));\n'); |
290 ' #sM: const Declaration(#sM, Function, $details),\n' | |
291 ' },\n' | |
292 ' }));\n'); | |
293 }); | 251 }); |
294 | 252 |
295 test('inherited field - not recursive', () { | 253 test('inherited field - not recursive', () { |
296 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false); | 254 recorder.lookupMember(lib.getType('D'), 'i', includeAccessors: false); |
297 checkResults(generator, | 255 checkResults(generator, |
298 imports: [ | 256 imports: ["import '/common.dart' as smoke_0;",], |
299 "import '/common.dart' as smoke_0;", | 257 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
300 ], | 258 ' checkedMode: false,\n' |
301 initCall: | 259 ' declarations: {\n' |
302 'useGeneratedCode(new StaticConfiguration(\n' | 260 ' smoke_0.D: {},\n' |
303 ' checkedMode: false,\n' | 261 ' }));\n'); |
304 ' declarations: {\n' | |
305 ' smoke_0.D: {},\n' | |
306 ' }));\n'); | |
307 }); | 262 }); |
308 | 263 |
309 test('inherited field - recursive', () { | 264 test('inherited field - recursive', () { |
310 recorder.lookupMember(lib.getType('D'), 'i', recursive: true, | 265 recorder.lookupMember(lib.getType('D'), 'i', |
311 includeAccessors: false); | 266 recursive: true, includeAccessors: false); |
312 checkResults(generator, | 267 checkResults(generator, |
313 imports: [ | 268 imports: ["import '/common.dart' as smoke_0;",], |
314 "import '/common.dart' as smoke_0;", | |
315 ], | |
316 topLevel: 'abstract class _M0 {} // C & A\n', | 269 topLevel: 'abstract class _M0 {} // C & A\n', |
317 initCall: | 270 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
318 'useGeneratedCode(new StaticConfiguration(\n' | 271 ' checkedMode: false,\n' |
319 ' checkedMode: false,\n' | 272 ' parents: {\n' |
320 ' parents: {\n' | 273 ' smoke_0.D: _M0,\n' |
321 ' smoke_0.D: _M0,\n' | 274 ' _M0: smoke_0.C,\n' |
322 ' _M0: smoke_0.C,\n' | 275 ' },\n' |
323 ' },\n' | 276 ' declarations: {\n' |
324 ' declarations: {\n' | 277 ' smoke_0.D: {},\n' |
325 ' smoke_0.D: {},\n' | 278 ' _M0: {\n' |
326 ' _M0: {\n' | 279 ' #i: const Declaration(#i, int),\n' |
327 ' #i: const Declaration(#i, int),\n' | 280 ' },\n' |
328 ' },\n' | 281 ' }));\n'); |
329 ' }));\n'); | |
330 }); | 282 }); |
331 | 283 |
332 test('inherited field - recursive deep', () { | 284 test('inherited field - recursive deep', () { |
333 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, | 285 recorder.lookupMember(lib.getType('J3'), 'i', |
334 includeAccessors: false); | 286 recursive: true, includeAccessors: false); |
335 checkResults(generator, | 287 checkResults(generator, |
336 imports: [ | 288 imports: ["import '/common.dart' as smoke_0;",], |
337 "import '/common.dart' as smoke_0;", | 289 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
338 ], | 290 ' checkedMode: false,\n' |
339 initCall: | 291 ' parents: {\n' |
340 'useGeneratedCode(new StaticConfiguration(\n' | 292 ' smoke_0.J2: smoke_0.J1,\n' |
341 ' checkedMode: false,\n' | 293 ' smoke_0.J3: smoke_0.J2,\n' |
342 ' parents: {\n' | 294 ' },\n' |
343 ' smoke_0.J2: smoke_0.J1,\n' | 295 ' declarations: {\n' |
344 ' smoke_0.J3: smoke_0.J2,\n' | 296 ' smoke_0.J1: {\n' |
345 ' },\n' | 297 ' #i: const Declaration(#i, int),\n' |
346 ' declarations: {\n' | 298 ' },\n' |
347 ' smoke_0.J1: {\n' | 299 ' smoke_0.J2: {},\n' |
348 ' #i: const Declaration(#i, int),\n' | 300 ' smoke_0.J3: {},\n' |
349 ' },\n' | 301 ' }));\n'); |
350 ' smoke_0.J2: {},\n' | |
351 ' smoke_0.J3: {},\n' | |
352 ' }));\n'); | |
353 }); | 302 }); |
354 | 303 |
355 test('inherited field - recursive - includeUpTo', () { | 304 test('inherited field - recursive - includeUpTo', () { |
356 recorder.lookupMember(lib.getType('J3'), 'i', recursive: true, | 305 recorder.lookupMember(lib.getType('J3'), 'i', |
357 includeAccessors: false, includeUpTo: lib.getType('J1')); | 306 recursive: true, |
| 307 includeAccessors: false, |
| 308 includeUpTo: lib.getType('J1')); |
358 checkResults(generator, | 309 checkResults(generator, |
359 imports: [ | 310 imports: ["import '/common.dart' as smoke_0;",], |
360 "import '/common.dart' as smoke_0;", | 311 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
361 ], | 312 ' checkedMode: false,\n' |
362 initCall: | 313 ' parents: {\n' |
363 'useGeneratedCode(new StaticConfiguration(\n' | 314 ' smoke_0.J2: smoke_0.J1,\n' |
364 ' checkedMode: false,\n' | 315 ' smoke_0.J3: smoke_0.J2,\n' |
365 ' parents: {\n' | 316 ' },\n' |
366 ' smoke_0.J2: smoke_0.J1,\n' | 317 ' declarations: {\n' |
367 ' smoke_0.J3: smoke_0.J2,\n' | 318 ' smoke_0.J2: {},\n' |
368 ' },\n' | 319 ' smoke_0.J3: {},\n' |
369 ' declarations: {\n' | 320 ' }));\n'); |
370 ' smoke_0.J2: {},\n' | |
371 ' smoke_0.J3: {},\n' | |
372 ' }));\n'); | |
373 }); | 321 }); |
374 }); | 322 }); |
375 | 323 |
376 group('query', () { | 324 group('query', () { |
377 test('default query', () { | 325 test('default query', () { |
378 var options = new QueryOptions(); | 326 var options = new QueryOptions(); |
379 var lib = provider.libraryFor('/common.dart'); | 327 var lib = provider.libraryFor('/common.dart'); |
380 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); | 328 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
381 checkResults(generator, | 329 checkResults(generator, |
382 imports: [ | 330 imports: ["import '/common.dart' as smoke_0;",], |
383 "import '/common.dart' as smoke_0;", | 331 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
384 ], | 332 ' checkedMode: false,\n' |
385 initCall: | 333 ' declarations: {\n' |
386 'useGeneratedCode(new StaticConfiguration(\n' | 334 ' smoke_0.A: {\n' |
387 ' checkedMode: false,\n' | 335 ' #i: const Declaration(#i, int),\n' |
388 ' declarations: {\n' | 336 ' #j: const Declaration(#j, int),\n' |
389 ' smoke_0.A: {\n' | 337 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
390 ' #i: const Declaration(#i, int),\n' | 338 ' },\n' |
391 ' #j: const Declaration(#j, int),\n' | 339 ' }));\n'); |
392 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | |
393 ' },\n' | |
394 ' }));\n'); | |
395 | |
396 }); | 340 }); |
397 | 341 |
398 test('only fields', () { | 342 test('only fields', () { |
399 var options = new QueryOptions(includeProperties: false); | 343 var options = new QueryOptions(includeProperties: false); |
400 var lib = provider.libraryFor('/common.dart'); | 344 var lib = provider.libraryFor('/common.dart'); |
401 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); | 345 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
402 checkResults(generator, | 346 checkResults(generator, |
403 imports: [ | 347 imports: ["import '/common.dart' as smoke_0;",], |
404 "import '/common.dart' as smoke_0;", | 348 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
405 ], | 349 ' checkedMode: false,\n' |
406 initCall: | 350 ' declarations: {\n' |
407 'useGeneratedCode(new StaticConfiguration(\n' | 351 ' smoke_0.A: {\n' |
408 ' checkedMode: false,\n' | 352 ' #i: const Declaration(#i, int),\n' |
409 ' declarations: {\n' | 353 ' #j: const Declaration(#j, int),\n' |
410 ' smoke_0.A: {\n' | 354 ' },\n' |
411 ' #i: const Declaration(#i, int),\n' | 355 ' }));\n'); |
412 ' #j: const Declaration(#j, int),\n' | |
413 ' },\n' | |
414 ' }));\n'); | |
415 | |
416 }); | 356 }); |
417 | 357 |
418 test('only properties', () { | 358 test('only properties', () { |
419 var options = new QueryOptions(includeFields: false); | 359 var options = new QueryOptions(includeFields: false); |
420 var lib = provider.libraryFor('/common.dart'); | 360 var lib = provider.libraryFor('/common.dart'); |
421 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); | 361 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
422 checkResults(generator, | 362 checkResults(generator, |
423 imports: [ | 363 imports: ["import '/common.dart' as smoke_0;",], |
424 "import '/common.dart' as smoke_0;", | 364 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
425 ], | 365 ' checkedMode: false,\n' |
426 initCall: | 366 ' declarations: {\n' |
427 'useGeneratedCode(new StaticConfiguration(\n' | 367 ' smoke_0.A: {\n' |
428 ' checkedMode: false,\n' | 368 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
429 ' declarations: {\n' | 369 ' },\n' |
430 ' smoke_0.A: {\n' | 370 ' }));\n'); |
431 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | |
432 ' },\n' | |
433 ' }));\n'); | |
434 | |
435 }); | 371 }); |
436 | 372 |
437 test('fields, properties, and and methods', () { | 373 test('fields, properties, and and methods', () { |
438 var options = new QueryOptions(includeMethods: true); | 374 var options = new QueryOptions(includeMethods: true); |
439 var lib = provider.libraryFor('/common.dart'); | 375 var lib = provider.libraryFor('/common.dart'); |
440 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); | 376 recorder.runQuery(lib.getType('A'), options, includeAccessors: false); |
441 checkResults(generator, | 377 checkResults(generator, |
442 imports: [ | 378 imports: ["import '/common.dart' as smoke_0;",], |
443 "import '/common.dart' as smoke_0;", | 379 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
444 ], | 380 ' checkedMode: false,\n' |
445 initCall: | 381 ' declarations: {\n' |
446 'useGeneratedCode(new StaticConfiguration(\n' | 382 ' smoke_0.A: {\n' |
447 ' checkedMode: false,\n' | 383 ' #i: const Declaration(#i, int),\n' |
448 ' declarations: {\n' | 384 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' |
449 ' smoke_0.A: {\n' | 385 ' #inc1: const Declaration(#inc1, Function, kind: METHOD),\n' |
450 ' #i: const Declaration(#i, int),\n' | 386 ' #inc2: const Declaration(#inc2, Function, kind: METHOD),\n' |
451 ' #inc0: const Declaration(#inc0, Function, kind: METHOD),\n' | 387 ' #j: const Declaration(#j, int),\n' |
452 ' #inc1: const Declaration(#inc1, Function, kind: METHOD),\n' | 388 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
453 ' #inc2: const Declaration(#inc2, Function, kind: METHOD),\n' | 389 ' },\n' |
454 ' #j: const Declaration(#j, int),\n' | 390 ' }));\n'); |
455 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | |
456 ' },\n' | |
457 ' }));\n'); | |
458 }); | 391 }); |
459 | 392 |
460 test('exclude inherited', () { | 393 test('exclude inherited', () { |
461 var options = new QueryOptions(includeInherited: false); | 394 var options = new QueryOptions(includeInherited: false); |
462 var lib = provider.libraryFor('/common.dart'); | 395 var lib = provider.libraryFor('/common.dart'); |
463 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); | 396 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); |
464 checkResults(generator, | 397 checkResults(generator, |
465 imports: [ | 398 imports: ["import '/common.dart' as smoke_0;",], |
466 "import '/common.dart' as smoke_0;", | 399 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
467 ], | 400 ' checkedMode: false,\n' |
468 initCall: | 401 ' declarations: {\n' |
469 'useGeneratedCode(new StaticConfiguration(\n' | 402 ' smoke_0.D: {\n' |
470 ' checkedMode: false,\n' | 403 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' |
471 ' declarations: {\n' | 404 'isFinal: true),\n' |
472 ' smoke_0.D: {\n' | 405 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' |
473 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' | 406 'isFinal: true),\n' |
474 'isFinal: true),\n' | 407 ' },\n' |
475 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' | 408 ' }));\n'); |
476 'isFinal: true),\n' | |
477 ' },\n' | |
478 ' }));\n'); | |
479 }); | 409 }); |
480 | 410 |
481 test('include inherited', () { | 411 test('include inherited', () { |
482 var options = new QueryOptions(includeInherited: true); | 412 var options = new QueryOptions(includeInherited: true); |
483 var lib = provider.libraryFor('/common.dart'); | 413 var lib = provider.libraryFor('/common.dart'); |
484 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); | 414 recorder.runQuery(lib.getType('D'), options, includeAccessors: false); |
485 checkResults(generator, | 415 checkResults(generator, |
486 imports: [ | 416 imports: ["import '/common.dart' as smoke_0;",], |
487 "import '/common.dart' as smoke_0;", | |
488 ], | |
489 topLevel: 'abstract class _M0 {} // C & A\n', | 417 topLevel: 'abstract class _M0 {} // C & A\n', |
490 initCall: | 418 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
491 'useGeneratedCode(new StaticConfiguration(\n' | 419 ' checkedMode: false,\n' |
492 ' checkedMode: false,\n' | 420 ' parents: {\n' |
493 ' parents: {\n' | 421 ' smoke_0.D: _M0,\n' |
494 ' smoke_0.D: _M0,\n' | 422 ' _M0: smoke_0.C,\n' |
495 ' _M0: smoke_0.C,\n' | 423 ' },\n' |
496 ' },\n' | 424 ' declarations: {\n' |
497 ' declarations: {\n' | 425 ' smoke_0.C: {\n' |
498 ' smoke_0.C: {\n' | 426 ' #b: const Declaration(#b, smoke_0.B),\n' |
499 ' #b: const Declaration(#b, smoke_0.B),\n' | 427 ' #x: const Declaration(#x, int),\n' |
500 ' #x: const Declaration(#x, int),\n' | 428 ' #y: const Declaration(#y, String),\n' |
501 ' #y: const Declaration(#y, String),\n' | 429 ' },\n' |
502 ' },\n' | 430 ' smoke_0.D: {\n' |
503 ' smoke_0.D: {\n' | 431 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' |
504 ' #i2: const Declaration(#i2, int, kind: PROPERTY, ' | 432 'isFinal: true),\n' |
505 'isFinal: true),\n' | 433 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' |
506 ' #x2: const Declaration(#x2, int, kind: PROPERTY, ' | 434 'isFinal: true),\n' |
507 'isFinal: true),\n' | 435 ' },\n' |
508 ' },\n' | 436 ' _M0: {\n' |
509 ' _M0: {\n' | 437 ' #i: const Declaration(#i, int),\n' |
510 ' #i: const Declaration(#i, int),\n' | 438 ' #j: const Declaration(#j, int),\n' |
511 ' #j: const Declaration(#j, int),\n' | 439 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' |
512 ' #j2: const Declaration(#j2, int, kind: PROPERTY),\n' | 440 ' },\n' |
513 ' },\n' | 441 ' }));\n'); |
514 ' }));\n'); | |
515 }); | 442 }); |
516 | 443 |
517 test('exact annotation', () { | 444 test('exact annotation', () { |
518 var lib = provider.libraryFor('/common.dart'); | 445 var lib = provider.libraryFor('/common.dart'); |
519 var vars = lib.definingCompilationUnit.topLevelVariables; | 446 var vars = lib.definingCompilationUnit.topLevelVariables; |
520 expect(vars[0].name, 'a1'); | 447 expect(vars[0].name, 'a1'); |
521 var options = new QueryOptions(includeInherited: true, | 448 var options = |
522 withAnnotations: [vars[0]]); | 449 new QueryOptions(includeInherited: true, withAnnotations: [vars[0]]); |
523 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); | 450 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); |
524 final annot = 'annotations: const [smoke_0.a1]'; | 451 final annot = 'annotations: const [smoke_0.a1]'; |
525 checkResults(generator, | 452 checkResults(generator, |
526 imports: [ | 453 imports: ["import '/common.dart' as smoke_0;",], |
527 "import '/common.dart' as smoke_0;", | 454 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
528 ], | 455 ' checkedMode: false,\n' |
529 initCall: | 456 ' parents: {\n' |
530 'useGeneratedCode(new StaticConfiguration(\n' | 457 ' smoke_0.H: smoke_0.G,\n' |
531 ' checkedMode: false,\n' | 458 ' },\n' |
532 ' parents: {\n' | 459 ' declarations: {\n' |
533 ' smoke_0.H: smoke_0.G,\n' | 460 ' smoke_0.G: {\n' |
534 ' },\n' | 461 ' #b: const Declaration(#b, int, $annot),\n' |
535 ' declarations: {\n' | 462 ' },\n' |
536 ' smoke_0.G: {\n' | 463 ' smoke_0.H: {\n' |
537 ' #b: const Declaration(#b, int, $annot),\n' | 464 ' #f: const Declaration(#f, int, $annot),\n' |
538 ' },\n' | 465 ' #g: const Declaration(#g, int, $annot),\n' |
539 ' smoke_0.H: {\n' | 466 ' },\n' |
540 ' #f: const Declaration(#f, int, $annot),\n' | 467 ' }));\n'); |
541 ' #g: const Declaration(#g, int, $annot),\n' | |
542 ' },\n' | |
543 ' }));\n'); | |
544 }); | 468 }); |
545 | 469 |
546 test('type annotation', () { | 470 test('type annotation', () { |
547 var lib = provider.libraryFor('/common.dart'); | 471 var lib = provider.libraryFor('/common.dart'); |
548 var options = new QueryOptions(includeInherited: true, | 472 var options = new QueryOptions( |
549 withAnnotations: [lib.getType('Annot')]); | 473 includeInherited: true, withAnnotations: [lib.getType('Annot')]); |
550 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); | 474 recorder.runQuery(lib.getType('H'), options, includeAccessors: false); |
551 final a1Annot = 'annotations: const [smoke_0.a1]'; | 475 final a1Annot = 'annotations: const [smoke_0.a1]'; |
552 final a3Annot = 'annotations: const [smoke_0.a3]'; | 476 final a3Annot = 'annotations: const [smoke_0.a3]'; |
553 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; | 477 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; |
554 checkResults(generator, | 478 checkResults(generator, |
555 imports: [ | 479 imports: ["import '/common.dart' as smoke_0;",], |
556 "import '/common.dart' as smoke_0;", | 480 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
557 ], | 481 ' checkedMode: false,\n' |
558 initCall: | 482 ' parents: {\n' |
559 'useGeneratedCode(new StaticConfiguration(\n' | 483 ' smoke_0.H: smoke_0.G,\n' |
560 ' checkedMode: false,\n' | 484 ' },\n' |
561 ' parents: {\n' | 485 ' declarations: {\n' |
562 ' smoke_0.H: smoke_0.G,\n' | 486 ' smoke_0.G: {\n' |
563 ' },\n' | 487 ' #b: const Declaration(#b, int, $a1Annot),\n' |
564 ' declarations: {\n' | 488 ' },\n' |
565 ' smoke_0.G: {\n' | 489 ' smoke_0.H: {\n' |
566 ' #b: const Declaration(#b, int, $a1Annot),\n' | 490 ' #f: const Declaration(#f, int, $a1Annot),\n' |
567 ' },\n' | 491 ' #g: const Declaration(#g, int, $a1Annot),\n' |
568 ' smoke_0.H: {\n' | 492 ' #i: const Declaration(#i, int, $a3Annot),\n' |
569 ' #f: const Declaration(#f, int, $a1Annot),\n' | 493 ' #j: const Declaration(#j, int, $exprAnnot),\n' |
570 ' #g: const Declaration(#g, int, $a1Annot),\n' | 494 ' },\n' |
571 ' #i: const Declaration(#i, int, $a3Annot),\n' | 495 ' }));\n'); |
572 ' #j: const Declaration(#j, int, $exprAnnot),\n' | |
573 ' },\n' | |
574 ' }));\n'); | |
575 }); | 496 }); |
576 | 497 |
577 test('type annotation with named arguments', () { | 498 test('type annotation with named arguments', () { |
578 var lib = provider.libraryFor('/common.dart'); | 499 var lib = provider.libraryFor('/common.dart'); |
579 var options = new QueryOptions(includeInherited: true, | 500 var options = new QueryOptions( |
580 withAnnotations: [lib.getType('AnnotC')]); | 501 includeInherited: true, withAnnotations: [lib.getType('AnnotC')]); |
581 recorder.runQuery(lib.getType('K'), options, includeAccessors: false); | 502 recorder.runQuery(lib.getType('K'), options, includeAccessors: false); |
582 final kAnnot = 'annotations: const [const smoke_0.AnnotC(named: true)]'; | 503 final kAnnot = 'annotations: const [const smoke_0.AnnotC(named: true)]'; |
583 final k2Annot = 'annotations: const [const smoke_0.AnnotC()]'; | 504 final k2Annot = 'annotations: const [const smoke_0.AnnotC()]'; |
584 checkResults(generator, | 505 checkResults(generator, |
585 imports: [ | 506 imports: ["import '/common.dart' as smoke_0;",], |
586 "import '/common.dart' as smoke_0;", | 507 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
587 ], | 508 ' checkedMode: false,\n' |
588 initCall: | 509 ' declarations: {\n' |
589 'useGeneratedCode(new StaticConfiguration(\n' | 510 ' smoke_0.K: {\n' |
590 ' checkedMode: false,\n' | 511 ' #k: const Declaration(#k, int, $kAnnot),\n' |
591 ' declarations: {\n' | 512 ' #k2: const Declaration(#k2, int, $k2Annot),\n' |
592 ' smoke_0.K: {\n' | 513 ' },\n' |
593 ' #k: const Declaration(#k, int, $kAnnot),\n' | 514 ' }));\n'); |
594 ' #k2: const Declaration(#k2, int, $k2Annot),\n' | |
595 ' },\n' | |
596 ' }));\n'); | |
597 }); | 515 }); |
598 }); | 516 }); |
599 | 517 |
600 group('with accessors', () { | 518 group('with accessors', () { |
601 test('lookup member', () { | 519 test('lookup member', () { |
602 var lib = provider.libraryFor('/common.dart'); | 520 var lib = provider.libraryFor('/common.dart'); |
603 recorder.lookupMember(lib.getType('I'), 'i1'); | 521 recorder.lookupMember(lib.getType('I'), 'i1'); |
604 recorder.lookupMember(lib.getType('I'), 'i2'); | 522 recorder.lookupMember(lib.getType('I'), 'i2'); |
605 recorder.lookupMember(lib.getType('I'), 'i3'); | 523 recorder.lookupMember(lib.getType('I'), 'i3'); |
606 recorder.lookupMember(lib.getType('I'), 'm4'); | 524 recorder.lookupMember(lib.getType('I'), 'm4'); |
607 checkResults(generator, | 525 checkResults(generator, |
608 imports: [ | 526 imports: ["import '/common.dart' as smoke_0;",], |
609 "import '/common.dart' as smoke_0;", | 527 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
610 ], | 528 ' checkedMode: false,\n' |
611 initCall: | 529 ' getters: {\n' |
612 'useGeneratedCode(new StaticConfiguration(\n' | 530 ' #i1: (o) => o.i1,\n' |
613 ' checkedMode: false,\n' | 531 ' #i2: (o) => o.i2,\n' |
614 ' getters: {\n' | 532 ' #i3: (o) => o.i3,\n' |
615 ' #i1: (o) => o.i1,\n' | 533 ' #m4: (o) => o.m4,\n' |
616 ' #i2: (o) => o.i2,\n' | 534 ' },\n' |
617 ' #i3: (o) => o.i3,\n' | 535 ' setters: {\n' // #i3 is final |
618 ' #m4: (o) => o.m4,\n' | 536 ' #i1: (o, v) { o.i1 = v; },\n' |
619 ' },\n' | 537 ' #i2: (o, v) { o.i2 = v; },\n' |
620 ' setters: {\n' // #i3 is final | 538 ' },\n' |
621 ' #i1: (o, v) { o.i1 = v; },\n' | 539 ' declarations: {\n' |
622 ' #i2: (o, v) { o.i2 = v; },\n' | 540 ' smoke_0.I: {\n' |
623 ' },\n' | 541 ' #i1: const Declaration(#i1, dynamic),\n' |
624 ' declarations: {\n' | 542 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' |
625 ' smoke_0.I: {\n' | 543 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' |
626 ' #i1: const Declaration(#i1, dynamic),\n' | 544 'isFinal: true),\n' |
627 ' #i2: const Declaration(#i2, dynamic, kind: PROPERTY),\n' | 545 ' #m4: const Declaration(#m4, Function, kind: METHOD),\n' |
628 ' #i3: const Declaration(#i3, smoke_0.G, kind: PROPERTY, ' | 546 ' },\n' |
629 'isFinal: true),\n' | 547 ' },\n' |
630 ' #m4: const Declaration(#m4, Function, kind: METHOD),\n' | 548 ' names: {\n' |
631 ' },\n' | 549 ' #i1: r\'i1\',\n' |
632 ' },\n' | 550 ' #i2: r\'i2\',\n' |
633 ' names: {\n' | 551 ' #i3: r\'i3\',\n' |
634 ' #i1: r\'i1\',\n' | 552 ' #m4: r\'m4\',\n' |
635 ' #i2: r\'i2\',\n' | 553 ' }));\n'); |
636 ' #i3: r\'i3\',\n' | |
637 ' #m4: r\'m4\',\n' | |
638 ' }));\n'); | |
639 }); | 554 }); |
640 | 555 |
641 test('static members', () { | 556 test('static members', () { |
642 var lib = provider.libraryFor('/common.dart'); | 557 var lib = provider.libraryFor('/common.dart'); |
643 recorder.lookupMember(lib.getType('A'), 'sI'); | 558 recorder.lookupMember(lib.getType('A'), 'sI'); |
644 recorder.lookupMember(lib.getType('A'), 'sJ'); | 559 recorder.lookupMember(lib.getType('A'), 'sJ'); |
645 recorder.lookupMember(lib.getType('A'), 'sM'); | 560 recorder.lookupMember(lib.getType('A'), 'sM'); |
646 final pDetails = 'kind: PROPERTY, isFinal: true, isStatic: true'; | 561 final pDetails = 'kind: PROPERTY, isFinal: true, isStatic: true'; |
647 const mDetails = 'kind: METHOD, isStatic: true'; | 562 const mDetails = 'kind: METHOD, isStatic: true'; |
648 checkResults(generator, | 563 checkResults(generator, |
649 imports: [ | 564 imports: ["import '/common.dart' as smoke_0;",], |
650 "import '/common.dart' as smoke_0;", | 565 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
651 ], | 566 ' checkedMode: false,\n' |
652 initCall: | 567 ' declarations: {\n' |
653 'useGeneratedCode(new StaticConfiguration(\n' | 568 ' smoke_0.A: {\n' |
654 ' checkedMode: false,\n' | 569 ' #sI: const Declaration(#sI, int, isStatic: true),\n' |
655 ' declarations: {\n' | 570 ' #sJ: const Declaration(#sJ, int, $pDetails),\n' |
656 ' smoke_0.A: {\n' | 571 ' #sM: const Declaration(#sM, Function, $mDetails),\n' |
657 ' #sI: const Declaration(#sI, int, isStatic: true),\n' | 572 ' },\n' |
658 ' #sJ: const Declaration(#sJ, int, $pDetails),\n' | 573 ' },\n' |
659 ' #sM: const Declaration(#sM, Function, $mDetails),\n' | 574 ' staticMethods: {\n' |
660 ' },\n' | 575 ' smoke_0.A: {\n' |
661 ' },\n' | 576 ' #sM: smoke_0.A.sM,\n' |
662 ' staticMethods: {\n' | 577 ' },\n' |
663 ' smoke_0.A: {\n' | 578 ' },\n' |
664 ' #sM: smoke_0.A.sM,\n' | 579 ' names: {\n' |
665 ' },\n' | 580 ' #sM: r\'sM\',\n' |
666 ' },\n' | 581 ' }));\n'); |
667 ' names: {\n' | |
668 ' #sM: r\'sM\',\n' | |
669 ' }));\n'); | |
670 }); | 582 }); |
671 | 583 |
672 test('query', () { | 584 test('query', () { |
673 var lib = provider.libraryFor('/common.dart'); | 585 var lib = provider.libraryFor('/common.dart'); |
674 var options = new QueryOptions(includeInherited: true, | 586 var options = new QueryOptions( |
675 withAnnotations: [lib.getType('Annot')]); | 587 includeInherited: true, withAnnotations: [lib.getType('Annot')]); |
676 recorder.runQuery(lib.getType('H'), options); | 588 recorder.runQuery(lib.getType('H'), options); |
677 final a1Annot = 'annotations: const [smoke_0.a1]'; | 589 final a1Annot = 'annotations: const [smoke_0.a1]'; |
678 final a3Annot = 'annotations: const [smoke_0.a3]'; | 590 final a3Annot = 'annotations: const [smoke_0.a3]'; |
679 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; | 591 final exprAnnot = 'annotations: const [const smoke_0.Annot(1)]'; |
680 checkResults(generator, | 592 checkResults(generator, |
681 imports: [ | 593 imports: ["import '/common.dart' as smoke_0;",], |
682 "import '/common.dart' as smoke_0;", | 594 initCall: 'useGeneratedCode(new StaticConfiguration(\n' |
683 ], | 595 ' checkedMode: false,\n' |
684 initCall: | 596 ' getters: {\n' |
685 'useGeneratedCode(new StaticConfiguration(\n' | 597 ' #b: (o) => o.b,\n' |
686 ' checkedMode: false,\n' | 598 ' #f: (o) => o.f,\n' |
687 ' getters: {\n' | 599 ' #g: (o) => o.g,\n' |
688 ' #b: (o) => o.b,\n' | 600 ' #i: (o) => o.i,\n' |
689 ' #f: (o) => o.f,\n' | 601 ' #j: (o) => o.j,\n' |
690 ' #g: (o) => o.g,\n' | 602 ' },\n' |
691 ' #i: (o) => o.i,\n' | 603 ' setters: {\n' // #i3 is final |
692 ' #j: (o) => o.j,\n' | 604 ' #b: (o, v) { o.b = v; },\n' |
693 ' },\n' | 605 ' #f: (o, v) { o.f = v; },\n' |
694 ' setters: {\n' // #i3 is final | 606 ' #g: (o, v) { o.g = v; },\n' |
695 ' #b: (o, v) { o.b = v; },\n' | 607 ' #i: (o, v) { o.i = v; },\n' |
696 ' #f: (o, v) { o.f = v; },\n' | 608 ' #j: (o, v) { o.j = v; },\n' |
697 ' #g: (o, v) { o.g = v; },\n' | 609 ' },\n' |
698 ' #i: (o, v) { o.i = v; },\n' | 610 ' parents: {\n' |
699 ' #j: (o, v) { o.j = v; },\n' | 611 ' smoke_0.H: smoke_0.G,\n' |
700 ' },\n' | 612 ' },\n' |
701 ' parents: {\n' | 613 ' declarations: {\n' |
702 ' smoke_0.H: smoke_0.G,\n' | 614 ' smoke_0.G: {\n' |
703 ' },\n' | 615 ' #b: const Declaration(#b, int, $a1Annot),\n' |
704 ' declarations: {\n' | 616 ' },\n' |
705 ' smoke_0.G: {\n' | 617 ' smoke_0.H: {\n' |
706 ' #b: const Declaration(#b, int, $a1Annot),\n' | 618 ' #f: const Declaration(#f, int, $a1Annot),\n' |
707 ' },\n' | 619 ' #g: const Declaration(#g, int, $a1Annot),\n' |
708 ' smoke_0.H: {\n' | 620 ' #i: const Declaration(#i, int, $a3Annot),\n' |
709 ' #f: const Declaration(#f, int, $a1Annot),\n' | 621 ' #j: const Declaration(#j, int, $exprAnnot),\n' |
710 ' #g: const Declaration(#g, int, $a1Annot),\n' | 622 ' },\n' |
711 ' #i: const Declaration(#i, int, $a3Annot),\n' | 623 ' },\n' |
712 ' #j: const Declaration(#j, int, $exprAnnot),\n' | 624 ' names: {\n' |
713 ' },\n' | 625 ' #b: r\'b\',\n' |
714 ' },\n' | 626 ' #f: r\'f\',\n' |
715 ' names: {\n' | 627 ' #g: r\'g\',\n' |
716 ' #b: r\'b\',\n' | 628 ' #i: r\'i\',\n' |
717 ' #f: r\'f\',\n' | 629 ' #j: r\'j\',\n' |
718 ' #g: r\'g\',\n' | 630 ' }));\n'); |
719 ' #i: r\'i\',\n' | |
720 ' #j: r\'j\',\n' | |
721 ' }));\n'); | |
722 }); | 631 }); |
723 }); | 632 }); |
724 } | 633 } |
725 | 634 |
726 const _SOURCES = const { | 635 const _SOURCES = const { |
727 '/a.dart': ''' | 636 '/a.dart': ''' |
728 library a; | 637 library a; |
729 import '/b.dart'; | 638 import '/b.dart'; |
730 | 639 |
731 class Annot { const Annot(); } | 640 class Annot { const Annot(); } |
(...skipping 10 matching lines...) Expand all Loading... |
742 class D3 { | 651 class D3 { |
743 int d3; | 652 int d3; |
744 } | 653 } |
745 class E extends A with D1 { | 654 class E extends A with D1 { |
746 int e1; | 655 int e1; |
747 } | 656 } |
748 class F extends A with D1, D2, D3 { | 657 class F extends A with D1, D2, D3 { |
749 int f1; | 658 int f1; |
750 } | 659 } |
751 ''', | 660 ''', |
752 | |
753 '/b.dart': ''' | 661 '/b.dart': ''' |
754 library b; | 662 library b; |
755 | 663 |
756 class B {} | 664 class B {} |
757 ''', | 665 ''', |
758 '/common.dart': ''' | 666 '/common.dart': ''' |
759 library common; | 667 library common; |
760 | 668 |
761 class A { | 669 class A { |
762 int i = 42; | 670 int i = 42; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 | 771 |
864 class K { | 772 class K { |
865 @AnnotC(named: true) int k; | 773 @AnnotC(named: true) int k; |
866 @AnnotC() int k2; | 774 @AnnotC() int k2; |
867 } | 775 } |
868 ''' | 776 ''' |
869 }; | 777 }; |
870 | 778 |
871 resolveImportUrl(LibraryElement lib) => | 779 resolveImportUrl(LibraryElement lib) => |
872 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; | 780 lib.isDartCore ? 'dart:core' : '/${lib.displayName}.dart'; |
OLD | NEW |