| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
| 6 | 6 |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 compareElements(r.element, expectedElement, desc); | 418 compareElements(r.element, expectedElement, desc); |
| 419 // elementAnnotation should be null; it is only used in the full AST. | 419 // elementAnnotation should be null; it is only used in the full AST. |
| 420 expect(o.elementAnnotation, isNull); | 420 expect(o.elementAnnotation, isNull); |
| 421 expect(r.elementAnnotation, isNull); | 421 expect(r.elementAnnotation, isNull); |
| 422 } else { | 422 } else { |
| 423 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); | 423 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); |
| 424 } | 424 } |
| 425 } | 425 } |
| 426 } | 426 } |
| 427 | 427 |
| 428 void compareConstructorElements(ConstructorElementImpl resynthesized, | 428 void compareConstructorElements(ConstructorElement resynthesized, |
| 429 ConstructorElementImpl original, String desc) { | 429 ConstructorElement original, String desc) { |
| 430 compareExecutableElements(resynthesized, original, desc); | 430 compareExecutableElements(resynthesized, original, desc); |
| 431 if (original.isConst) { | 431 if (original.isConst) { |
| 432 compareConstAstLists(resynthesized.constantInitializers, | 432 ConstructorElementImpl resynthesizedImpl = |
| 433 original.constantInitializers, desc); | 433 getActualElement(resynthesized, desc); |
| 434 ConstructorElementImpl originalImpl = getActualElement(original, desc); |
| 435 compareConstAstLists(resynthesizedImpl.constantInitializers, |
| 436 originalImpl.constantInitializers, desc); |
| 434 } | 437 } |
| 435 if (original.redirectedConstructor == null) { | 438 if (original.redirectedConstructor == null) { |
| 436 expect(resynthesized.redirectedConstructor, isNull, reason: desc); | 439 expect(resynthesized.redirectedConstructor, isNull, reason: desc); |
| 437 } else { | 440 } else { |
| 438 compareElements(resynthesized.redirectedConstructor, | 441 compareConstructorElements(resynthesized.redirectedConstructor, |
| 439 original.redirectedConstructor, desc); | 442 original.redirectedConstructor, '$desc redirectedConstructor'); |
| 443 } |
| 444 ConstructorElement resynthesizedNonHandle = |
| 445 resynthesized is ConstructorElementHandle |
| 446 ? resynthesized.actualElement |
| 447 : resynthesized; |
| 448 if (original is ConstructorMember) { |
| 449 expect(resynthesizedNonHandle, new isInstanceOf<ConstructorMember>(), |
| 450 reason: desc); |
| 451 if (resynthesizedNonHandle is ConstructorMember) { |
| 452 List<DartType> resynthesizedTypeArguments = |
| 453 resynthesizedNonHandle.definingType.typeArguments; |
| 454 List<DartType> originalTypeArguments = |
| 455 original.definingType.typeArguments; |
| 456 expect( |
| 457 resynthesizedTypeArguments, hasLength(originalTypeArguments.length), |
| 458 reason: desc); |
| 459 for (int i = 0; i < originalTypeArguments.length; i++) { |
| 460 compareTypeImpls(resynthesizedTypeArguments[i], |
| 461 originalTypeArguments[i], '$desc type argument $i'); |
| 462 } |
| 463 } |
| 464 } else { |
| 465 expect( |
| 466 resynthesizedNonHandle, isNot(new isInstanceOf<ConstructorMember>()), |
| 467 reason: desc); |
| 440 } | 468 } |
| 441 } | 469 } |
| 442 | 470 |
| 443 void compareElementAnnotations(ElementAnnotationImpl resynthesized, | 471 void compareElementAnnotations(ElementAnnotationImpl resynthesized, |
| 444 ElementAnnotationImpl original, String desc) { | 472 ElementAnnotationImpl original, String desc) { |
| 445 expect(resynthesized.element, isNotNull, reason: desc); | 473 expect(resynthesized.element, isNotNull, reason: desc); |
| 446 expect(resynthesized.element.kind, original.element.kind, reason: desc); | 474 expect(resynthesized.element.kind, original.element.kind, reason: desc); |
| 447 expect(resynthesized.element.location, original.element.location, | 475 expect(resynthesized.element.location, original.element.location, |
| 448 reason: desc); | 476 reason: desc); |
| 449 expect(resynthesized.compilationUnit, isNotNull, reason: desc); | 477 expect(resynthesized.compilationUnit, isNotNull, reason: desc); |
| (...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3236 fail('Unexpectedly tried to get unlinked summary for $uri'); | 3264 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 3237 } | 3265 } |
| 3238 return serializedUnit; | 3266 return serializedUnit; |
| 3239 } | 3267 } |
| 3240 | 3268 |
| 3241 @override | 3269 @override |
| 3242 bool hasLibrarySummary(String uri) { | 3270 bool hasLibrarySummary(String uri) { |
| 3243 return true; | 3271 return true; |
| 3244 } | 3272 } |
| 3245 } | 3273 } |
| OLD | NEW |