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

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

Issue 2343103003: ImportElement/ExportElement 'uri' should be the selected URI. (Closed)
Patch Set: Created 4 years, 3 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 analyzer.test.src.task.dart_test; 5 library analyzer.test.src.task.dart_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 expect(combinator.offset, 33); 349 expect(combinator.offset, 33);
350 expect(combinator.end, 42); 350 expect(combinator.end, 42);
351 expect(combinator.shownNames, ['A', 'B']); 351 expect(combinator.shownNames, ['A', 'B']);
352 } 352 }
353 { 353 {
354 HideElementCombinator combinator = combinators[1]; 354 HideElementCombinator combinator = combinators[1];
355 expect(combinator.hiddenNames, ['C', 'D']); 355 expect(combinator.hiddenNames, ['C', 'D']);
356 } 356 }
357 } 357 }
358 358
359 test_perform_configurations_export() {
360 context.declaredVariables.define('dart.library.io', 'true');
361 context.declaredVariables.define('dart.library.html', 'true');
362 newSource('/foo.dart', '');
363 var foo_io = newSource('/foo_io.dart', '');
364 newSource('/foo_html.dart', '');
365 var testSource = newSource(
366 '/test.dart',
367 r'''
368 export 'foo.dart'
369 if (dart.library.io) 'foo_io.dart'
370 if (dart.library.html) 'foo_html.dart';
371 ''');
372 // Perform the task.
373 computeResult(testSource, LIBRARY_ELEMENT2,
374 matcher: isBuildDirectiveElementsTask);
375 LibraryElement testLibrary = outputs[LIBRARY_ELEMENT2];
376 // Validate the export element.
377 ExportElement export = testLibrary.exports[0];
378 expect(export.exportedLibrary.source, foo_io);
379 expect(export.uri, 'foo_io.dart');
380 }
381
382 test_perform_configurations_import() {
383 context.declaredVariables.define('dart.library.io', 'true');
384 context.declaredVariables.define('dart.library.html', 'true');
385 newSource('/foo.dart', '');
386 var foo_io = newSource('/foo_io.dart', '');
387 newSource('/foo_html.dart', '');
388 var testSource = newSource(
389 '/test.dart',
390 r'''
391 import 'foo.dart'
392 if (dart.library.io) 'foo_io.dart'
393 if (dart.library.html) 'foo_html.dart';
394 ''');
395 // Perform the task.
396 computeResult(testSource, LIBRARY_ELEMENT2,
397 matcher: isBuildDirectiveElementsTask);
398 LibraryElement testLibrary = outputs[LIBRARY_ELEMENT2];
399 // Validate the import element.
400 ImportElement import = testLibrary.imports[0];
401 expect(import.importedLibrary.source, foo_io);
402 expect(import.uri, 'foo_io.dart');
403 }
404
359 test_perform_dartCoreContext() { 405 test_perform_dartCoreContext() {
360 List<Source> sources = newSources({'/libA.dart': ''}); 406 List<Source> sources = newSources({'/libA.dart': ''});
361 Source source = sources[0]; 407 Source source = sources[0];
362 // perform task 408 // perform task
363 computeResult(source, LIBRARY_ELEMENT2, 409 computeResult(source, LIBRARY_ELEMENT2,
364 matcher: isBuildDirectiveElementsTask); 410 matcher: isBuildDirectiveElementsTask);
365 // prepare outputs 411 // prepare outputs
366 LibraryElement libraryElement = outputs[LIBRARY_ELEMENT2]; 412 LibraryElement libraryElement = outputs[LIBRARY_ELEMENT2];
367 // verify that dart:core has SDK context 413 // verify that dart:core has SDK context
368 { 414 {
(...skipping 5301 matching lines...) Expand 10 before | Expand all | Expand 10 after
5670 /** 5716 /**
5671 * Fill [errorListener] with [result] errors in the current [task]. 5717 * Fill [errorListener] with [result] errors in the current [task].
5672 */ 5718 */
5673 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5719 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5674 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>; 5720 List<AnalysisError> errors = task.outputs[result] as List<AnalysisError>;
5675 expect(errors, isNotNull, reason: result.name); 5721 expect(errors, isNotNull, reason: result.name);
5676 errorListener = new GatheringErrorListener(); 5722 errorListener = new GatheringErrorListener();
5677 errorListener.addAll(errors); 5723 errorListener.addAll(errors);
5678 } 5724 }
5679 } 5725 }
OLDNEW
« pkg/analyzer/lib/dart/ast/ast.dart ('K') | « pkg/analyzer/lib/src/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698