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

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

Issue 1833743002: Resynthesize _DeferredClassElement instead of actual ClassElementImpl. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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
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/constant/value.dart'; 10 import 'package:analyzer/dart/constant/value.dart';
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } 172 }
173 } 173 }
174 } else { 174 } else {
175 expect( 175 expect(
176 resynthesizedNonHandle, isNot(new isInstanceOf<ConstructorMember>()), 176 resynthesizedNonHandle, isNot(new isInstanceOf<ConstructorMember>()),
177 reason: desc); 177 reason: desc);
178 } 178 }
179 } 179 }
180 180
181 void compareClassElements( 181 void compareClassElements(
182 ClassElementImpl resynthesized, ClassElementImpl original, String desc) { 182 ClassElement resynthesized, ClassElement original, String desc) {
183 compareElements(resynthesized, original, desc); 183 ClassElementImpl r = getActualElement(resynthesized, desc);
184 expect(resynthesized.fields.length, original.fields.length, 184 ClassElementImpl o = getActualElement(original, desc);
185 reason: '$desc fields.length'); 185 compareElements(r, o, desc);
186 for (int i = 0; i < resynthesized.fields.length; i++) { 186 expect(r.fields.length, o.fields.length, reason: '$desc fields.length');
187 String name = original.fields[i].name; 187 for (int i = 0; i < r.fields.length; i++) {
188 compareFieldElements( 188 String name = o.fields[i].name;
189 resynthesized.fields[i], original.fields[i], '$desc.field $name'); 189 compareFieldElements(r.fields[i], o.fields[i], '$desc.field $name');
190 } 190 }
191 compareTypes( 191 compareTypes(r.supertype, o.supertype, '$desc supertype');
192 resynthesized.supertype, original.supertype, '$desc supertype'); 192 expect(r.interfaces.length, o.interfaces.length);
193 expect(resynthesized.interfaces.length, original.interfaces.length); 193 for (int i = 0; i < r.interfaces.length; i++) {
194 for (int i = 0; i < resynthesized.interfaces.length; i++) { 194 compareTypes(r.interfaces[i], o.interfaces[i],
195 compareTypes(resynthesized.interfaces[i], original.interfaces[i], 195 '$desc interface ${o.interfaces[i].name}');
196 '$desc interface ${original.interfaces[i].name}');
197 } 196 }
198 expect(resynthesized.mixins.length, original.mixins.length); 197 expect(r.mixins.length, o.mixins.length);
199 for (int i = 0; i < resynthesized.mixins.length; i++) { 198 for (int i = 0; i < r.mixins.length; i++) {
200 compareTypes(resynthesized.mixins[i], original.mixins[i], 199 compareTypes(r.mixins[i], o.mixins[i], '$desc mixin ${o.mixins[i].name}');
201 '$desc mixin ${original.mixins[i].name}');
202 } 200 }
203 expect(resynthesized.typeParameters.length, original.typeParameters.length); 201 expect(r.typeParameters.length, o.typeParameters.length);
204 for (int i = 0; i < resynthesized.typeParameters.length; i++) { 202 for (int i = 0; i < r.typeParameters.length; i++) {
205 compareTypeParameterElements( 203 compareTypeParameterElements(r.typeParameters[i], o.typeParameters[i],
206 resynthesized.typeParameters[i], 204 '$desc type parameter ${o.typeParameters[i].name}');
207 original.typeParameters[i],
208 '$desc type parameter ${original.typeParameters[i].name}');
209 } 205 }
210 expect(resynthesized.constructors.length, original.constructors.length, 206 expect(r.constructors.length, o.constructors.length,
211 reason: '$desc constructors.length'); 207 reason: '$desc constructors.length');
212 for (int i = 0; i < resynthesized.constructors.length; i++) { 208 for (int i = 0; i < r.constructors.length; i++) {
213 compareConstructorElements( 209 compareConstructorElements(r.constructors[i], o.constructors[i],
214 resynthesized.constructors[i], 210 '$desc constructor ${o.constructors[i].name}');
215 original.constructors[i],
216 '$desc constructor ${original.constructors[i].name}');
217 } 211 }
218 expect(resynthesized.accessors.length, original.accessors.length); 212 expect(r.accessors.length, o.accessors.length);
219 for (int i = 0; i < resynthesized.accessors.length; i++) { 213 for (int i = 0; i < r.accessors.length; i++) {
220 comparePropertyAccessorElements( 214 comparePropertyAccessorElements(r.accessors[i], o.accessors[i],
221 resynthesized.accessors[i], 215 '$desc accessor ${o.accessors[i].name}');
222 original.accessors[i],
223 '$desc accessor ${original.accessors[i].name}');
224 } 216 }
225 expect(resynthesized.methods.length, original.methods.length); 217 expect(r.methods.length, o.methods.length);
226 for (int i = 0; i < resynthesized.methods.length; i++) { 218 for (int i = 0; i < r.methods.length; i++) {
227 compareMethodElements(resynthesized.methods[i], original.methods[i], 219 compareMethodElements(
228 '$desc.${original.methods[i].name}'); 220 r.methods[i], o.methods[i], '$desc.${o.methods[i].name}');
229 } 221 }
230 compareTypes(resynthesized.type, original.type, desc); 222 compareTypes(r.type, o.type, desc);
231 expect(resynthesized.hasBeenInferred, original.hasBeenInferred, 223 expect(r.hasBeenInferred, o.hasBeenInferred, reason: desc);
232 reason: desc);
233 } 224 }
234 225
235 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized, 226 void compareCompilationUnitElements(CompilationUnitElementImpl resynthesized,
236 CompilationUnitElementImpl original) { 227 CompilationUnitElementImpl original) {
237 String desc = 'Compilation unit ${original.source.uri}'; 228 String desc = 'Compilation unit ${original.source.uri}';
238 compareUriReferencedElements(resynthesized, original, desc); 229 compareUriReferencedElements(resynthesized, original, desc);
239 expect(resynthesized.source, original.source); 230 expect(resynthesized.source, original.source);
240 expect(resynthesized.librarySource, original.librarySource); 231 expect(resynthesized.librarySource, original.librarySource);
241 expect(resynthesized.types.length, original.types.length); 232 expect(resynthesized.types.length, original.types.length);
242 for (int i = 0; i < resynthesized.types.length; i++) { 233 for (int i = 0; i < resynthesized.types.length; i++) {
(...skipping 3868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 fail('Unexpectedly tried to get unlinked summary for $uri'); 4102 fail('Unexpectedly tried to get unlinked summary for $uri');
4112 } 4103 }
4113 return serializedUnit; 4104 return serializedUnit;
4114 } 4105 }
4115 4106
4116 @override 4107 @override
4117 bool hasLibrarySummary(String uri) { 4108 bool hasLibrarySummary(String uri) {
4118 return true; 4109 return true;
4119 } 4110 }
4120 } 4111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698