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

Side by Side Diff: pkg/analyzer/test/generated/engine_test.dart

Issue 848463003: Pluggable lint verifiers first step and basic lint task tests. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine.engine_test; 8 library engine.engine_test;
9 9
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 main() { 44 main() {
45 groupSep = ' | '; 45 groupSep = ' | ';
46 runReflectiveTests(AnalysisCacheTest); 46 runReflectiveTests(AnalysisCacheTest);
47 runReflectiveTests(AnalysisContextImplTest); 47 runReflectiveTests(AnalysisContextImplTest);
48 runReflectiveTests(AnalysisTaskTest); 48 runReflectiveTests(AnalysisTaskTest);
49 runReflectiveTests(AnalysisOptionsImplTest); 49 runReflectiveTests(AnalysisOptionsImplTest);
50 runReflectiveTests(DartEntryTest); 50 runReflectiveTests(DartEntryTest);
51 runReflectiveTests(GenerateDartErrorsTaskTest); 51 runReflectiveTests(GenerateDartErrorsTaskTest);
52 runReflectiveTests(GenerateDartHintsTaskTest); 52 runReflectiveTests(GenerateDartHintsTaskTest);
53 runReflectiveTests(GenerateDartLintsTaskTest);
53 runReflectiveTests(GetContentTaskTest); 54 runReflectiveTests(GetContentTaskTest);
54 runReflectiveTests(HtmlEntryTest); 55 runReflectiveTests(HtmlEntryTest);
55 runReflectiveTests(IncrementalAnalysisCacheTest); 56 runReflectiveTests(IncrementalAnalysisCacheTest);
56 runReflectiveTests(IncrementalAnalysisTaskTest); 57 runReflectiveTests(IncrementalAnalysisTaskTest);
58 runReflectiveTests(LintGeneratorTest);
57 runReflectiveTests(ParseDartTaskTest); 59 runReflectiveTests(ParseDartTaskTest);
58 runReflectiveTests(ParseHtmlTaskTest); 60 runReflectiveTests(ParseHtmlTaskTest);
59 runReflectiveTests(PartitionManagerTest); 61 runReflectiveTests(PartitionManagerTest);
60 runReflectiveTests(ResolveDartLibraryTaskTest); 62 runReflectiveTests(ResolveDartLibraryTaskTest);
61 runReflectiveTests(ResolveDartUnitTaskTest); 63 runReflectiveTests(ResolveDartUnitTaskTest);
62 runReflectiveTests(ResolveHtmlTaskTest); 64 runReflectiveTests(ResolveHtmlTaskTest);
63 runReflectiveTests(ScanDartTaskTest); 65 runReflectiveTests(ScanDartTaskTest);
64 runReflectiveTests(SdkCachePartitionTest); 66 runReflectiveTests(SdkCachePartitionTest);
65 runReflectiveTests(SourcesChangedEventTest); 67 runReflectiveTests(SourcesChangedEventTest);
66 runReflectiveTests(UniversalCachePartitionTest); 68 runReflectiveTests(UniversalCachePartitionTest);
(...skipping 3930 matching lines...) Expand 10 before | Expand all | Expand 10 after
3997 } 3999 }
3998 expect(task.libraryElement, isNotNull); 4000 expect(task.libraryElement, isNotNull);
3999 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; 4001 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap;
4000 expect(hintMap, hasLength(2)); 4002 expect(hintMap, hasLength(2));
4001 expect(hintMap[librarySource], hasLength(1)); 4003 expect(hintMap[librarySource], hasLength(1));
4002 expect(hintMap[partSource], hasLength(0)); 4004 expect(hintMap[partSource], hasLength(0));
4003 return true; 4005 return true;
4004 } 4006 }
4005 } 4007 }
4006 4008
4009 @ReflectiveTestCase()
4010 class GenerateDartLintsTaskTest extends EngineTestCase {
4011 void test_accept() {
4012 GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null);
4013 expect(task.accept(new GenerateDartLintsTaskTestTV_accept()), isTrue);
4014 }
4015 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!
4016 GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null);
4017 expect(task.exception, isNull);
4018 }
4019 void test_getLintMap() {
4020 GenerateDartLintsTask task = new GenerateDartLintsTask(null, null, null);
4021 expect(task.lintMap, isNull);
4022 }
4023 void test_getLibraryElement() {
4024 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
4025 LibraryElement element = ElementFactory.library(context, "lib");
4026 GenerateDartLintsTask task =
4027 new GenerateDartLintsTask(context, null, element);
4028 expect(task.libraryElement, same(element));
4029 }
4030
4031 void test_perform() {
4032 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
4033 ChangeSet changeSet = new ChangeSet();
4034 Source librarySource =
4035 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
4036 changeSet.addedSource(librarySource);
4037 context.applyChanges(changeSet);
4038 context.setContents(librarySource, r'''
4039 library lib;
4040 ''');
4041 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(1);
4042 units[0] = new TimestampedData<CompilationUnit>(
4043 context.getModificationStamp(librarySource),
4044 context.resolveCompilationUnit2(librarySource, librarySource));
4045 GenerateDartLintsTask task = new GenerateDartLintsTask(
4046 context,
4047 units,
4048 context.computeLibraryElement(librarySource));
4049 task.perform(new GenerateDartLintsTaskTestTV_perform(librarySource));
4050 }
4051 }
4052
4053 class GenerateDartLintsTaskTestTV_accept extends TestTaskVisitor<bool> {
4054 @override
4055 bool visitGenerateDartLintsTask(GenerateDartLintsTask task) => true;
4056 }
4057
4058 class GenerateDartLintsTaskTestTV_perform extends TestTaskVisitor<bool> {
4059 Source librarySource;
4060 GenerateDartLintsTaskTestTV_perform(this.librarySource);
4061 @override
4062 bool visitGenerateDartLintsTask(GenerateDartLintsTask task) {
4063 CaughtException exception = task.exception;
4064 if (exception != null) {
4065 throw exception;
4066 }
4067 expect(task.libraryElement, isNotNull);
4068 return true;
4069 }
4070 }
4071
4072 @ReflectiveTestCase()
4073 class LintGeneratorTest extends EngineTestCase {
4074 void test_generate() {
4075
4076 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore();
4077 ChangeSet changeSet = new ChangeSet();
4078 Source librarySource =
4079 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
4080 changeSet.addedSource(librarySource);
4081 context.applyChanges(changeSet);
4082 context.setContents(librarySource, r'''
4083 library lib;
4084 ''');
4085
4086 CompilationUnit unit =
4087 context.resolveCompilationUnit2(librarySource, librarySource);
4088 List<CompilationUnit> units = <CompilationUnit>[];
4089 units.add(unit);
4090
4091 RecordingErrorListener errorListener = new RecordingErrorListener();
4092
4093 LintGeneratorTest_Verifier verifier = new LintGeneratorTest_Verifier();
4094
4095 LintGenerator lintGenerator =
4096 new LintGenerator(units, errorListener, [verifier]);
4097 lintGenerator.generate();
4098
4099 verifier.testExpectations();
4100 }
4101 }
4102
4103
4104 class LintGeneratorTest_Verifier extends LintVerifier {
4105
4106 bool visited;
4107
4108 @override
4109 Object visitCompilationUnit(CompilationUnit node) {
4110 visited = true;
4111 return null;
4112 }
4113
4114 testExpectations() {
4115 expect(reporter, isNotNull);
4116 expect(visited, isTrue);
4117 }
4118 }
4119
4007 4120
4008 @ReflectiveTestCase() 4121 @ReflectiveTestCase()
4009 class GetContentTaskTest extends EngineTestCase { 4122 class GetContentTaskTest extends EngineTestCase {
4010 void test_accept() { 4123 void test_accept() {
4011 Source source = new TestSource('/test.dart', ''); 4124 Source source = new TestSource('/test.dart', '');
4012 GetContentTask task = new GetContentTask(null, source); 4125 GetContentTask task = new GetContentTask(null, source);
4013 expect(task.accept(new GetContentTaskTestTV_accept()), isTrue); 4126 expect(task.accept(new GetContentTaskTestTV_accept()), isTrue);
4014 } 4127 }
4015 4128
4016 void test_getException() { 4129 void test_getException() {
(...skipping 2908 matching lines...) Expand 10 before | Expand all | Expand 10 after
6925 bool contains(Source source) => source == libB; 7038 bool contains(Source source) => source == libB;
6926 } 7039 }
6927 7040
6928 7041
6929 class _UniversalCachePartitionTest_test_setMaxCacheSize implements 7042 class _UniversalCachePartitionTest_test_setMaxCacheSize implements
6930 CacheRetentionPolicy { 7043 CacheRetentionPolicy {
6931 @override 7044 @override
6932 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => 7045 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) =>
6933 RetentionPriority.LOW; 7046 RetentionPriority.LOW;
6934 } 7047 }
OLDNEW
« pkg/analyzer/lib/src/generated/resolver.dart ('K') | « pkg/analyzer/lib/src/generated/resolver.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698