| 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/constant/value.dart'; | 10 import 'package:analyzer/dart/constant/value.dart'; |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 if (!shallow) { | 695 if (!shallow) { |
| 696 compareTypes(resynthesized.type, original.type, desc); | 696 compareTypes(resynthesized.type, original.type, desc); |
| 697 } | 697 } |
| 698 expect(resynthesized.typeParameters.length, original.typeParameters.length); | 698 expect(resynthesized.typeParameters.length, original.typeParameters.length); |
| 699 for (int i = 0; i < resynthesized.typeParameters.length; i++) { | 699 for (int i = 0; i < resynthesized.typeParameters.length; i++) { |
| 700 compareTypeParameterElements( | 700 compareTypeParameterElements( |
| 701 resynthesized.typeParameters[i], | 701 resynthesized.typeParameters[i], |
| 702 original.typeParameters[i], | 702 original.typeParameters[i], |
| 703 '$desc type parameter ${original.typeParameters[i].name}'); | 703 '$desc type parameter ${original.typeParameters[i].name}'); |
| 704 } | 704 } |
| 705 if (original is! Member) { | 705 compareLocalElementsOfExecutable(resynthesized, original, desc); |
| 706 List<FunctionElement> rFunctions = resynthesized.functions; | |
| 707 List<FunctionElement> oFunctions = original.functions; | |
| 708 expect(rFunctions, hasLength(oFunctions.length)); | |
| 709 for (int i = 0; i < oFunctions.length; i++) { | |
| 710 compareFunctionElements(rFunctions[i], oFunctions[i], | |
| 711 '$desc local function ${oFunctions[i].name}'); | |
| 712 } | |
| 713 } | |
| 714 if (original is! Member) { | |
| 715 List<LabelElement> rLabels = resynthesized.labels; | |
| 716 List<LabelElement> oLabels = original.labels; | |
| 717 expect(rLabels, hasLength(oLabels.length)); | |
| 718 for (int i = 0; i < oLabels.length; i++) { | |
| 719 compareLabelElements( | |
| 720 rLabels[i], oLabels[i], '$desc label ${oLabels[i].name}'); | |
| 721 } | |
| 722 } | |
| 723 if (original is! Member) { | |
| 724 compareLocalVariableElementLists(resynthesized, original, desc); | |
| 725 } | |
| 726 } | 706 } |
| 727 | 707 |
| 728 void compareExportElements(ExportElementImpl resynthesized, | 708 void compareExportElements(ExportElementImpl resynthesized, |
| 729 ExportElementImpl original, String desc) { | 709 ExportElementImpl original, String desc) { |
| 730 compareUriReferencedElements(resynthesized, original, desc); | 710 compareUriReferencedElements(resynthesized, original, desc); |
| 731 expect(resynthesized.exportedLibrary.location, | 711 expect(resynthesized.exportedLibrary.location, |
| 732 original.exportedLibrary.location); | 712 original.exportedLibrary.location); |
| 733 expect(resynthesized.combinators.length, original.combinators.length); | 713 expect(resynthesized.combinators.length, original.combinators.length); |
| 734 for (int i = 0; i < resynthesized.combinators.length; i++) { | 714 for (int i = 0; i < resynthesized.combinators.length; i++) { |
| 735 compareNamespaceCombinators( | 715 compareNamespaceCombinators( |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 793 | 773 |
| 794 void compareLabelElements( | 774 void compareLabelElements( |
| 795 LabelElementImpl resynthesized, LabelElementImpl original, String desc) { | 775 LabelElementImpl resynthesized, LabelElementImpl original, String desc) { |
| 796 expect(resynthesized.isOnSwitchMember, original.isOnSwitchMember, | 776 expect(resynthesized.isOnSwitchMember, original.isOnSwitchMember, |
| 797 reason: desc); | 777 reason: desc); |
| 798 expect(resynthesized.isOnSwitchStatement, original.isOnSwitchStatement, | 778 expect(resynthesized.isOnSwitchStatement, original.isOnSwitchStatement, |
| 799 reason: desc); | 779 reason: desc); |
| 800 compareElements(resynthesized, original, desc); | 780 compareElements(resynthesized, original, desc); |
| 801 } | 781 } |
| 802 | 782 |
| 803 void compareLocalVariableElementLists(ExecutableElement resynthesized, | 783 void compareLocalElementsOfExecutable(ExecutableElement resynthesized, |
| 804 ExecutableElement original, String desc) { | 784 ExecutableElement original, String desc) { |
| 805 List<LocalVariableElement> rVariables = resynthesized.localVariables; | 785 if (original is! Member) { |
| 806 List<LocalVariableElement> oVariables = original.localVariables; | 786 List<FunctionElement> rFunctions = resynthesized.functions; |
| 807 expect(rVariables, hasLength(oVariables.length)); | 787 List<FunctionElement> oFunctions = original.functions; |
| 808 for (int i = 0; i < oVariables.length; i++) { | 788 expect(rFunctions, hasLength(oFunctions.length)); |
| 809 compareVariableElements(rVariables[i], oVariables[i], | 789 for (int i = 0; i < oFunctions.length; i++) { |
| 810 '$desc local variable ${oVariables[i].name}'); | 790 compareFunctionElements(rFunctions[i], oFunctions[i], |
| 791 '$desc local function ${oFunctions[i].name}'); |
| 792 } |
| 793 } |
| 794 if (original is! Member) { |
| 795 List<LabelElement> rLabels = resynthesized.labels; |
| 796 List<LabelElement> oLabels = original.labels; |
| 797 expect(rLabels, hasLength(oLabels.length)); |
| 798 for (int i = 0; i < oLabels.length; i++) { |
| 799 compareLabelElements( |
| 800 rLabels[i], oLabels[i], '$desc label ${oLabels[i].name}'); |
| 801 } |
| 802 } |
| 803 if (original is! Member) { |
| 804 List<LocalVariableElement> rVariables = resynthesized.localVariables; |
| 805 List<LocalVariableElement> oVariables = original.localVariables; |
| 806 expect(rVariables, hasLength(oVariables.length)); |
| 807 for (int i = 0; i < oVariables.length; i++) { |
| 808 compareVariableElements(rVariables[i], oVariables[i], |
| 809 '$desc local variable ${oVariables[i].name}'); |
| 810 } |
| 811 } | 811 } |
| 812 } | 812 } |
| 813 | 813 |
| 814 void compareMetadata(List<ElementAnnotation> resynthesized, | 814 void compareMetadata(List<ElementAnnotation> resynthesized, |
| 815 List<ElementAnnotation> original, String desc) { | 815 List<ElementAnnotation> original, String desc) { |
| 816 expect(resynthesized, hasLength(original.length), reason: desc); | 816 expect(resynthesized, hasLength(original.length), reason: desc); |
| 817 for (int i = 0; i < original.length; i++) { | 817 for (int i = 0; i < original.length; i++) { |
| 818 compareElementAnnotations( | 818 compareElementAnnotations( |
| 819 resynthesized[i], original[i], '$desc annotation $i'); | 819 resynthesized[i], original[i], '$desc annotation $i'); |
| 820 } | 820 } |
| (...skipping 3530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4351 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4351 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 4352 } | 4352 } |
| 4353 return serializedUnit; | 4353 return serializedUnit; |
| 4354 } | 4354 } |
| 4355 | 4355 |
| 4356 @override | 4356 @override |
| 4357 bool hasLibrarySummary(String uri) { | 4357 bool hasLibrarySummary(String uri) { |
| 4358 return true; | 4358 return true; |
| 4359 } | 4359 } |
| 4360 } | 4360 } |
| OLD | NEW |