OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 | 7 |
8 import 'package:compiler/src/common.dart'; | 8 import 'package:compiler/src/common.dart'; |
9 import 'package:compiler/src/common_elements.dart'; | 9 import 'package:compiler/src/common_elements.dart'; |
10 import 'package:compiler/src/compiler.dart'; | 10 import 'package:compiler/src/compiler.dart'; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 annotatedCode, computeMemberData, compileFunction, | 204 annotatedCode, computeMemberData, compileFunction, |
205 options: options, verbose: verbose); | 205 options: options, verbose: verbose); |
206 | 206 |
207 data.actualMap.forEach((Id id, ActualData actualData) { | 207 data.actualMap.forEach((Id id, ActualData actualData) { |
208 String actual = actualData.value; | 208 String actual = actualData.value; |
209 if (!data.expectedMap.containsKey(id)) { | 209 if (!data.expectedMap.containsKey(id)) { |
210 if (actual != '') { | 210 if (actual != '') { |
211 reportHere( | 211 reportHere( |
212 data.compiler.reporter, | 212 data.compiler.reporter, |
213 actualData.sourceSpan, | 213 actualData.sourceSpan, |
214 'Id $id for ${actualData.object} ' | 214 'Id $id = ${actual} for ${actualData.object} ' |
215 '(${actualData.object.runtimeType}) ' | 215 '(${actualData.object.runtimeType}) ' |
216 'not expected in ${data.expectedMap.keys}'); | 216 'not expected in ${data.expectedMap.keys}'); |
217 print('--annotations diff--------------------------------------------'); | 217 print('--annotations diff--------------------------------------------'); |
218 print(data.diffCode); | 218 print(data.diffCode); |
219 print('--------------------------------------------------------------'); | 219 print('--------------------------------------------------------------'); |
220 } | 220 } |
221 Expect.equals('', actual); | 221 Expect.equals('', actual); |
222 } else { | 222 } else { |
223 String expected = data.expectedMap.remove(id); | 223 String expected = data.expectedMap[id]; |
224 if (actual != expected) { | 224 if (actual != expected) { |
225 reportHere( | 225 reportHere( |
226 data.compiler.reporter, | 226 data.compiler.reporter, |
227 actualData.sourceSpan, | 227 actualData.sourceSpan, |
228 'Object: ${actualData.object} (${actualData.object.runtimeType}), ' | 228 'Object: ${actualData.object} (${actualData.object.runtimeType}), ' |
229 'expected: ${expected}, actual: ${actual}'); | 229 'expected: ${expected}, actual: ${actual}'); |
230 print('--annotations diff--------------------------------------------'); | 230 print('--annotations diff--------------------------------------------'); |
231 print(data.diffCode); | 231 print(data.diffCode); |
232 print('--------------------------------------------------------------'); | 232 print('--------------------------------------------------------------'); |
233 } | 233 } |
234 Expect.equals(expected, actual); | 234 Expect.equals(expected, actual); |
235 } | 235 } |
236 }); | 236 }); |
237 | 237 |
| 238 Set<Id> missingIds = new Set<Id>(); |
238 data.expectedMap.forEach((Id id, String expected) { | 239 data.expectedMap.forEach((Id id, String expected) { |
239 reportHere( | 240 if (!data.actualMap.containsKey(id)) { |
240 data.compiler.reporter, | 241 missingIds.add(id); |
241 computeSpannable(data.elementEnvironment, data.mainUri, id), | 242 reportHere( |
242 'Expected $expected for id $id missing in ${data.actualMap.keys}'); | 243 data.compiler.reporter, |
| 244 computeSpannable(data.elementEnvironment, data.mainUri, id), |
| 245 'Expected $expected for id $id missing in ${data.actualMap.keys}'); |
| 246 } |
243 }); | 247 }); |
244 Expect.isTrue( | 248 Expect.isTrue(missingIds.isEmpty, "Ids not found: ${missingIds}."); |
245 data.expectedMap.isEmpty, "Ids not found: ${data.expectedMap}."); | |
246 } | 249 } |
247 | 250 |
248 /// Compute a [Spannable] from an [id] in the library [mainUri]. | 251 /// Compute a [Spannable] from an [id] in the library [mainUri]. |
249 Spannable computeSpannable( | 252 Spannable computeSpannable( |
250 ElementEnvironment elementEnvironment, Uri mainUri, Id id) { | 253 ElementEnvironment elementEnvironment, Uri mainUri, Id id) { |
251 if (id is NodeId) { | 254 if (id is NodeId) { |
252 return new SourceSpan(mainUri, id.value, id.value + 1); | 255 return new SourceSpan(mainUri, id.value, id.value + 1); |
253 } else if (id is ElementId) { | 256 } else if (id is ElementId) { |
254 LibraryEntity library = elementEnvironment.lookupLibrary(mainUri); | 257 LibraryEntity library = elementEnvironment.lookupLibrary(mainUri); |
255 if (id.className != null) { | 258 if (id.className != null) { |
(...skipping 19 matching lines...) Expand all Loading... |
275 id = new NodeId(annotation.offset); | 278 id = new NodeId(annotation.offset); |
276 expected = text; | 279 expected = text; |
277 } else { | 280 } else { |
278 id = new ElementId(text.substring(0, colonPos)); | 281 id = new ElementId(text.substring(0, colonPos)); |
279 expected = text.substring(colonPos + 1); | 282 expected = text.substring(colonPos + 1); |
280 } | 283 } |
281 map[id] = expected; | 284 map[id] = expected; |
282 } | 285 } |
283 return map; | 286 return map; |
284 } | 287 } |
OLD | NEW |