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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 resynthesized.typeParameters[i], | 776 resynthesized.typeParameters[i], |
777 original.typeParameters[i], | 777 original.typeParameters[i], |
778 '$desc type parameter ${original.typeParameters[i].name}'); | 778 '$desc type parameter ${original.typeParameters[i].name}'); |
779 } | 779 } |
780 } | 780 } |
781 | 781 |
782 void compareImportElements(ImportElementImpl resynthesized, | 782 void compareImportElements(ImportElementImpl resynthesized, |
783 ImportElementImpl original, String desc) { | 783 ImportElementImpl original, String desc) { |
784 compareUriReferencedElements(resynthesized, original, desc); | 784 compareUriReferencedElements(resynthesized, original, desc); |
785 expect(resynthesized.importedLibrary.location, | 785 expect(resynthesized.importedLibrary.location, |
786 original.importedLibrary.location); | 786 original.importedLibrary.location, |
787 expect(resynthesized.prefixOffset, original.prefixOffset); | 787 reason: '$desc importedLibrary location'); |
| 788 expect(resynthesized.prefixOffset, original.prefixOffset, |
| 789 reason: '$desc prefixOffset'); |
788 if (original.prefix == null) { | 790 if (original.prefix == null) { |
789 expect(resynthesized.prefix, isNull); | 791 expect(resynthesized.prefix, isNull, reason: '$desc prefix'); |
790 } else { | 792 } else { |
791 comparePrefixElements( | 793 comparePrefixElements( |
792 resynthesized.prefix, original.prefix, original.prefix.name); | 794 resynthesized.prefix, original.prefix, original.prefix.name); |
793 } | 795 } |
794 expect(resynthesized.combinators.length, original.combinators.length); | 796 expect(resynthesized.combinators.length, original.combinators.length, |
| 797 reason: '$desc combinators'); |
795 for (int i = 0; i < resynthesized.combinators.length; i++) { | 798 for (int i = 0; i < resynthesized.combinators.length; i++) { |
796 compareNamespaceCombinators( | 799 compareNamespaceCombinators( |
797 resynthesized.combinators[i], original.combinators[i]); | 800 resynthesized.combinators[i], original.combinators[i]); |
798 } | 801 } |
799 } | 802 } |
800 | 803 |
801 void compareLabelElements( | 804 void compareLabelElements( |
802 LabelElementImpl resynthesized, LabelElementImpl original, String desc) { | 805 LabelElementImpl resynthesized, LabelElementImpl original, String desc) { |
803 expect(resynthesized.isOnSwitchMember, original.isOnSwitchMember, | 806 expect(resynthesized.isOnSwitchMember, original.isOnSwitchMember, |
804 reason: desc); | 807 reason: desc); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 MethodElementImpl original, String desc) { | 854 MethodElementImpl original, String desc) { |
852 // TODO(paulberry): do we need to deal with | 855 // TODO(paulberry): do we need to deal with |
853 // MultiplyInheritedMethodElementImpl? | 856 // MultiplyInheritedMethodElementImpl? |
854 compareExecutableElements(resynthesized, original, desc); | 857 compareExecutableElements(resynthesized, original, desc); |
855 } | 858 } |
856 | 859 |
857 void compareNamespaceCombinators( | 860 void compareNamespaceCombinators( |
858 NamespaceCombinator resynthesized, NamespaceCombinator original) { | 861 NamespaceCombinator resynthesized, NamespaceCombinator original) { |
859 if (original is ShowElementCombinatorImpl && | 862 if (original is ShowElementCombinatorImpl && |
860 resynthesized is ShowElementCombinatorImpl) { | 863 resynthesized is ShowElementCombinatorImpl) { |
861 expect(resynthesized.shownNames, original.shownNames); | 864 expect(resynthesized.shownNames, original.shownNames, |
862 expect(resynthesized.offset, original.offset); | 865 reason: 'shownNames'); |
863 expect(resynthesized.end, original.end); | 866 expect(resynthesized.offset, original.offset, reason: 'offset'); |
| 867 expect(resynthesized.end, original.end, reason: 'end'); |
864 } else if (original is HideElementCombinatorImpl && | 868 } else if (original is HideElementCombinatorImpl && |
865 resynthesized is HideElementCombinatorImpl) { | 869 resynthesized is HideElementCombinatorImpl) { |
866 expect(resynthesized.hiddenNames, original.hiddenNames); | 870 expect(resynthesized.hiddenNames, original.hiddenNames, |
| 871 reason: 'hiddenNames'); |
867 } else if (resynthesized.runtimeType != original.runtimeType) { | 872 } else if (resynthesized.runtimeType != original.runtimeType) { |
868 fail( | 873 fail( |
869 'Type mismatch: expected ${original.runtimeType}, got ${resynthesized.
runtimeType}'); | 874 'Type mismatch: expected ${original.runtimeType}, got ${resynthesized.
runtimeType}'); |
870 } else { | 875 } else { |
871 fail('Unimplemented comparison for ${original.runtimeType}'); | 876 fail('Unimplemented comparison for ${original.runtimeType}'); |
872 } | 877 } |
873 } | 878 } |
874 | 879 |
875 void compareNamespaces( | 880 void compareNamespaces( |
876 Namespace resynthesized, Namespace original, String desc) { | 881 Namespace resynthesized, Namespace original, String desc) { |
(...skipping 3722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4599 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4604 fail('Unexpectedly tried to get unlinked summary for $uri'); |
4600 } | 4605 } |
4601 return serializedUnit; | 4606 return serializedUnit; |
4602 } | 4607 } |
4603 | 4608 |
4604 @override | 4609 @override |
4605 bool hasLibrarySummary(String uri) { | 4610 bool hasLibrarySummary(String uri) { |
4606 return true; | 4611 return true; |
4607 } | 4612 } |
4608 } | 4613 } |
OLD | NEW |