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

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1181663004: Fix for explicit dart:core import. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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/test/generated/static_warning_code_test.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.task.dart_test; 5 library test.src.task.dart_test;
6 6
7 import 'package:analyzer/src/context/cache.dart'; 7 import 'package:analyzer/src/context/cache.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/constant.dart'; 9 import 'package:analyzer/src/generated/constant.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 expect(exportElement.uriOffset, 41); 353 expect(exportElement.uriOffset, 41);
354 expect(exportElement.uriEnd, 52); 354 expect(exportElement.uriEnd, 52);
355 } 355 }
356 // validate LibraryElement 356 // validate LibraryElement
357 expect(libraryElementA.hasExtUri, isFalse); 357 expect(libraryElementA.hasExtUri, isFalse);
358 // has an artificial "dart:core" import 358 // has an artificial "dart:core" import
359 { 359 {
360 List<ImportElement> imports = libraryElementA.imports; 360 List<ImportElement> imports = libraryElementA.imports;
361 expect(imports, hasLength(2)); 361 expect(imports, hasLength(2));
362 expect(imports[1].importedLibrary.isDartCore, isTrue); 362 expect(imports[1].importedLibrary.isDartCore, isTrue);
363 expect(imports[1].isSynthetic, isTrue);
363 } 364 }
364 } 365 }
365 366
366 test_perform_combinators() { 367 test_perform_combinators() {
367 List<Source> sources = newSources({ 368 List<Source> sources = newSources({
368 '/libA.dart': ''' 369 '/libA.dart': '''
369 library libA; 370 library libA;
370 import 'libB.dart' show A, B hide C, D; 371 import 'libB.dart' show A, B hide C, D;
371 ''', 372 ''',
372 '/libB.dart': ''' 373 '/libB.dart': '''
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 ''' 446 '''
446 }); 447 });
447 Source sourceA = sources[0]; 448 Source sourceA = sources[0];
448 // perform task 449 // perform task
449 computeResult(sourceA, LIBRARY_ELEMENT2); 450 computeResult(sourceA, LIBRARY_ELEMENT2);
450 expect(task, new isInstanceOf<BuildDirectiveElementsTask>()); 451 expect(task, new isInstanceOf<BuildDirectiveElementsTask>());
451 // validate errors 452 // validate errors
452 _assertErrorsWithCodes([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]); 453 _assertErrorsWithCodes([CompileTimeErrorCode.IMPORT_OF_NON_LIBRARY]);
453 } 454 }
454 455
456 test_perform_explicitDartCoreImport() {
457 List<Source> sources = newSources({
458 '/lib.dart': '''
459 library lib;
460 import 'dart:core' show List;
461 '''
462 });
463 Source source = sources[0];
464 // perform task
465 computeResult(source, LIBRARY_ELEMENT2);
466 expect(task, new isInstanceOf<BuildDirectiveElementsTask>());
467 // prepare outputs
468 LibraryElement libraryElement = outputs[LIBRARY_ELEMENT2];
469 // has an explicit "dart:core" import
470 {
471 List<ImportElement> imports = libraryElement.imports;
472 expect(imports, hasLength(1));
473 expect(imports[0].importedLibrary.isDartCore, isTrue);
474 expect(imports[0].isSynthetic, isFalse);
475 }
476 }
477
455 test_perform_hasExtUri() { 478 test_perform_hasExtUri() {
456 List<Source> sources = newSources({ 479 List<Source> sources = newSources({
457 '/lib.dart': ''' 480 '/lib.dart': '''
458 import 'dart-ext:doesNotExist.dart'; 481 import 'dart-ext:doesNotExist.dart';
459 ''' 482 '''
460 }); 483 });
461 Source source = sources[0]; 484 Source source = sources[0];
462 // perform task 485 // perform task
463 computeResult(source, LIBRARY_ELEMENT2); 486 computeResult(source, LIBRARY_ELEMENT2);
464 expect(task, new isInstanceOf<BuildDirectiveElementsTask>()); 487 expect(task, new isInstanceOf<BuildDirectiveElementsTask>());
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
2729 /** 2752 /**
2730 * Fill [errorListener] with [result] errors in the current [task]. 2753 * Fill [errorListener] with [result] errors in the current [task].
2731 */ 2754 */
2732 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 2755 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
2733 List<AnalysisError> errors = task.outputs[result]; 2756 List<AnalysisError> errors = task.outputs[result];
2734 expect(errors, isNotNull, reason: result.name); 2757 expect(errors, isNotNull, reason: result.name);
2735 errorListener = new GatheringErrorListener(); 2758 errorListener = new GatheringErrorListener();
2736 errorListener.addAll(errors); 2759 errorListener.addAll(errors);
2737 } 2760 }
2738 } 2761 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/static_warning_code_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698