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 'package:compiler/src/commandline_options.dart'; | 6 import 'package:compiler/src/commandline_options.dart'; |
7 import 'package:compiler/src/common.dart'; | 7 import 'package:compiler/src/common.dart'; |
8 import 'package:compiler/src/common_elements.dart'; | 8 import 'package:compiler/src/common_elements.dart'; |
9 import 'package:compiler/src/compiler.dart'; | 9 import 'package:compiler/src/compiler.dart'; |
10 import 'package:compiler/src/elements/entities.dart'; | 10 import 'package:compiler/src/elements/entities.dart'; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 annotatedCode, computeMemberData, compileFunction, | 177 annotatedCode, computeMemberData, compileFunction, |
178 options: options, verbose: verbose); | 178 options: options, verbose: verbose); |
179 | 179 |
180 data.actualMap.forEach((Id id, ActualData actualData) { | 180 data.actualMap.forEach((Id id, ActualData actualData) { |
181 String actual = actualData.value; | 181 String actual = actualData.value; |
182 if (!data.expectedMap.containsKey(id)) { | 182 if (!data.expectedMap.containsKey(id)) { |
183 if (actual != '') { | 183 if (actual != '') { |
184 reportHere( | 184 reportHere( |
185 data.compiler.reporter, | 185 data.compiler.reporter, |
186 actualData.sourceSpan, | 186 actualData.sourceSpan, |
187 'Id $id for ${actualData.object} ' | 187 'Id $id = ${actual} for ${actualData.object} ' |
188 '(${actualData.object.runtimeType}) ' | 188 '(${actualData.object.runtimeType}) ' |
189 'not expected in ${data.expectedMap.keys}'); | 189 'not expected in ${data.expectedMap.keys}'); |
190 print('--annotations diff--------------------------------------------'); | 190 print('--annotations diff--------------------------------------------'); |
191 print(data.diffCode); | 191 print(data.diffCode); |
192 print('--------------------------------------------------------------'); | 192 print('--------------------------------------------------------------'); |
193 } | 193 } |
194 Expect.equals('', actual); | 194 Expect.equals('', actual); |
195 } else { | 195 } else { |
196 String expected = data.expectedMap.remove(id); | 196 String expected = data.expectedMap[id]; |
197 if (actual != expected) { | 197 if (actual != expected) { |
198 reportHere( | 198 reportHere( |
199 data.compiler.reporter, | 199 data.compiler.reporter, |
200 actualData.sourceSpan, | 200 actualData.sourceSpan, |
201 'Object: ${actualData.object} (${actualData.object.runtimeType}), ' | 201 'Object: ${actualData.object} (${actualData.object.runtimeType}), ' |
202 'expected: ${expected}, actual: ${actual}'); | 202 'expected: ${expected}, actual: ${actual}'); |
203 print('--annotations diff--------------------------------------------'); | 203 print('--annotations diff--------------------------------------------'); |
204 print(data.diffCode); | 204 print(data.diffCode); |
205 print('--------------------------------------------------------------'); | 205 print('--------------------------------------------------------------'); |
206 } | 206 } |
207 Expect.equals(expected, actual); | 207 Expect.equals(expected, actual); |
208 } | 208 } |
209 }); | 209 }); |
210 | 210 |
| 211 Set<Id> missingIds = new Set<Id>(); |
211 data.expectedMap.forEach((Id id, String expected) { | 212 data.expectedMap.forEach((Id id, String expected) { |
212 reportHere( | 213 if (!data.actualMap.containsKey(id)) { |
213 data.compiler.reporter, | 214 missingIds.add(id); |
214 computeSpannable(data.elementEnvironment, data.mainUri, id), | 215 reportHere( |
215 'Expected $expected for id $id missing in ${data.actualMap.keys}'); | 216 data.compiler.reporter, |
| 217 computeSpannable(data.elementEnvironment, data.mainUri, id), |
| 218 'Expected $expected for id $id missing in ${data.actualMap.keys}'); |
| 219 } |
216 }); | 220 }); |
217 Expect.isTrue( | 221 Expect.isTrue(missingIds.isEmpty, "Ids not found: ${missingIds}."); |
218 data.expectedMap.isEmpty, "Ids not found: ${data.expectedMap}."); | |
219 } | 222 } |
220 | 223 |
221 /// Compute a [Spannable] from an [id] in the library [mainUri]. | 224 /// Compute a [Spannable] from an [id] in the library [mainUri]. |
222 Spannable computeSpannable( | 225 Spannable computeSpannable( |
223 ElementEnvironment elementEnvironment, Uri mainUri, Id id) { | 226 ElementEnvironment elementEnvironment, Uri mainUri, Id id) { |
224 if (id is NodeId) { | 227 if (id is NodeId) { |
225 return new SourceSpan(mainUri, id.value, id.value + 1); | 228 return new SourceSpan(mainUri, id.value, id.value + 1); |
226 } else if (id is ElementId) { | 229 } else if (id is ElementId) { |
227 LibraryEntity library = elementEnvironment.lookupLibrary(mainUri); | 230 LibraryEntity library = elementEnvironment.lookupLibrary(mainUri); |
228 if (id.className != null) { | 231 if (id.className != null) { |
(...skipping 19 matching lines...) Expand all Loading... |
248 id = new NodeId(annotation.offset); | 251 id = new NodeId(annotation.offset); |
249 expected = text; | 252 expected = text; |
250 } else { | 253 } else { |
251 id = new ElementId(text.substring(0, colonPos)); | 254 id = new ElementId(text.substring(0, colonPos)); |
252 expected = text.substring(colonPos + 1); | 255 expected = text.substring(colonPos + 1); |
253 } | 256 } |
254 map[id] = expected; | 257 map[id] = expected; |
255 } | 258 } |
256 return map; | 259 return map; |
257 } | 260 } |
OLD | NEW |