| OLD | NEW |
| 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/file_system/file_system.dart'; | 7 import 'package:analyzer/file_system/file_system.dart'; |
| 8 import 'package:analyzer/file_system/memory_file_system.dart'; | 8 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/generated/ast.dart'; | 10 import 'package:analyzer/src/generated/ast.dart'; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 runReflectiveTests(BuildLibraryElementTaskTest); | 39 runReflectiveTests(BuildLibraryElementTaskTest); |
| 40 runReflectiveTests(BuildPublicNamespaceTaskTest); | 40 runReflectiveTests(BuildPublicNamespaceTaskTest); |
| 41 runReflectiveTests(BuildTypeProviderTaskTest); | 41 runReflectiveTests(BuildTypeProviderTaskTest); |
| 42 runReflectiveTests(ParseDartTaskTest); | 42 runReflectiveTests(ParseDartTaskTest); |
| 43 runReflectiveTests(ScanDartTaskTest); | 43 runReflectiveTests(ScanDartTaskTest); |
| 44 } | 44 } |
| 45 | 45 |
| 46 @reflectiveTest | 46 @reflectiveTest |
| 47 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { | 47 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
| 48 test_buildInputs() { | 48 test_buildInputs() { |
| 49 LibraryUnitTarget target = new LibraryUnitTarget(emptySource, emptySource); |
| 49 Map<String, TaskInput> inputs = | 50 Map<String, TaskInput> inputs = |
| 50 BuildCompilationUnitElementTask.buildInputs(emptySource); | 51 BuildCompilationUnitElementTask.buildInputs(target); |
| 51 expect(inputs, isNotNull); | 52 expect(inputs, isNotNull); |
| 52 expect(inputs.keys, unorderedEquals( | 53 expect(inputs.keys, unorderedEquals( |
| 53 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); | 54 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); |
| 54 } | 55 } |
| 55 | 56 |
| 56 test_constructor() { | 57 test_constructor() { |
| 57 BuildCompilationUnitElementTask task = | 58 BuildCompilationUnitElementTask task = |
| 58 new BuildCompilationUnitElementTask(context, emptySource); | 59 new BuildCompilationUnitElementTask(context, emptySource); |
| 59 expect(task, isNotNull); | 60 expect(task, isNotNull); |
| 60 expect(task.context, context); | 61 expect(task.context, context); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 86 import 'lib2.dart'; | 87 import 'lib2.dart'; |
| 87 export 'lib3.dart'; | 88 export 'lib3.dart'; |
| 88 part 'part.dart'; | 89 part 'part.dart'; |
| 89 class A {'''); | 90 class A {'''); |
| 90 expect(outputs, hasLength(2)); | 91 expect(outputs, hasLength(2)); |
| 91 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); | 92 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
| 92 expect(outputs[RESOLVED_UNIT1], isNotNull); | 93 expect(outputs[RESOLVED_UNIT1], isNotNull); |
| 93 } | 94 } |
| 94 | 95 |
| 95 void _performBuildTask(String content) { | 96 void _performBuildTask(String content) { |
| 96 AnalysisTarget target = _newSource('/test.dart', content); | 97 Source source = _newSource('/test.dart', content); |
| 98 AnalysisTarget target = new LibraryUnitTarget(source, source); |
| 97 _computeResult(target, RESOLVED_UNIT1); | 99 _computeResult(target, RESOLVED_UNIT1); |
| 98 expect(task, new isInstanceOf<BuildCompilationUnitElementTask>()); | 100 expect(task, new isInstanceOf<BuildCompilationUnitElementTask>()); |
| 99 } | 101 } |
| 100 } | 102 } |
| 101 | 103 |
| 102 @reflectiveTest | 104 @reflectiveTest |
| 103 class BuildDirectiveElementsTaskTest extends _AbstractDartTaskTest { | 105 class BuildDirectiveElementsTaskTest extends _AbstractDartTaskTest { |
| 104 test_buildInputs() { | 106 test_buildInputs() { |
| 105 ExtendedAnalysisContext context = new _MockContext(); | 107 ExtendedAnalysisContext context = new _MockContext(); |
| 106 // prepare sources | 108 // prepare sources |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 438 |
| 437 @reflectiveTest | 439 @reflectiveTest |
| 438 class BuildLibraryElementTaskTest extends _AbstractDartTaskTest { | 440 class BuildLibraryElementTaskTest extends _AbstractDartTaskTest { |
| 439 Source librarySource; | 441 Source librarySource; |
| 440 CompilationUnit libraryUnit; | 442 CompilationUnit libraryUnit; |
| 441 CompilationUnitElement libraryUnitElement; | 443 CompilationUnitElement libraryUnitElement; |
| 442 List<CompilationUnit> partUnits; | 444 List<CompilationUnit> partUnits; |
| 443 | 445 |
| 444 LibraryElement libraryElement; | 446 LibraryElement libraryElement; |
| 445 | 447 |
| 446 test_buildInputs() { | |
| 447 ExtendedAnalysisContext context = new _MockContext(); | |
| 448 // prepare sources | |
| 449 File libraryFile = resourceProvider.newFile('/lib.dart', ''); | |
| 450 File partFile1 = resourceProvider.newFile('/part1.dart', ''); | |
| 451 File partFile2 = resourceProvider.newFile('/part2.dart', ''); | |
| 452 Source librarySource = libraryFile.createSource(); | |
| 453 Source partSource1 = partFile1.createSource(); | |
| 454 Source partSource2 = partFile2.createSource(); | |
| 455 // set INCLUDED_PARTS | |
| 456 context.getCacheEntry(librarySource).setValue( | |
| 457 INCLUDED_PARTS, <Source>[partSource1, partSource2]); | |
| 458 // set BUILT_UNIT | |
| 459 CompilationUnit libraryUnit = AstFactory.compilationUnit(); | |
| 460 CompilationUnit partUnit1 = AstFactory.compilationUnit(); | |
| 461 CompilationUnit partUnit2 = AstFactory.compilationUnit(); | |
| 462 context.getCacheEntry(librarySource).setValue(RESOLVED_UNIT1, libraryUnit); | |
| 463 context.getCacheEntry(partSource1).setValue(RESOLVED_UNIT1, partUnit1); | |
| 464 context.getCacheEntry(partSource2).setValue(RESOLVED_UNIT1, partUnit2); | |
| 465 // request inputs | |
| 466 WorkItem workItem = new WorkItem( | |
| 467 context, librarySource, BuildLibraryElementTask.DESCRIPTOR); | |
| 468 workItem.gatherInputs(null); | |
| 469 Map<String, dynamic> inputs = workItem.inputs; | |
| 470 expect(inputs, hasLength(2)); | |
| 471 expect(inputs[BuildLibraryElementTask.DEFINING_RESOLVER_UNIT1_INPUT_NAME], | |
| 472 libraryUnit); | |
| 473 expect(inputs[BuildLibraryElementTask.PARTS_RESOLVED_UNIT1_INPUT_NAME], | |
| 474 unorderedEquals([partUnit1, partUnit2])); | |
| 475 } | |
| 476 | |
| 477 test_constructor() { | 448 test_constructor() { |
| 478 BuildLibraryElementTask task = | 449 BuildLibraryElementTask task = |
| 479 new BuildLibraryElementTask(context, emptySource); | 450 new BuildLibraryElementTask(context, emptySource); |
| 480 expect(task, isNotNull); | 451 expect(task, isNotNull); |
| 481 expect(task.context, context); | 452 expect(task.context, context); |
| 482 expect(task.target, emptySource); | 453 expect(task.target, emptySource); |
| 483 } | 454 } |
| 484 | 455 |
| 485 test_createTask() { | 456 test_createTask() { |
| 486 BuildLibraryElementTask task = | 457 BuildLibraryElementTask task = |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 return entryMap.putIfAbsent(target, () => new CacheEntry()); | 984 return entryMap.putIfAbsent(target, () => new CacheEntry()); |
| 1014 } | 985 } |
| 1015 | 986 |
| 1016 TimestampedData<String> getContents(Source source) => source.contents; | 987 TimestampedData<String> getContents(Source source) => source.contents; |
| 1017 | 988 |
| 1018 noSuchMethod(Invocation invocation) { | 989 noSuchMethod(Invocation invocation) { |
| 1019 print('noSuchMethod: ${invocation.memberName}'); | 990 print('noSuchMethod: ${invocation.memberName}'); |
| 1020 return super.noSuchMethod(invocation); | 991 return super.noSuchMethod(invocation); |
| 1021 } | 992 } |
| 1022 } | 993 } |
| OLD | NEW |