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 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 29 matching lines...) Expand all Loading... |
40 * so they are not resynthesized. | 40 * so they are not resynthesized. |
41 */ | 41 */ |
42 Set<String> variablesWithNotConstInitializers = new Set<String>(); | 42 Set<String> variablesWithNotConstInitializers = new Set<String>(); |
43 | 43 |
44 /** | 44 /** |
45 * Tests may set this to `true` to indicate that a missing file at the time of | 45 * Tests may set this to `true` to indicate that a missing file at the time of |
46 * summary resynthesis shouldn't trigger an error. | 46 * summary resynthesis shouldn't trigger an error. |
47 */ | 47 */ |
48 bool allowMissingFiles = false; | 48 bool allowMissingFiles = false; |
49 | 49 |
50 bool get checkPropagatedTypes => true; | |
51 | |
52 void addLibrary(String uri) { | 50 void addLibrary(String uri) { |
53 otherLibrarySources.add(context.sourceFactory.forUri(uri)); | 51 otherLibrarySources.add(context.sourceFactory.forUri(uri)); |
54 } | 52 } |
55 | 53 |
56 Source addLibrarySource(String filePath, String contents) { | 54 Source addLibrarySource(String filePath, String contents) { |
57 Source source = addSource(filePath, contents); | 55 Source source = addSource(filePath, contents); |
58 otherLibrarySources.add(source); | 56 otherLibrarySources.add(source); |
59 return source; | 57 return source; |
60 } | 58 } |
61 | 59 |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 expect(rImpl, isNot(new isInstanceOf<Member>()), reason: desc); | 703 expect(rImpl, isNot(new isInstanceOf<Member>()), reason: desc); |
706 } | 704 } |
707 } | 705 } |
708 | 706 |
709 void compareExecutableElements( | 707 void compareExecutableElements( |
710 ExecutableElement resynthesized, ExecutableElement original, String desc, | 708 ExecutableElement resynthesized, ExecutableElement original, String desc, |
711 {bool shallow: false}) { | 709 {bool shallow: false}) { |
712 compareElements(resynthesized, original, desc); | 710 compareElements(resynthesized, original, desc); |
713 compareParameterElementLists( | 711 compareParameterElementLists( |
714 resynthesized.parameters, original.parameters, desc); | 712 resynthesized.parameters, original.parameters, desc); |
715 if (checkPropagatedTypes || !original.hasImplicitReturnType) { | 713 if (!original.hasImplicitReturnType) { |
716 compareTypes( | 714 compareTypes( |
717 resynthesized.returnType, original.returnType, '$desc return type'); | 715 resynthesized.returnType, original.returnType, '$desc return type'); |
718 } | 716 } |
719 if (!shallow) { | 717 if (!shallow) { |
720 compareTypes(resynthesized.type, original.type, desc); | 718 compareTypes(resynthesized.type, original.type, desc); |
721 } | 719 } |
722 expect(resynthesized.typeParameters.length, original.typeParameters.length); | 720 expect(resynthesized.typeParameters.length, original.typeParameters.length); |
723 for (int i = 0; i < resynthesized.typeParameters.length; i++) { | 721 for (int i = 0; i < resynthesized.typeParameters.length; i++) { |
724 compareTypeParameterElements( | 722 compareTypeParameterElements( |
725 resynthesized.typeParameters[i], | 723 resynthesized.typeParameters[i], |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 compareExecutableElements(resynthesized, original, desc); | 941 compareExecutableElements(resynthesized, original, desc); |
944 expect(resynthesized.variable, isNotNull); | 942 expect(resynthesized.variable, isNotNull); |
945 expect(resynthesized.variable.location, original.variable.location); | 943 expect(resynthesized.variable.location, original.variable.location); |
946 } | 944 } |
947 | 945 |
948 void comparePropertyInducingElements( | 946 void comparePropertyInducingElements( |
949 PropertyInducingElementImpl resynthesized, | 947 PropertyInducingElementImpl resynthesized, |
950 PropertyInducingElementImpl original, | 948 PropertyInducingElementImpl original, |
951 String desc) { | 949 String desc) { |
952 compareVariableElements(resynthesized, original, desc); | 950 compareVariableElements(resynthesized, original, desc); |
953 if (checkPropagatedTypes) { | |
954 compareTypes(resynthesized.propagatedType, original.propagatedType, desc); | |
955 } | |
956 if (original.getter == null) { | 951 if (original.getter == null) { |
957 expect(resynthesized.getter, isNull); | 952 expect(resynthesized.getter, isNull); |
958 } else { | 953 } else { |
959 expect(resynthesized.getter, isNotNull); | 954 expect(resynthesized.getter, isNotNull); |
960 expect(resynthesized.getter.location, original.getter.location); | 955 expect(resynthesized.getter.location, original.getter.location); |
961 } | 956 } |
962 if (original.setter == null) { | 957 if (original.setter == null) { |
963 expect(resynthesized.setter, isNull); | 958 expect(resynthesized.setter, isNull); |
964 } else { | 959 } else { |
965 expect(resynthesized.setter, isNotNull); | 960 expect(resynthesized.setter, isNotNull); |
(...skipping 3659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4625 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4620 fail('Unexpectedly tried to get unlinked summary for $uri'); |
4626 } | 4621 } |
4627 return serializedUnit; | 4622 return serializedUnit; |
4628 } | 4623 } |
4629 | 4624 |
4630 @override | 4625 @override |
4631 bool hasLibrarySummary(String uri) { | 4626 bool hasLibrarySummary(String uri) { |
4632 return true; | 4627 return true; |
4633 } | 4628 } |
4634 } | 4629 } |
OLD | NEW |