| OLD | NEW |
| 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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 _context = AnalysisContextFactory.contextWithCore(); | 1015 _context = AnalysisContextFactory.contextWithCore(); |
| 1016 _sourceFactory = _context.sourceFactory; | 1016 _sourceFactory = _context.sourceFactory; |
| 1017 Source source = _addSource("/test.dart", "library lib;"); | 1017 Source source = _addSource("/test.dart", "library lib;"); |
| 1018 LibraryElement element = _context.getLibraryElement(source); | 1018 LibraryElement element = _context.getLibraryElement(source); |
| 1019 expect(element, isNull); | 1019 expect(element, isNull); |
| 1020 _context.computeLibraryElement(source); | 1020 _context.computeLibraryElement(source); |
| 1021 element = _context.getLibraryElement(source); | 1021 element = _context.getLibraryElement(source); |
| 1022 expect(element, isNotNull); | 1022 expect(element, isNotNull); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 Future test_getLibraryElementFuture() { |
| 1026 _context = AnalysisContextFactory.contextWithCore(); |
| 1027 _sourceFactory = _context.sourceFactory; |
| 1028 Source source = _addSource("/test.dart", "library lib;"); |
| 1029 bool completed = false; |
| 1030 _context.getLibraryElementFuture(source).then((LibraryElement element) { |
| 1031 expect(element, isNotNull); |
| 1032 completed = true; |
| 1033 }); |
| 1034 return pumpEventQueue().then((_) { |
| 1035 expect(completed, isFalse); |
| 1036 while (_context.performAnalysisTask().hasMoreWork) {} |
| 1037 }).then((_) => pumpEventQueue()).then((_) { |
| 1038 expect(completed, isTrue); |
| 1039 }); |
| 1040 } |
| 1041 |
| 1025 void test_getLibrarySources() { | 1042 void test_getLibrarySources() { |
| 1026 List<Source> sources = _context.librarySources; | 1043 List<Source> sources = _context.librarySources; |
| 1027 int originalLength = sources.length; | 1044 int originalLength = sources.length; |
| 1028 Source source = _addSource("/test.dart", "library lib;"); | 1045 Source source = _addSource("/test.dart", "library lib;"); |
| 1029 _context.computeKindOf(source); | 1046 _context.computeKindOf(source); |
| 1030 sources = _context.librarySources; | 1047 sources = _context.librarySources; |
| 1031 expect(sources, hasLength(originalLength + 1)); | 1048 expect(sources, hasLength(originalLength + 1)); |
| 1032 for (Source returnedSource in sources) { | 1049 for (Source returnedSource in sources) { |
| 1033 if (returnedSource == source) { | 1050 if (returnedSource == source) { |
| 1034 return; | 1051 return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | 1138 |
| 1122 void test_getResolvedCompilationUnit_source_html() { | 1139 void test_getResolvedCompilationUnit_source_html() { |
| 1123 _context = AnalysisContextFactory.contextWithCore(); | 1140 _context = AnalysisContextFactory.contextWithCore(); |
| 1124 _sourceFactory = _context.sourceFactory; | 1141 _sourceFactory = _context.sourceFactory; |
| 1125 Source source = _addSource("/test.html", "<html></html>"); | 1142 Source source = _addSource("/test.html", "<html></html>"); |
| 1126 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 1143 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1127 expect(_context.resolveCompilationUnit2(source, source), isNull); | 1144 expect(_context.resolveCompilationUnit2(source, source), isNull); |
| 1128 expect(_context.getResolvedCompilationUnit2(source, source), isNull); | 1145 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1129 } | 1146 } |
| 1130 | 1147 |
| 1148 Future test_getResolvedCompilationUnitFuture() { |
| 1149 _context = AnalysisContextFactory.contextWithCore(); |
| 1150 _sourceFactory = _context.sourceFactory; |
| 1151 Source source = _addSource("/lib.dart", "library lib;"); |
| 1152 LibraryElement library = _context.computeLibraryElement(source); |
| 1153 // Complete all pending analysis tasks and flush the AST so that it won't |
| 1154 // be available immediately. |
| 1155 while (_context.performAnalysisTask().hasMoreWork) {} |
| 1156 DartEntry dartEntry = _context.getReadableSourceEntryOrNull(source); |
| 1157 dartEntry.flushAstStructures(); |
| 1158 bool completed = false; |
| 1159 _context.getResolvedCompilationUnitFuture( |
| 1160 source, |
| 1161 library).then((CompilationUnit unit) { |
| 1162 expect(unit, isNotNull); |
| 1163 completed = true; |
| 1164 }); |
| 1165 return pumpEventQueue().then((_) { |
| 1166 expect(completed, isFalse); |
| 1167 while (_context.performAnalysisTask().hasMoreWork) {} |
| 1168 }).then((_) => pumpEventQueue()).then((_) { |
| 1169 expect(completed, isTrue); |
| 1170 }); |
| 1171 } |
| 1172 |
| 1173 Future test_getResolvedCompilationUnitFuture_unrelatedLibrary() { |
| 1174 _context = AnalysisContextFactory.contextWithCore(); |
| 1175 _sourceFactory = _context.sourceFactory; |
| 1176 Source librarySource = _addSource("/lib.dart", "library lib;"); |
| 1177 LibraryElement library = _context.computeLibraryElement(librarySource); |
| 1178 Source partSource = _addSource("/part.dart", "part of foo;"); |
| 1179 bool completed = false; |
| 1180 _context.getResolvedCompilationUnitFuture(partSource, library).then((_) { |
| 1181 fail('Expected resolution to fail'); |
| 1182 }, onError: (e) { |
| 1183 expect(e, new isInstanceOf<AnalysisNotScheduledError>()); |
| 1184 completed = true; |
| 1185 }); |
| 1186 return pumpEventQueue().then((_) { |
| 1187 expect(completed, isFalse); |
| 1188 while (_context.performAnalysisTask().hasMoreWork) {} |
| 1189 }).then((_) => pumpEventQueue()).then((_) { |
| 1190 expect(completed, isTrue); |
| 1191 }); |
| 1192 } |
| 1193 |
| 1131 void test_getResolvedHtmlUnit() { | 1194 void test_getResolvedHtmlUnit() { |
| 1132 _context = AnalysisContextFactory.contextWithCore(); | 1195 _context = AnalysisContextFactory.contextWithCore(); |
| 1133 _sourceFactory = _context.sourceFactory; | 1196 _sourceFactory = _context.sourceFactory; |
| 1134 Source source = _addSource("/test.html", "<html></html>"); | 1197 Source source = _addSource("/test.html", "<html></html>"); |
| 1135 expect(_context.getResolvedHtmlUnit(source), isNull); | 1198 expect(_context.getResolvedHtmlUnit(source), isNull); |
| 1136 _context.resolveHtmlUnit(source); | 1199 _context.resolveHtmlUnit(source); |
| 1137 expect(_context.getResolvedHtmlUnit(source), isNotNull); | 1200 expect(_context.getResolvedHtmlUnit(source), isNotNull); |
| 1138 } | 1201 } |
| 1139 | 1202 |
| 1140 void test_getSourceFactory() { | 1203 void test_getSourceFactory() { |
| (...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3885 } | 3948 } |
| 3886 expect(task.libraryElement, same(libraryElement)); | 3949 expect(task.libraryElement, same(libraryElement)); |
| 3887 expect(task.source, same(source)); | 3950 expect(task.source, same(source)); |
| 3888 List<AnalysisError> errors = task.errors; | 3951 List<AnalysisError> errors = task.errors; |
| 3889 expect(errors, hasLength(1)); | 3952 expect(errors, hasLength(1)); |
| 3890 expect(errors[0].errorCode, same(CompileTimeErrorCode.URI_DOES_NOT_EXIST)); | 3953 expect(errors[0].errorCode, same(CompileTimeErrorCode.URI_DOES_NOT_EXIST)); |
| 3891 return true; | 3954 return true; |
| 3892 } | 3955 } |
| 3893 } | 3956 } |
| 3894 | 3957 |
| 3958 |
| 3895 @ReflectiveTestCase() | 3959 @ReflectiveTestCase() |
| 3896 class GenerateDartHintsTaskTest extends EngineTestCase { | 3960 class GenerateDartHintsTaskTest extends EngineTestCase { |
| 3897 void test_accept() { | 3961 void test_accept() { |
| 3898 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3962 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3899 expect(task.accept(new GenerateDartHintsTaskTestTV_accept()), isTrue); | 3963 expect(task.accept(new GenerateDartHintsTaskTestTV_accept()), isTrue); |
| 3900 } | 3964 } |
| 3901 void test_getException() { | 3965 void test_getException() { |
| 3902 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3966 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3903 expect(task.exception, isNull); | 3967 expect(task.exception, isNull); |
| 3904 } | 3968 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3947 new GenerateDartHintsTaskTestTV_perform(librarySource, partSource)); | 4011 new GenerateDartHintsTaskTestTV_perform(librarySource, partSource)); |
| 3948 } | 4012 } |
| 3949 } | 4013 } |
| 3950 | 4014 |
| 3951 | 4015 |
| 3952 class GenerateDartHintsTaskTestTV_accept extends TestTaskVisitor<bool> { | 4016 class GenerateDartHintsTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 3953 @override | 4017 @override |
| 3954 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) => true; | 4018 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) => true; |
| 3955 } | 4019 } |
| 3956 | 4020 |
| 3957 | |
| 3958 class GenerateDartHintsTaskTestTV_perform extends TestTaskVisitor<bool> { | 4021 class GenerateDartHintsTaskTestTV_perform extends TestTaskVisitor<bool> { |
| 3959 Source librarySource; | 4022 Source librarySource; |
| 3960 Source partSource; | 4023 Source partSource; |
| 3961 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); | 4024 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); |
| 3962 @override | 4025 @override |
| 3963 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { | 4026 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 3964 CaughtException exception = task.exception; | 4027 CaughtException exception = task.exception; |
| 3965 if (exception != null) { | 4028 if (exception != null) { |
| 3966 throw exception; | 4029 throw exception; |
| 3967 } | 4030 } |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4820 Scanner scanner = new Scanner( | 4883 Scanner scanner = new Scanner( |
| 4821 _source, | 4884 _source, |
| 4822 new CharSequenceReader(code), | 4885 new CharSequenceReader(code), |
| 4823 AnalysisErrorListener.NULL_LISTENER); | 4886 AnalysisErrorListener.NULL_LISTENER); |
| 4824 Parser parser = new Parser(_source, AnalysisErrorListener.NULL_LISTENER); | 4887 Parser parser = new Parser(_source, AnalysisErrorListener.NULL_LISTENER); |
| 4825 return parser.parseCompilationUnit(scanner.tokenize()); | 4888 return parser.parseCompilationUnit(scanner.tokenize()); |
| 4826 } | 4889 } |
| 4827 } | 4890 } |
| 4828 | 4891 |
| 4829 | 4892 |
| 4830 | |
| 4831 @ReflectiveTestCase() | 4893 @ReflectiveTestCase() |
| 4832 class IncrementalAnalysisTaskTest extends EngineTestCase { | 4894 class IncrementalAnalysisTaskTest extends EngineTestCase { |
| 4833 void test_accept() { | 4895 void test_accept() { |
| 4834 IncrementalAnalysisTask task = new IncrementalAnalysisTask(null, null); | 4896 IncrementalAnalysisTask task = new IncrementalAnalysisTask(null, null); |
| 4835 expect(task.accept(new IncrementalAnalysisTaskTestTV_accept()), isTrue); | 4897 expect(task.accept(new IncrementalAnalysisTaskTestTV_accept()), isTrue); |
| 4836 } | 4898 } |
| 4837 | 4899 |
| 4838 void test_perform() { | 4900 void test_perform() { |
| 4839 // main() {} String foo; | 4901 // main() {} String foo; |
| 4840 // main() {String} String foo; | 4902 // main() {String} String foo; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4886 } | 4948 } |
| 4887 } | 4949 } |
| 4888 | 4950 |
| 4889 | 4951 |
| 4890 class IncrementalAnalysisTaskTestTV_accept extends TestTaskVisitor<bool> { | 4952 class IncrementalAnalysisTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 4891 @override | 4953 @override |
| 4892 bool visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => true; | 4954 bool visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => true; |
| 4893 } | 4955 } |
| 4894 | 4956 |
| 4895 | 4957 |
| 4958 |
| 4896 class IncrementalAnalysisTaskTestTV_assertTask extends | 4959 class IncrementalAnalysisTaskTestTV_assertTask extends |
| 4897 TestTaskVisitor<CompilationUnit> { | 4960 TestTaskVisitor<CompilationUnit> { |
| 4898 IncrementalAnalysisTask task; | 4961 IncrementalAnalysisTask task; |
| 4899 IncrementalAnalysisTaskTestTV_assertTask(this.task); | 4962 IncrementalAnalysisTaskTestTV_assertTask(this.task); |
| 4900 @override | 4963 @override |
| 4901 CompilationUnit | 4964 CompilationUnit |
| 4902 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) => | 4965 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) => |
| 4903 task.compilationUnit; | 4966 task.compilationUnit; |
| 4904 } | 4967 } |
| 4905 | 4968 |
| (...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6001 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { | 6064 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
| 6002 fail("Unexpected invocation of getLibrariesReferencedFromHtml"); | 6065 fail("Unexpected invocation of getLibrariesReferencedFromHtml"); |
| 6003 return null; | 6066 return null; |
| 6004 } | 6067 } |
| 6005 @override | 6068 @override |
| 6006 LibraryElement getLibraryElement(Source source) { | 6069 LibraryElement getLibraryElement(Source source) { |
| 6007 fail("Unexpected invocation of getLibraryElement"); | 6070 fail("Unexpected invocation of getLibraryElement"); |
| 6008 return null; | 6071 return null; |
| 6009 } | 6072 } |
| 6010 @override | 6073 @override |
| 6074 Future<LibraryElement> getLibraryElementFuture(Source source) { |
| 6075 fail("Unexpected invocation of getLibraryElementFuture"); |
| 6076 return null; |
| 6077 } |
| 6078 @override |
| 6011 LineInfo getLineInfo(Source source) { | 6079 LineInfo getLineInfo(Source source) { |
| 6012 fail("Unexpected invocation of getLineInfo"); | 6080 fail("Unexpected invocation of getLineInfo"); |
| 6013 return null; | 6081 return null; |
| 6014 } | 6082 } |
| 6015 @override | 6083 @override |
| 6016 int getModificationStamp(Source source) { | 6084 int getModificationStamp(Source source) { |
| 6017 fail("Unexpected invocation of getModificationStamp"); | 6085 fail("Unexpected invocation of getModificationStamp"); |
| 6018 return 0; | 6086 return 0; |
| 6019 } | 6087 } |
| 6020 @override | 6088 @override |
| 6021 Namespace getPublicNamespace(LibraryElement library) { | 6089 Namespace getPublicNamespace(LibraryElement library) { |
| 6022 fail("Unexpected invocation of getPublicNamespace"); | 6090 fail("Unexpected invocation of getPublicNamespace"); |
| 6023 return null; | 6091 return null; |
| 6024 } | 6092 } |
| 6025 @override | 6093 @override |
| 6026 CompilationUnit getResolvedCompilationUnit(Source unitSource, | 6094 CompilationUnit getResolvedCompilationUnit(Source unitSource, |
| 6027 LibraryElement library) { | 6095 LibraryElement library) { |
| 6028 fail("Unexpected invocation of getResolvedCompilationUnit"); | 6096 fail("Unexpected invocation of getResolvedCompilationUnit"); |
| 6029 return null; | 6097 return null; |
| 6030 } | 6098 } |
| 6031 @override | 6099 @override |
| 6032 CompilationUnit getResolvedCompilationUnit2(Source unitSource, | 6100 CompilationUnit getResolvedCompilationUnit2(Source unitSource, |
| 6033 Source librarySource) { | 6101 Source librarySource) { |
| 6034 fail("Unexpected invocation of getResolvedCompilationUnit"); | 6102 fail("Unexpected invocation of getResolvedCompilationUnit"); |
| 6035 return null; | 6103 return null; |
| 6036 } | 6104 } |
| 6037 @override | 6105 @override |
| 6106 Future<CompilationUnit> getResolvedCompilationUnitFuture(Source source, |
| 6107 LibraryElement library) { |
| 6108 fail("Unexpected invocation of getResolvedCompilationUnitFuture"); |
| 6109 return null; |
| 6110 } |
| 6111 @override |
| 6038 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 6112 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 6039 fail("Unexpected invocation of getResolvedHtmlUnit"); | 6113 fail("Unexpected invocation of getResolvedHtmlUnit"); |
| 6040 return null; | 6114 return null; |
| 6041 } | 6115 } |
| 6042 @override | 6116 @override |
| 6043 bool isClientLibrary(Source librarySource) { | 6117 bool isClientLibrary(Source librarySource) { |
| 6044 fail("Unexpected invocation of isClientLibrary"); | 6118 fail("Unexpected invocation of isClientLibrary"); |
| 6045 return false; | 6119 return false; |
| 6046 } | 6120 } |
| 6047 @override | 6121 @override |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6091 } | 6165 } |
| 6092 @override | 6166 @override |
| 6093 void setChangedContents(Source source, String contents, int offset, | 6167 void setChangedContents(Source source, String contents, int offset, |
| 6094 int oldLength, int newLength) { | 6168 int oldLength, int newLength) { |
| 6095 fail("Unexpected invocation of setChangedContents"); | 6169 fail("Unexpected invocation of setChangedContents"); |
| 6096 } | 6170 } |
| 6097 @override | 6171 @override |
| 6098 void setContents(Source source, String contents) { | 6172 void setContents(Source source, String contents) { |
| 6099 fail("Unexpected invocation of setContents"); | 6173 fail("Unexpected invocation of setContents"); |
| 6100 } | 6174 } |
| 6175 |
| 6101 @override | 6176 @override |
| 6102 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, | 6177 void visitCacheItems(void callback(Source source, SourceEntry dartEntry, |
| 6103 DataDescriptor rowDesc, CacheState state)) { | 6178 DataDescriptor rowDesc, CacheState state)) { |
| 6104 fail("Unexpected invocation of visitCacheItems"); | 6179 fail("Unexpected invocation of visitCacheItems"); |
| 6105 } | 6180 } |
| 6106 } | 6181 } |
| 6107 | 6182 |
| 6108 | 6183 |
| 6109 class TestAnalysisContext_test_addSourceInfo extends TestAnalysisContext { | 6184 class TestAnalysisContext_test_addSourceInfo extends TestAnalysisContext { |
| 6110 bool invoked = false; | 6185 bool invoked = false; |
| (...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7001 bool contains(Source source) => source == libB; | 7076 bool contains(Source source) => source == libB; |
| 7002 } | 7077 } |
| 7003 | 7078 |
| 7004 | 7079 |
| 7005 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 7080 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 7006 CacheRetentionPolicy { | 7081 CacheRetentionPolicy { |
| 7007 @override | 7082 @override |
| 7008 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 7083 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7009 RetentionPriority.LOW; | 7084 RetentionPriority.LOW; |
| 7010 } | 7085 } |
| OLD | NEW |