Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: pkg/analyzer/test/src/summary/resynthesize_test.dart

Issue 1716873002: Test resynthesis of initializer of parameter elements and variable members. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 if (original.field == null) { 799 if (original.field == null) {
800 expect(resynthesized.field, isNull, reason: '$desc field'); 800 expect(resynthesized.field, isNull, reason: '$desc field');
801 } else { 801 } else {
802 expect(resynthesized.field, isNotNull, reason: '$desc field'); 802 expect(resynthesized.field, isNotNull, reason: '$desc field');
803 compareFieldElements( 803 compareFieldElements(
804 resynthesized.field, original.field, '$desc field'); 804 resynthesized.field, original.field, '$desc field');
805 } 805 }
806 } 806 }
807 expect(resynthesized.defaultValueCode, original.defaultValueCode, 807 expect(resynthesized.defaultValueCode, original.defaultValueCode,
808 reason: desc); 808 reason: desc);
809 ParameterElementImpl resynthesizedActual =
810 getActualElement(resynthesized, desc);
811 ParameterElementImpl originalActual = getActualElement(original, desc);
812 compareFunctionElements(
813 resynthesizedActual.initializer, originalActual.initializer, desc);
809 } 814 }
810 815
811 void comparePrefixElements(PrefixElementImpl resynthesized, 816 void comparePrefixElements(PrefixElementImpl resynthesized,
812 PrefixElementImpl original, String desc) { 817 PrefixElementImpl original, String desc) {
813 compareElements(resynthesized, original, desc); 818 compareElements(resynthesized, original, desc);
814 } 819 }
815 820
816 void comparePropertyAccessorElements( 821 void comparePropertyAccessorElements(
817 PropertyAccessorElementImpl resynthesized, 822 PropertyAccessorElementImpl resynthesized,
818 PropertyAccessorElementImpl original, 823 PropertyAccessorElementImpl original,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 compareElements(resynthesized, original, desc); 947 compareElements(resynthesized, original, desc);
943 expect(resynthesized.uri, original.uri); 948 expect(resynthesized.uri, original.uri);
944 expect(resynthesized.uriOffset, original.uriOffset, reason: desc); 949 expect(resynthesized.uriOffset, original.uriOffset, reason: desc);
945 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); 950 expect(resynthesized.uriEnd, original.uriEnd, reason: desc);
946 } 951 }
947 952
948 void compareVariableElements( 953 void compareVariableElements(
949 VariableElement resynthesized, VariableElement original, String desc) { 954 VariableElement resynthesized, VariableElement original, String desc) {
950 compareElements(resynthesized, original, desc); 955 compareElements(resynthesized, original, desc);
951 compareTypes(resynthesized.type, original.type, desc); 956 compareTypes(resynthesized.type, original.type, desc);
952 // TODO(scheglov) VariableMember.initializer is not implemented 957 VariableElementImpl resynthesizedActual =
953 if (original is! VariableMember) { 958 getActualElement(resynthesized, desc);
954 compareFunctionElements(
955 resynthesized.initializer, original.initializer, desc);
956 }
957 VariableElementImpl originalActual = getActualElement(original, desc); 959 VariableElementImpl originalActual = getActualElement(original, desc);
960 compareFunctionElements(
961 resynthesizedActual.initializer, originalActual.initializer, desc);
958 if (originalActual is ConstVariableElement) { 962 if (originalActual is ConstVariableElement) {
959 Element oEnclosing = original.enclosingElement; 963 Element oEnclosing = original.enclosingElement;
960 if (oEnclosing is ClassElement && oEnclosing.isEnum) { 964 if (oEnclosing is ClassElement && oEnclosing.isEnum) {
961 compareConstValues( 965 compareConstValues(
962 resynthesized.constantValue, original.constantValue, desc); 966 resynthesized.constantValue, original.constantValue, desc);
963 } else { 967 } else {
964 VariableElementImpl resynthesizedActual =
965 getActualElement(resynthesized, desc);
966 Expression initializer = resynthesizedActual.constantInitializer; 968 Expression initializer = resynthesizedActual.constantInitializer;
967 if (constantInitializersAreInvalid) { 969 if (constantInitializersAreInvalid) {
968 _assertUnresolvedIdentifier(initializer, desc); 970 _assertUnresolvedIdentifier(initializer, desc);
969 } else { 971 } else {
970 compareConstAsts(initializer, originalActual.constantInitializer, 972 compareConstAsts(initializer, originalActual.constantInitializer,
971 '$desc initializer'); 973 '$desc initializer');
972 } 974 }
973 } 975 }
974 } 976 }
975 checkPossibleMember(resynthesized, original, desc); 977 checkPossibleMember(resynthesized, original, desc);
(...skipping 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after
3953 fail('Unexpectedly tried to get unlinked summary for $uri'); 3955 fail('Unexpectedly tried to get unlinked summary for $uri');
3954 } 3956 }
3955 return serializedUnit; 3957 return serializedUnit;
3956 } 3958 }
3957 3959
3958 @override 3960 @override
3959 bool hasLibrarySummary(String uri) { 3961 bool hasLibrarySummary(String uri) {
3960 return true; 3962 return true;
3961 } 3963 }
3962 } 3964 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698