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

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

Issue 1573203003: Compute public namespace during resynthesizing. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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 | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | 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 'package:analyzer/src/generated/element.dart'; 7 import 'package:analyzer/src/generated/element.dart';
8 import 'package:analyzer/src/generated/engine.dart'; 8 import 'package:analyzer/src/generated/engine.dart';
9 import 'package:analyzer/src/generated/resolver.dart' show Namespace;
9 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/summary/format.dart'; 11 import 'package:analyzer/src/summary/format.dart';
11 import 'package:analyzer/src/summary/resynthesize.dart'; 12 import 'package:analyzer/src/summary/resynthesize.dart';
12 import 'package:analyzer/src/summary/summarize_elements.dart'; 13 import 'package:analyzer/src/summary/summarize_elements.dart';
13 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
14 15
15 import '../../generated/resolver_test.dart'; 16 import '../../generated/resolver_test.dart';
16 import '../../reflective_tests.dart'; 17 import '../../reflective_tests.dart';
17 18
18 main() { 19 main() {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 'export ${original.exports[i].uri}'); 64 'export ${original.exports[i].uri}');
64 } 65 }
65 expect(resynthesized.nameLength, original.nameLength); 66 expect(resynthesized.nameLength, original.nameLength);
66 if (original.entryPoint == null) { 67 if (original.entryPoint == null) {
67 expect(resynthesized.entryPoint, isNull); 68 expect(resynthesized.entryPoint, isNull);
68 } else { 69 } else {
69 expect(resynthesized.entryPoint, isNotNull); 70 expect(resynthesized.entryPoint, isNotNull);
70 compareFunctionElements( 71 compareFunctionElements(
71 resynthesized.entryPoint, original.entryPoint, '(entry point)'); 72 resynthesized.entryPoint, original.entryPoint, '(entry point)');
72 } 73 }
73 // TODO(paulberry): test exportNamespace, publicNamespace, 74 compareNamespaces(resynthesized.publicNamespace, original.publicNamespace,
74 // and metadata. 75 '(public namespace)');
76 // TODO(paulberry): test exportNamespace and metadata.
75 } 77 }
76 78
77 void compareClassElements( 79 void compareClassElements(
78 ClassElementImpl resynthesized, ClassElementImpl original, String desc) { 80 ClassElementImpl resynthesized, ClassElementImpl original, String desc) {
79 compareElements(resynthesized, original, desc); 81 compareElements(resynthesized, original, desc);
80 expect(resynthesized.fields.length, original.fields.length, 82 expect(resynthesized.fields.length, original.fields.length,
81 reason: '$desc fields.length'); 83 reason: '$desc fields.length');
82 for (int i = 0; i < resynthesized.fields.length; i++) { 84 for (int i = 0; i < resynthesized.fields.length; i++) {
83 String name = original.fields[i].name; 85 String name = original.fields[i].name;
84 compareFieldElements(resynthesized.getField(name), original.fields[i], 86 compareFieldElements(resynthesized.getField(name), original.fields[i],
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 resynthesized is HideElementCombinatorImpl) { 311 resynthesized is HideElementCombinatorImpl) {
310 expect(resynthesized.hiddenNames, original.hiddenNames); 312 expect(resynthesized.hiddenNames, original.hiddenNames);
311 } else if (resynthesized.runtimeType != original.runtimeType) { 313 } else if (resynthesized.runtimeType != original.runtimeType) {
312 fail( 314 fail(
313 'Type mismatch: expected ${original.runtimeType}, got ${resynthesized. runtimeType}'); 315 'Type mismatch: expected ${original.runtimeType}, got ${resynthesized. runtimeType}');
314 } else { 316 } else {
315 fail('Unimplemented comparison for ${original.runtimeType}'); 317 fail('Unimplemented comparison for ${original.runtimeType}');
316 } 318 }
317 } 319 }
318 320
321 void compareNamespaces(
322 Namespace resynthesized, Namespace original, String desc) {
323 Map<String, Element> resynthesizedMap = resynthesized.definedNames;
324 Map<String, Element> originalMap = original.definedNames;
325 expect(resynthesizedMap.keys, originalMap.keys, reason: desc);
Paul Berry 2016/01/11 22:27:24 I'd rather not rely on the keys being in the same
326 for (String key in originalMap.keys) {
327 Element resynthesizedElement = resynthesizedMap[key];
328 Element originalElement = originalMap[key];
329 compareElements(resynthesizedElement, originalElement, key);
330 }
331 }
332
319 void compareParameterElements(ParameterElementImpl resynthesized, 333 void compareParameterElements(ParameterElementImpl resynthesized,
320 ParameterElementImpl original, String desc) { 334 ParameterElementImpl original, String desc) {
321 compareVariableElements(resynthesized, original, desc); 335 compareVariableElements(resynthesized, original, desc);
322 expect(resynthesized.parameters.length, original.parameters.length); 336 expect(resynthesized.parameters.length, original.parameters.length);
323 for (int i = 0; i < resynthesized.parameters.length; i++) { 337 for (int i = 0; i < resynthesized.parameters.length; i++) {
324 compareParameterElements( 338 compareParameterElements(
325 resynthesized.parameters[i], 339 resynthesized.parameters[i],
326 original.parameters[i], 340 original.parameters[i],
327 '$desc parameter ${original.parameters[i].name}'); 341 '$desc parameter ${original.parameters[i].name}');
328 } 342 }
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 } 1369 }
1356 1370
1357 test_variable_implicit_type() { 1371 test_variable_implicit_type() {
1358 checkLibrary('var x;'); 1372 checkLibrary('var x;');
1359 } 1373 }
1360 1374
1361 test_variables() { 1375 test_variables() {
1362 checkLibrary('int i; int j;'); 1376 checkLibrary('int i; int j;');
1363 } 1377 }
1364 } 1378 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/resynthesize.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698