Chromium Code Reviews| Index: pkg/analyzer/test/generated/engine_test.dart |
| =================================================================== |
| --- pkg/analyzer/test/generated/engine_test.dart (revision 42759) |
| +++ pkg/analyzer/test/generated/engine_test.dart (working copy) |
| @@ -50,10 +50,12 @@ |
| runReflectiveTests(DartEntryTest); |
| runReflectiveTests(GenerateDartErrorsTaskTest); |
| runReflectiveTests(GenerateDartHintsTaskTest); |
| + runReflectiveTests(GenerateDartLintsTaskTest); |
| runReflectiveTests(GetContentTaskTest); |
| runReflectiveTests(HtmlEntryTest); |
| runReflectiveTests(IncrementalAnalysisCacheTest); |
| runReflectiveTests(IncrementalAnalysisTaskTest); |
| + runReflectiveTests(LintGeneratorTest); |
| runReflectiveTests(ParseDartTaskTest); |
| runReflectiveTests(ParseHtmlTaskTest); |
| runReflectiveTests(PartitionManagerTest); |
| @@ -4004,8 +4006,119 @@ |
| } |
| } |
| +@ReflectiveTestCase() |
| +class GenerateDartLintsTaskTest extends EngineTestCase { |
| + void test_accept() { |
| + GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null); |
| + expect(task.accept(new GenerateDartLintsTaskTestTV_accept()), isTrue); |
| + } |
| + void test_getException() { |
|
Brian Wilkerson
2015/01/10 00:26:53
Ah. The tests didn't get renamed when the methods
pquitslund
2015/01/12 16:44:43
Ah, got it. Fixed!
|
| + GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null); |
| + expect(task.exception, isNull); |
| + } |
| + void test_getLintMap() { |
| + GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null); |
| + expect(task.lintMap, isNull); |
| + } |
| + void test_getLibraryElement() { |
| + InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| + LibraryElement element = ElementFactory.library(context, "lib"); |
| + GenerateDartLintsTask task = |
| + new GenerateDartLintsTask(context, null, element); |
| + expect(task.libraryElement, same(element)); |
| + } |
| + void test_perform() { |
| + InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| + ChangeSet changeSet = new ChangeSet(); |
| + Source librarySource = |
| + new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| + changeSet.addedSource(librarySource); |
| + context.applyChanges(changeSet); |
| + context.setContents(librarySource, r''' |
| +library lib; |
| +'''); |
| + List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(1); |
| + units[0] = new TimestampedData<CompilationUnit>( |
| + context.getModificationStamp(librarySource), |
| + context.resolveCompilationUnit2(librarySource, librarySource)); |
| + GenerateDartLintsTask task = new GenerateDartLintsTask( |
| + context, |
| + units, |
| + context.computeLibraryElement(librarySource)); |
| + task.perform(new GenerateDartLintsTaskTestTV_perform(librarySource)); |
| + } |
| +} |
| + |
| +class GenerateDartLintsTaskTestTV_accept extends TestTaskVisitor<bool> { |
| + @override |
| + bool visitGenerateDartLintsTask(GenerateDartLintsTask task) => true; |
| +} |
| + |
| +class GenerateDartLintsTaskTestTV_perform extends TestTaskVisitor<bool> { |
| + Source librarySource; |
| + GenerateDartLintsTaskTestTV_perform(this.librarySource); |
| + @override |
| + bool visitGenerateDartLintsTask(GenerateDartLintsTask task) { |
| + CaughtException exception = task.exception; |
| + if (exception != null) { |
| + throw exception; |
| + } |
| + expect(task.libraryElement, isNotNull); |
| + return true; |
| + } |
| +} |
| + |
| @ReflectiveTestCase() |
| +class LintGeneratorTest extends EngineTestCase { |
| + void test_generate() { |
| + |
| + InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| + ChangeSet changeSet = new ChangeSet(); |
| + Source librarySource = |
| + new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| + changeSet.addedSource(librarySource); |
| + context.applyChanges(changeSet); |
| + context.setContents(librarySource, r''' |
| +library lib; |
| +'''); |
| + |
| + CompilationUnit unit = |
| + context.resolveCompilationUnit2(librarySource, librarySource); |
| + List<CompilationUnit> units = <CompilationUnit>[]; |
| + units.add(unit); |
| + |
| + RecordingErrorListener errorListener = new RecordingErrorListener(); |
| + |
| + LintGeneratorTest_Verifier verifier = new LintGeneratorTest_Verifier(); |
| + |
| + LintGenerator lintGenerator = |
| + new LintGenerator(units, errorListener, [verifier]); |
| + lintGenerator.generate(); |
| + |
| + verifier.testExpectations(); |
| + } |
| +} |
| + |
| + |
| +class LintGeneratorTest_Verifier extends LintVerifier { |
| + |
| + bool visited; |
| + |
| + @override |
| + Object visitCompilationUnit(CompilationUnit node) { |
| + visited = true; |
| + return null; |
| + } |
| + |
| + testExpectations() { |
| + expect(reporter, isNotNull); |
| + expect(visited, isTrue); |
| + } |
| +} |
| + |
| + |
| +@ReflectiveTestCase() |
| class GetContentTaskTest extends EngineTestCase { |
| void test_accept() { |
| Source source = new TestSource('/test.dart', ''); |