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

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

Issue 1578263003: Test for LibraryElement.hasExtUri resynth. (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 | « 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 '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/resolver.dart' show Namespace;
10 import 'package:analyzer/src/generated/source.dart'; 10 import 'package:analyzer/src/generated/source.dart';
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 resynthesisCount: resynthesisCount); 42 resynthesisCount: resynthesisCount);
43 checkLibraryElements(original, resynthesized); 43 checkLibraryElements(original, resynthesized);
44 } 44 }
45 45
46 void checkLibraryElements( 46 void checkLibraryElements(
47 LibraryElementImpl original, LibraryElementImpl resynthesized) { 47 LibraryElementImpl original, LibraryElementImpl resynthesized) {
48 compareElements(resynthesized, original, '(library)'); 48 compareElements(resynthesized, original, '(library)');
49 expect(resynthesized.displayName, original.displayName); 49 expect(resynthesized.displayName, original.displayName);
50 expect(original.enclosingElement, isNull); 50 expect(original.enclosingElement, isNull);
51 expect(resynthesized.enclosingElement, isNull); 51 expect(resynthesized.enclosingElement, isNull);
52 expect(resynthesized.hasExtUri, original.hasExtUri);
52 compareCompilationUnitElements(resynthesized.definingCompilationUnit, 53 compareCompilationUnitElements(resynthesized.definingCompilationUnit,
53 original.definingCompilationUnit); 54 original.definingCompilationUnit);
54 expect(resynthesized.parts.length, original.parts.length); 55 expect(resynthesized.parts.length, original.parts.length);
55 for (int i = 0; i < resynthesized.parts.length; i++) { 56 for (int i = 0; i < resynthesized.parts.length; i++) {
56 compareCompilationUnitElements(resynthesized.parts[i], original.parts[i]); 57 compareCompilationUnitElements(resynthesized.parts[i], original.parts[i]);
57 } 58 }
58 expect(resynthesized.imports.length, original.imports.length); 59 expect(resynthesized.imports.length, original.imports.length);
59 for (int i = 0; i < resynthesized.imports.length; i++) { 60 for (int i = 0; i < resynthesized.imports.length; i++) {
60 compareImportElements(resynthesized.imports[i], original.imports[i], 61 compareImportElements(resynthesized.imports[i], original.imports[i],
61 'import ${original.imports[i].uri}'); 62 'import ${original.imports[i].uri}');
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 expect(resynthesized.uriEnd, original.uriEnd, reason: desc); 480 expect(resynthesized.uriEnd, original.uriEnd, reason: desc);
480 } 481 }
481 482
482 void compareVariableElements(VariableElementImpl resynthesized, 483 void compareVariableElements(VariableElementImpl resynthesized,
483 VariableElementImpl original, String desc) { 484 VariableElementImpl original, String desc) {
484 compareElements(resynthesized, original, desc); 485 compareElements(resynthesized, original, desc);
485 compareTypes(resynthesized.type, original.type, desc); 486 compareTypes(resynthesized.type, original.type, desc);
486 // TODO(paulberry): test initializer 487 // TODO(paulberry): test initializer
487 } 488 }
488 489
490 fail_library_hasExtUri() {
491 checkLibrary('import "dart-ext:doesNotExist.dart";');
492 }
493
489 LibraryElementImpl resynthesizeLibrary( 494 LibraryElementImpl resynthesizeLibrary(
490 Source source, LibraryElementImpl original, bool allowErrors, 495 Source source, LibraryElementImpl original, bool allowErrors,
491 {int resynthesisCount: 1}) { 496 {int resynthesisCount: 1}) {
492 if (!allowErrors) { 497 if (!allowErrors) {
493 assertNoErrors(source); 498 assertNoErrors(source);
494 } 499 }
495 String uri = source.uri.toString(); 500 String uri = source.uri.toString();
496 addLibrary('dart:core'); 501 addLibrary('dart:core');
497 return resynthesizeLibraryElement(uri, original, 502 return resynthesizeLibraryElement(uri, original,
498 resynthesisCount: resynthesisCount); 503 resynthesisCount: resynthesisCount);
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1382 } 1387 }
1383 1388
1384 test_variable_implicit_type() { 1389 test_variable_implicit_type() {
1385 checkLibrary('var x;'); 1390 checkLibrary('var x;');
1386 } 1391 }
1387 1392
1388 test_variables() { 1393 test_variables() {
1389 checkLibrary('int i; int j;'); 1394 checkLibrary('int i; int j;');
1390 } 1395 }
1391 } 1396 }
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