| 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:collection'; | 10 import 'dart:collection'; |
| 11 | 11 |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/constant.dart'; | 13 import 'package:analyzer/src/generated/constant.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 15 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/error.dart'; | 16 import 'package:analyzer/src/generated/error.dart'; |
| 17 import 'package:analyzer/src/generated/html.dart' as ht; | 17 import 'package:analyzer/src/generated/html.dart' as ht; |
| 18 import 'package:analyzer/src/generated/java_core.dart'; | 18 import 'package:analyzer/src/generated/java_core.dart'; |
| 19 import 'package:analyzer/src/generated/java_engine.dart'; | 19 import 'package:analyzer/src/generated/java_engine.dart'; |
| 20 import 'package:analyzer/src/generated/java_engine_io.dart'; | 20 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 21 import 'package:analyzer/src/generated/java_junit.dart'; | |
| 22 import 'package:analyzer/src/generated/parser.dart'; | 21 import 'package:analyzer/src/generated/parser.dart'; |
| 23 import 'package:analyzer/src/generated/resolver.dart'; | 22 import 'package:analyzer/src/generated/resolver.dart'; |
| 24 import 'package:analyzer/src/generated/scanner.dart'; | 23 import 'package:analyzer/src/generated/scanner.dart'; |
| 25 import 'package:analyzer/src/generated/sdk.dart'; | 24 import 'package:analyzer/src/generated/sdk.dart'; |
| 26 import 'package:analyzer/src/generated/sdk_io.dart'; | 25 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 27 import 'package:analyzer/src/generated/source_io.dart'; | 26 import 'package:analyzer/src/generated/source_io.dart'; |
| 28 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 27 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 29 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 28 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 30 import 'package:analyzer/src/generated/utilities_collection.dart'; | 29 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 31 import 'package:analyzer/src/task/task_dart.dart'; | 30 import 'package:analyzer/src/task/task_dart.dart'; |
| 32 import 'package:typed_mock/typed_mock.dart'; | 31 import 'package:typed_mock/typed_mock.dart'; |
| 33 import 'package:unittest/unittest.dart' as _ut; | 32 import 'package:unittest/unittest.dart'; |
| 34 | 33 |
| 35 import 'all_the_rest.dart'; | 34 import 'all_the_rest.dart'; |
| 36 import 'resolver_test.dart'; | 35 import 'resolver_test.dart'; |
| 37 import 'test_support.dart'; | 36 import 'test_support.dart'; |
| 38 import '../reflective_tests.dart'; | 37 import '../reflective_tests.dart'; |
| 39 | 38 |
| 40 | 39 |
| 41 main() { | 40 main() { |
| 42 _ut.groupSep = ' | '; | 41 groupSep = ' | '; |
| 43 runReflectiveTests(AnalysisCacheTest); | 42 runReflectiveTests(AnalysisCacheTest); |
| 44 runReflectiveTests(AnalysisContextImplTest); | 43 runReflectiveTests(AnalysisContextImplTest); |
| 45 runReflectiveTests(AnalysisTaskTest); | 44 runReflectiveTests(AnalysisTaskTest); |
| 46 runReflectiveTests(AnalysisOptionsImplTest); | 45 runReflectiveTests(AnalysisOptionsImplTest); |
| 47 runReflectiveTests(DartEntryTest); | 46 runReflectiveTests(DartEntryTest); |
| 48 runReflectiveTests(GenerateDartErrorsTaskTest); | 47 runReflectiveTests(GenerateDartErrorsTaskTest); |
| 49 runReflectiveTests(GenerateDartHintsTaskTest); | 48 runReflectiveTests(GenerateDartHintsTaskTest); |
| 50 runReflectiveTests(GetContentTaskTest); | 49 runReflectiveTests(GetContentTaskTest); |
| 51 runReflectiveTests(HtmlEntryTest); | 50 runReflectiveTests(HtmlEntryTest); |
| 52 runReflectiveTests(IncrementalAnalysisCacheTest); | 51 runReflectiveTests(IncrementalAnalysisCacheTest); |
| 53 runReflectiveTests(InstrumentedAnalysisContextImplTest); | 52 runReflectiveTests(InstrumentedAnalysisContextImplTest); |
| 54 runReflectiveTests(IncrementalAnalysisTaskTest); | 53 runReflectiveTests(IncrementalAnalysisTaskTest); |
| 55 runReflectiveTests(ParseDartTaskTest); | 54 runReflectiveTests(ParseDartTaskTest); |
| 56 runReflectiveTests(ParseHtmlTaskTest); | 55 runReflectiveTests(ParseHtmlTaskTest); |
| 57 runReflectiveTests(PartitionManagerTest); | 56 runReflectiveTests(PartitionManagerTest); |
| 58 runReflectiveTests(ResolveDartLibraryTaskTest); | 57 runReflectiveTests(ResolveDartLibraryTaskTest); |
| 59 runReflectiveTests(ResolveDartUnitTaskTest); | 58 runReflectiveTests(ResolveDartUnitTaskTest); |
| 60 runReflectiveTests(ResolveHtmlTaskTest); | 59 runReflectiveTests(ResolveHtmlTaskTest); |
| 61 runReflectiveTests(ScanDartTaskTest); | 60 runReflectiveTests(ScanDartTaskTest); |
| 62 runReflectiveTests(SdkCachePartitionTest); | 61 runReflectiveTests(SdkCachePartitionTest); |
| 63 runReflectiveTests(UniversalCachePartitionTest); | 62 runReflectiveTests(UniversalCachePartitionTest); |
| 64 runReflectiveTests(WorkManagerTest); | 63 runReflectiveTests(WorkManagerTest); |
| 65 } | 64 } |
| 66 | 65 |
| 67 | 66 |
| 68 class AnalysisCacheTest extends EngineTestCase { | 67 class AnalysisCacheTest extends EngineTestCase { |
| 69 void test_creation() { | 68 void test_creation() { |
| 70 JUnitTestCase.assertNotNull(new AnalysisCache(new List<CachePartition>(0))); | 69 expect(new AnalysisCache(new List<CachePartition>(0)), isNotNull); |
| 71 } | 70 } |
| 72 | 71 |
| 73 void test_get() { | 72 void test_get() { |
| 74 AnalysisCache cache = new AnalysisCache(new List<CachePartition>(0)); | 73 AnalysisCache cache = new AnalysisCache(new List<CachePartition>(0)); |
| 75 TestSource source = new TestSource(); | 74 TestSource source = new TestSource(); |
| 76 JUnitTestCase.assertNull(cache.get(source)); | 75 expect(cache.get(source), isNull); |
| 77 } | 76 } |
| 78 | 77 |
| 79 void test_iterator() { | 78 void test_iterator() { |
| 80 CachePartition partition = | 79 CachePartition partition = |
| 81 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 80 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 82 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 81 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 83 TestSource source = new TestSource(); | 82 TestSource source = new TestSource(); |
| 84 DartEntry entry = new DartEntry(); | 83 DartEntry entry = new DartEntry(); |
| 85 cache.put(source, entry); | 84 cache.put(source, entry); |
| 86 MapIterator<Source, SourceEntry> iterator = cache.iterator(); | 85 MapIterator<Source, SourceEntry> iterator = cache.iterator(); |
| 87 JUnitTestCase.assertTrue(iterator.moveNext()); | 86 expect(iterator.moveNext(), isTrue); |
| 88 JUnitTestCase.assertSame(source, iterator.key); | 87 expect(iterator.key, same(source)); |
| 89 JUnitTestCase.assertSame(entry, iterator.value); | 88 expect(iterator.value, same(entry)); |
| 90 JUnitTestCase.assertFalse(iterator.moveNext()); | 89 expect(iterator.moveNext(), isFalse); |
| 91 } | 90 } |
| 92 | 91 |
| 93 void test_put_noFlush() { | 92 void test_put_noFlush() { |
| 94 CachePartition partition = | 93 CachePartition partition = |
| 95 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 94 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 96 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 95 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 97 TestSource source = new TestSource(); | 96 TestSource source = new TestSource(); |
| 98 DartEntry entry = new DartEntry(); | 97 DartEntry entry = new DartEntry(); |
| 99 cache.put(source, entry); | 98 cache.put(source, entry); |
| 100 JUnitTestCase.assertSame(entry, cache.get(source)); | 99 expect(cache.get(source), same(entry)); |
| 101 } | 100 } |
| 102 | 101 |
| 103 void test_setMaxCacheSize() { | 102 void test_setMaxCacheSize() { |
| 104 CachePartition partition = new UniversalCachePartition( | 103 CachePartition partition = new UniversalCachePartition( |
| 105 null, | 104 null, |
| 106 8, | 105 8, |
| 107 new _AnalysisCacheTest_test_setMaxCacheSize()); | 106 new _AnalysisCacheTest_test_setMaxCacheSize()); |
| 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 107 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 109 int size = 6; | 108 int size = 6; |
| 110 for (int i = 0; i < size; i++) { | 109 for (int i = 0; i < size; i++) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 123 void test_size() { | 122 void test_size() { |
| 124 CachePartition partition = | 123 CachePartition partition = |
| 125 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 124 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 126 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 125 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 127 int size = 4; | 126 int size = 4; |
| 128 for (int i = 0; i < size; i++) { | 127 for (int i = 0; i < size; i++) { |
| 129 Source source = new TestSource("/test$i.dart"); | 128 Source source = new TestSource("/test$i.dart"); |
| 130 cache.put(source, new DartEntry()); | 129 cache.put(source, new DartEntry()); |
| 131 cache.accessedAst(source); | 130 cache.accessedAst(source); |
| 132 } | 131 } |
| 133 JUnitTestCase.assertEquals(size, cache.size()); | 132 expect(cache.size(), size); |
| 134 } | 133 } |
| 135 | 134 |
| 136 void _assertNonFlushedCount(int expectedCount, AnalysisCache cache) { | 135 void _assertNonFlushedCount(int expectedCount, AnalysisCache cache) { |
| 137 int nonFlushedCount = 0; | 136 int nonFlushedCount = 0; |
| 138 MapIterator<Source, SourceEntry> iterator = cache.iterator(); | 137 MapIterator<Source, SourceEntry> iterator = cache.iterator(); |
| 139 while (iterator.moveNext()) { | 138 while (iterator.moveNext()) { |
| 140 if (iterator.value.getState(DartEntry.PARSED_UNIT) != | 139 if (iterator.value.getState(DartEntry.PARSED_UNIT) != |
| 141 CacheState.FLUSHED) { | 140 CacheState.FLUSHED) { |
| 142 nonFlushedCount++; | 141 nonFlushedCount++; |
| 143 } | 142 } |
| 144 } | 143 } |
| 145 JUnitTestCase.assertEquals(expectedCount, nonFlushedCount); | 144 expect(nonFlushedCount, expectedCount); |
| 146 } | 145 } |
| 147 } | 146 } |
| 148 | 147 |
| 149 | 148 |
| 150 class AnalysisContextImplTest extends EngineTestCase { | 149 class AnalysisContextImplTest extends EngineTestCase { |
| 151 /** | 150 /** |
| 152 * An analysis context whose source factory is [sourceFactory]. | 151 * An analysis context whose source factory is [sourceFactory]. |
| 153 */ | 152 */ |
| 154 AnalysisContextImpl _context; | 153 AnalysisContextImpl _context; |
| 155 | 154 |
| 156 /** | 155 /** |
| 157 * The source factory associated with the analysis [context]. | 156 * The source factory associated with the analysis [context]. |
| 158 */ | 157 */ |
| 159 SourceFactory _sourceFactory; | 158 SourceFactory _sourceFactory; |
| 160 | 159 |
| 161 void fail_extractContext() { | 160 void fail_extractContext() { |
| 162 JUnitTestCase.fail("Implement this"); | 161 fail("Implement this"); |
| 163 } | 162 } |
| 164 | 163 |
| 165 void fail_mergeContext() { | 164 void fail_mergeContext() { |
| 166 JUnitTestCase.fail("Implement this"); | 165 fail("Implement this"); |
| 167 } | 166 } |
| 168 | 167 |
| 169 void fail_performAnalysisTask_importedLibraryDelete_html() { | 168 void fail_performAnalysisTask_importedLibraryDelete_html() { |
| 170 Source htmlSource = _addSource( | 169 Source htmlSource = _addSource( |
| 171 "/page.html", | 170 "/page.html", |
| 172 r''' | 171 r''' |
| 173 <html><body><script type="application/dart"> | 172 <html><body><script type="application/dart"> |
| 174 import 'libB.dart'; | 173 import 'libB.dart'; |
| 175 main() {print('hello dart');} | 174 main() {print('hello dart');} |
| 176 </script></body></html>'''); | 175 </script></body></html>'''); |
| 177 Source libBSource = _addSource("/libB.dart", "library libB;"); | 176 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 178 _analyzeAll_assertFinished(); | 177 _analyzeAll_assertFinished(); |
| 179 JUnitTestCase.assertNotNullMsg( | 178 expect(_context.getResolvedHtmlUnit(htmlSource), isNotNull, reason: "htmlUni
t resolved 1"); |
| 180 "htmlUnit resolved 1", | 179 expect(_context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNu
ll, reason: "libB resolved 1"); |
| 181 _context.getResolvedHtmlUnit(htmlSource)); | 180 expect(!_hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource)),
isTrue, reason: "htmlSource doesn't have errors"); |
| 182 JUnitTestCase.assertNotNullMsg( | |
| 183 "libB resolved 1", | |
| 184 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | |
| 185 JUnitTestCase.assertTrueMsg( | |
| 186 "htmlSource doesn't have errors", | |
| 187 !_hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource))); | |
| 188 // remove libB.dart content and analyze | 181 // remove libB.dart content and analyze |
| 189 _context.setContents(libBSource, null); | 182 _context.setContents(libBSource, null); |
| 190 _analyzeAll_assertFinished(); | 183 _analyzeAll_assertFinished(); |
| 191 JUnitTestCase.assertNotNullMsg( | 184 expect(_context.getResolvedHtmlUnit(htmlSource), isNotNull, reason: "htmlUni
t resolved 1"); |
| 192 "htmlUnit resolved 1", | |
| 193 _context.getResolvedHtmlUnit(htmlSource)); | |
| 194 AnalysisErrorInfo errors = _context.getErrors(htmlSource); | 185 AnalysisErrorInfo errors = _context.getErrors(htmlSource); |
| 195 JUnitTestCase.assertTrueMsg( | 186 expect(_hasAnalysisErrorWithErrorSeverity(errors), isTrue, reason: "htmlSour
ce has an error"); |
| 196 "htmlSource has an error", | |
| 197 _hasAnalysisErrorWithErrorSeverity(errors)); | |
| 198 } | 187 } |
| 199 | 188 |
| 200 void fail_recordLibraryElements() { | 189 void fail_recordLibraryElements() { |
| 201 JUnitTestCase.fail("Implement this"); | 190 fail("Implement this"); |
| 202 } | 191 } |
| 203 | 192 |
| 204 @override | 193 @override |
| 205 void setUp() { | 194 void setUp() { |
| 206 _context = new AnalysisContextImpl(); | 195 _context = new AnalysisContextImpl(); |
| 207 _sourceFactory = new SourceFactory( | 196 _sourceFactory = new SourceFactory( |
| 208 [new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), new FileUriResol
ver()]); | 197 [new DartUriResolver(DirectoryBasedDartSdk.defaultSdk), new FileUriResol
ver()]); |
| 209 _context.sourceFactory = _sourceFactory; | 198 _context.sourceFactory = _sourceFactory; |
| 210 AnalysisOptionsImpl options = | 199 AnalysisOptionsImpl options = |
| 211 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 200 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 212 options.cacheSize = 256; | 201 options.cacheSize = 256; |
| 213 options.enableAsync = true; | 202 options.enableAsync = true; |
| 214 options.enableEnum = true; | 203 options.enableEnum = true; |
| 215 _context.analysisOptions = options; | 204 _context.analysisOptions = options; |
| 216 } | 205 } |
| 217 | 206 |
| 218 @override | 207 @override |
| 219 void tearDown() { | 208 void tearDown() { |
| 220 _context = null; | 209 _context = null; |
| 221 _sourceFactory = null; | 210 _sourceFactory = null; |
| 222 super.tearDown(); | 211 super.tearDown(); |
| 223 } | 212 } |
| 224 | 213 |
| 225 void test_applyChanges_add() { | 214 void test_applyChanges_add() { |
| 226 JUnitTestCase.assertTrue(_context.sourcesNeedingProcessing.isEmpty); | 215 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 227 Source source = _addSource("/test.dart", "main() {}"); | 216 Source source = _addSource("/test.dart", "main() {}"); |
| 228 JUnitTestCase.assertTrue( | 217 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 229 _context.sourcesNeedingProcessing.contains(source)); | |
| 230 } | 218 } |
| 231 | 219 |
| 232 void test_applyChanges_change_flush_element() { | 220 void test_applyChanges_change_flush_element() { |
| 233 _context = AnalysisContextFactory.contextWithCore(); | 221 _context = AnalysisContextFactory.contextWithCore(); |
| 234 _sourceFactory = _context.sourceFactory; | 222 _sourceFactory = _context.sourceFactory; |
| 235 Source librarySource = _addSource( | 223 Source librarySource = _addSource( |
| 236 "/lib.dart", | 224 "/lib.dart", |
| 237 r''' | 225 r''' |
| 238 library lib; | 226 library lib; |
| 239 int a = 0;'''); | 227 int a = 0;'''); |
| 240 JUnitTestCase.assertNotNull(_context.computeLibraryElement(librarySource)); | 228 expect(_context.computeLibraryElement(librarySource), isNotNull); |
| 241 _context.setContents( | 229 _context.setContents( |
| 242 librarySource, | 230 librarySource, |
| 243 r''' | 231 r''' |
| 244 library lib; | 232 library lib; |
| 245 int aa = 0;'''); | 233 int aa = 0;'''); |
| 246 JUnitTestCase.assertNull(_context.getLibraryElement(librarySource)); | 234 expect(_context.getLibraryElement(librarySource), isNull); |
| 247 } | 235 } |
| 248 | 236 |
| 249 void test_applyChanges_change_multiple() { | 237 void test_applyChanges_change_multiple() { |
| 250 _context = AnalysisContextFactory.contextWithCore(); | 238 _context = AnalysisContextFactory.contextWithCore(); |
| 251 _sourceFactory = _context.sourceFactory; | 239 _sourceFactory = _context.sourceFactory; |
| 252 Source librarySource = _addSource( | 240 Source librarySource = _addSource( |
| 253 "/lib.dart", | 241 "/lib.dart", |
| 254 r''' | 242 r''' |
| 255 library lib; | 243 library lib; |
| 256 part 'part.dart'; | 244 part 'part.dart'; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 277 _context.resolveCompilationUnit2(librarySource, librarySource); | 265 _context.resolveCompilationUnit2(librarySource, librarySource); |
| 278 CompilationUnit partUnit = | 266 CompilationUnit partUnit = |
| 279 _context.resolveCompilationUnit2(partSource, librarySource); | 267 _context.resolveCompilationUnit2(partSource, librarySource); |
| 280 TopLevelVariableDeclaration declaration = | 268 TopLevelVariableDeclaration declaration = |
| 281 libraryUnit.declarations[0] as TopLevelVariableDeclaration; | 269 libraryUnit.declarations[0] as TopLevelVariableDeclaration; |
| 282 Element declarationElement = declaration.variables.variables[0].element; | 270 Element declarationElement = declaration.variables.variables[0].element; |
| 283 TopLevelVariableDeclaration use = | 271 TopLevelVariableDeclaration use = |
| 284 partUnit.declarations[0] as TopLevelVariableDeclaration; | 272 partUnit.declarations[0] as TopLevelVariableDeclaration; |
| 285 Element useElement = | 273 Element useElement = |
| 286 (use.variables.variables[0].initializer as SimpleIdentifier).staticEleme
nt; | 274 (use.variables.variables[0].initializer as SimpleIdentifier).staticEleme
nt; |
| 287 JUnitTestCase.assertSame( | 275 expect((useElement as PropertyAccessorElement).variable, same(declarationEle
ment)); |
| 288 declarationElement, | |
| 289 (useElement as PropertyAccessorElement).variable); | |
| 290 } | 276 } |
| 291 | 277 |
| 292 void test_applyChanges_empty() { | 278 void test_applyChanges_empty() { |
| 293 _context.applyChanges(new ChangeSet()); | 279 _context.applyChanges(new ChangeSet()); |
| 294 JUnitTestCase.assertNull(_context.performAnalysisTask().changeNotices); | 280 expect(_context.performAnalysisTask().changeNotices, isNull); |
| 295 } | 281 } |
| 296 | 282 |
| 297 void test_applyChanges_overriddenSource() { | 283 void test_applyChanges_overriddenSource() { |
| 298 // Note: addSource adds the source to the contentCache. | 284 // Note: addSource adds the source to the contentCache. |
| 299 Source source = _addSource("/test.dart", "library test;"); | 285 Source source = _addSource("/test.dart", "library test;"); |
| 300 _context.computeErrors(source); | 286 _context.computeErrors(source); |
| 301 while (!_context.sourcesNeedingProcessing.isEmpty) { | 287 while (!_context.sourcesNeedingProcessing.isEmpty) { |
| 302 _context.performAnalysisTask(); | 288 _context.performAnalysisTask(); |
| 303 } | 289 } |
| 304 // Adding the source as a changedSource should have no effect since | 290 // Adding the source as a changedSource should have no effect since |
| (...skipping 17 matching lines...) Expand all Loading... |
| 322 LibraryElement libAElement = _context.computeLibraryElement(libA); | 308 LibraryElement libAElement = _context.computeLibraryElement(libA); |
| 323 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | 309 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
| 324 EngineTestCase.assertLength(2, importedLibraries); | 310 EngineTestCase.assertLength(2, importedLibraries); |
| 325 _context.computeErrors(libA); | 311 _context.computeErrors(libA); |
| 326 _context.computeErrors(libB); | 312 _context.computeErrors(libB); |
| 327 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 313 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); |
| 328 _context.setContents(libB, null); | 314 _context.setContents(libB, null); |
| 329 _removeSource(libB); | 315 _removeSource(libB); |
| 330 List<Source> sources = _context.sourcesNeedingProcessing; | 316 List<Source> sources = _context.sourcesNeedingProcessing; |
| 331 EngineTestCase.assertSizeOfList(1, sources); | 317 EngineTestCase.assertSizeOfList(1, sources); |
| 332 JUnitTestCase.assertSame(libA, sources[0]); | 318 expect(sources[0], same(libA)); |
| 333 libAElement = _context.computeLibraryElement(libA); | 319 libAElement = _context.computeLibraryElement(libA); |
| 334 importedLibraries = libAElement.importedLibraries; | 320 importedLibraries = libAElement.importedLibraries; |
| 335 EngineTestCase.assertLength(1, importedLibraries); | 321 EngineTestCase.assertLength(1, importedLibraries); |
| 336 } | 322 } |
| 337 | 323 |
| 338 void test_applyChanges_removeContainer() { | 324 void test_applyChanges_removeContainer() { |
| 339 _context = AnalysisContextFactory.contextWithCore(); | 325 _context = AnalysisContextFactory.contextWithCore(); |
| 340 _sourceFactory = _context.sourceFactory; | 326 _sourceFactory = _context.sourceFactory; |
| 341 Source libA = _addSource( | 327 Source libA = _addSource( |
| 342 "/libA.dart", | 328 "/libA.dart", |
| 343 r''' | 329 r''' |
| 344 library libA; | 330 library libA; |
| 345 import 'libB.dart';'''); | 331 import 'libB.dart';'''); |
| 346 Source libB = | 332 Source libB = |
| 347 _addSource("/libB.dart", "library libB;"); | 333 _addSource("/libB.dart", "library libB;"); |
| 348 _context.computeLibraryElement(libA); | 334 _context.computeLibraryElement(libA); |
| 349 _context.computeErrors(libA); | 335 _context.computeErrors(libA); |
| 350 _context.computeErrors(libB); | 336 _context.computeErrors(libB); |
| 351 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 337 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); |
| 352 ChangeSet changeSet = new ChangeSet(); | 338 ChangeSet changeSet = new ChangeSet(); |
| 353 changeSet.removedContainer( | 339 changeSet.removedContainer( |
| 354 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); | 340 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); |
| 355 _context.applyChanges(changeSet); | 341 _context.applyChanges(changeSet); |
| 356 List<Source> sources = _context.sourcesNeedingProcessing; | 342 List<Source> sources = _context.sourcesNeedingProcessing; |
| 357 EngineTestCase.assertSizeOfList(1, sources); | 343 EngineTestCase.assertSizeOfList(1, sources); |
| 358 JUnitTestCase.assertSame(libA, sources[0]); | 344 expect(sources[0], same(libA)); |
| 359 } | 345 } |
| 360 | 346 |
| 361 void test_computeDocumentationComment_block() { | 347 void test_computeDocumentationComment_block() { |
| 362 _context = AnalysisContextFactory.contextWithCore(); | 348 _context = AnalysisContextFactory.contextWithCore(); |
| 363 _sourceFactory = _context.sourceFactory; | 349 _sourceFactory = _context.sourceFactory; |
| 364 String comment = "/** Comment */"; | 350 String comment = "/** Comment */"; |
| 365 Source source = | 351 Source source = |
| 366 _addSource("/test.dart", """ | 352 _addSource("/test.dart", """ |
| 367 $comment | 353 $comment |
| 368 class A {}"""); | 354 class A {}"""); |
| 369 LibraryElement libraryElement = _context.computeLibraryElement(source); | 355 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 370 JUnitTestCase.assertNotNull(libraryElement); | 356 expect(libraryElement, isNotNull); |
| 371 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 357 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 372 JUnitTestCase.assertNotNull(libraryElement); | 358 expect(libraryElement, isNotNull); |
| 373 JUnitTestCase.assertEquals( | 359 expect(_context.computeDocumentationComment(classElement), comment); |
| 374 comment, | |
| 375 _context.computeDocumentationComment(classElement)); | |
| 376 } | 360 } |
| 377 | 361 |
| 378 void test_computeDocumentationComment_none() { | 362 void test_computeDocumentationComment_none() { |
| 379 _context = AnalysisContextFactory.contextWithCore(); | 363 _context = AnalysisContextFactory.contextWithCore(); |
| 380 _sourceFactory = _context.sourceFactory; | 364 _sourceFactory = _context.sourceFactory; |
| 381 Source source = | 365 Source source = |
| 382 _addSource("/test.dart", "class A {}"); | 366 _addSource("/test.dart", "class A {}"); |
| 383 LibraryElement libraryElement = _context.computeLibraryElement(source); | 367 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 384 JUnitTestCase.assertNotNull(libraryElement); | 368 expect(libraryElement, isNotNull); |
| 385 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 369 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 386 JUnitTestCase.assertNotNull(libraryElement); | 370 expect(libraryElement, isNotNull); |
| 387 JUnitTestCase.assertNull( | 371 expect(_context.computeDocumentationComment(classElement), isNull); |
| 388 _context.computeDocumentationComment(classElement)); | |
| 389 } | 372 } |
| 390 | 373 |
| 391 void test_computeDocumentationComment_null() { | 374 void test_computeDocumentationComment_null() { |
| 392 JUnitTestCase.assertNull(_context.computeDocumentationComment(null)); | 375 expect(_context.computeDocumentationComment(null), isNull); |
| 393 } | 376 } |
| 394 | 377 |
| 395 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { | 378 void test_computeDocumentationComment_singleLine_multiple_EOL_n() { |
| 396 _context = AnalysisContextFactory.contextWithCore(); | 379 _context = AnalysisContextFactory.contextWithCore(); |
| 397 _sourceFactory = _context.sourceFactory; | 380 _sourceFactory = _context.sourceFactory; |
| 398 String comment = "/// line 1\n/// line 2\n/// line 3\n"; | 381 String comment = "/// line 1\n/// line 2\n/// line 3\n"; |
| 399 Source source = _addSource("/test.dart", "${comment}class A {}"); | 382 Source source = _addSource("/test.dart", "${comment}class A {}"); |
| 400 LibraryElement libraryElement = _context.computeLibraryElement(source); | 383 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 401 JUnitTestCase.assertNotNull(libraryElement); | 384 expect(libraryElement, isNotNull); |
| 402 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 385 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 403 JUnitTestCase.assertNotNull(libraryElement); | 386 expect(libraryElement, isNotNull); |
| 404 String actual = _context.computeDocumentationComment(classElement); | 387 String actual = _context.computeDocumentationComment(classElement); |
| 405 JUnitTestCase.assertEquals("/// line 1\n/// line 2\n/// line 3", actual); | 388 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
| 406 } | 389 } |
| 407 | 390 |
| 408 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { | 391 void test_computeDocumentationComment_singleLine_multiple_EOL_rn() { |
| 409 _context = AnalysisContextFactory.contextWithCore(); | 392 _context = AnalysisContextFactory.contextWithCore(); |
| 410 _sourceFactory = _context.sourceFactory; | 393 _sourceFactory = _context.sourceFactory; |
| 411 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; | 394 String comment = "/// line 1\r\n/// line 2\r\n/// line 3\r\n"; |
| 412 Source source = _addSource("/test.dart", "${comment}class A {}"); | 395 Source source = _addSource("/test.dart", "${comment}class A {}"); |
| 413 LibraryElement libraryElement = _context.computeLibraryElement(source); | 396 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 414 JUnitTestCase.assertNotNull(libraryElement); | 397 expect(libraryElement, isNotNull); |
| 415 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 398 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 416 JUnitTestCase.assertNotNull(libraryElement); | 399 expect(libraryElement, isNotNull); |
| 417 String actual = _context.computeDocumentationComment(classElement); | 400 String actual = _context.computeDocumentationComment(classElement); |
| 418 JUnitTestCase.assertEquals("/// line 1\n/// line 2\n/// line 3", actual); | 401 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
| 419 } | 402 } |
| 420 | 403 |
| 421 void test_computeErrors_dart_none() { | 404 void test_computeErrors_dart_none() { |
| 422 Source source = _addSource("/lib.dart", "library lib;"); | 405 Source source = _addSource("/lib.dart", "library lib;"); |
| 423 List<AnalysisError> errors = _context.computeErrors(source); | 406 List<AnalysisError> errors = _context.computeErrors(source); |
| 424 EngineTestCase.assertLength(0, errors); | 407 EngineTestCase.assertLength(0, errors); |
| 425 } | 408 } |
| 426 | 409 |
| 427 void test_computeErrors_dart_part() { | 410 void test_computeErrors_dart_part() { |
| 428 Source librarySource = | 411 Source librarySource = |
| 429 _addSource("/lib.dart", "library lib; part 'part.dart';"); | 412 _addSource("/lib.dart", "library lib; part 'part.dart';"); |
| 430 Source partSource = _addSource("/part.dart", "part of 'lib';"); | 413 Source partSource = _addSource("/part.dart", "part of 'lib';"); |
| 431 _context.parseCompilationUnit(librarySource); | 414 _context.parseCompilationUnit(librarySource); |
| 432 List<AnalysisError> errors = _context.computeErrors(partSource); | 415 List<AnalysisError> errors = _context.computeErrors(partSource); |
| 433 JUnitTestCase.assertNotNull(errors); | 416 expect(errors, isNotNull); |
| 434 JUnitTestCase.assertTrue(errors.length > 0); | 417 expect(errors.length > 0, isTrue); |
| 435 } | 418 } |
| 436 | 419 |
| 437 void test_computeErrors_dart_some() { | 420 void test_computeErrors_dart_some() { |
| 438 Source source = _addSource("/lib.dart", "library 'lib';"); | 421 Source source = _addSource("/lib.dart", "library 'lib';"); |
| 439 List<AnalysisError> errors = _context.computeErrors(source); | 422 List<AnalysisError> errors = _context.computeErrors(source); |
| 440 JUnitTestCase.assertNotNull(errors); | 423 expect(errors, isNotNull); |
| 441 JUnitTestCase.assertTrue(errors.length > 0); | 424 expect(errors.length > 0, isTrue); |
| 442 } | 425 } |
| 443 | 426 |
| 444 void test_computeErrors_html_none() { | 427 void test_computeErrors_html_none() { |
| 445 Source source = _addSource("/test.html", "<html></html>"); | 428 Source source = _addSource("/test.html", "<html></html>"); |
| 446 List<AnalysisError> errors = _context.computeErrors(source); | 429 List<AnalysisError> errors = _context.computeErrors(source); |
| 447 EngineTestCase.assertLength(0, errors); | 430 EngineTestCase.assertLength(0, errors); |
| 448 } | 431 } |
| 449 | 432 |
| 450 void test_computeExportedLibraries_none() { | 433 void test_computeExportedLibraries_none() { |
| 451 Source source = _addSource("/test.dart", "library test;"); | 434 Source source = _addSource("/test.dart", "library test;"); |
| 452 EngineTestCase.assertLength(0, _context.computeExportedLibraries(source)); | 435 EngineTestCase.assertLength(0, _context.computeExportedLibraries(source)); |
| 453 } | 436 } |
| 454 | 437 |
| 455 void test_computeExportedLibraries_some() { | 438 void test_computeExportedLibraries_some() { |
| 456 // addSource("/lib1.dart", "library lib1;"); | 439 // addSource("/lib1.dart", "library lib1;"); |
| 457 // addSource("/lib2.dart", "library lib2;"); | 440 // addSource("/lib2.dart", "library lib2;"); |
| 458 Source source = _addSource( | 441 Source source = _addSource( |
| 459 "/test.dart", | 442 "/test.dart", |
| 460 "library test; export 'lib1.dart'; export 'lib2.dart';"); | 443 "library test; export 'lib1.dart'; export 'lib2.dart';"); |
| 461 EngineTestCase.assertLength(2, _context.computeExportedLibraries(source)); | 444 EngineTestCase.assertLength(2, _context.computeExportedLibraries(source)); |
| 462 } | 445 } |
| 463 | 446 |
| 464 void test_computeHtmlElement_nonHtml() { | 447 void test_computeHtmlElement_nonHtml() { |
| 465 Source source = _addSource("/test.dart", "library test;"); | 448 Source source = _addSource("/test.dart", "library test;"); |
| 466 JUnitTestCase.assertNull(_context.computeHtmlElement(source)); | 449 expect(_context.computeHtmlElement(source), isNull); |
| 467 } | 450 } |
| 468 | 451 |
| 469 void test_computeHtmlElement_valid() { | 452 void test_computeHtmlElement_valid() { |
| 470 Source source = _addSource("/test.html", "<html></html>"); | 453 Source source = _addSource("/test.html", "<html></html>"); |
| 471 HtmlElement element = _context.computeHtmlElement(source); | 454 HtmlElement element = _context.computeHtmlElement(source); |
| 472 JUnitTestCase.assertNotNull(element); | 455 expect(element, isNotNull); |
| 473 JUnitTestCase.assertSame(element, _context.computeHtmlElement(source)); | 456 expect(_context.computeHtmlElement(source), same(element)); |
| 474 } | 457 } |
| 475 | 458 |
| 476 void test_computeImportedLibraries_none() { | 459 void test_computeImportedLibraries_none() { |
| 477 Source source = _addSource("/test.dart", "library test;"); | 460 Source source = _addSource("/test.dart", "library test;"); |
| 478 EngineTestCase.assertLength(0, _context.computeImportedLibraries(source)); | 461 EngineTestCase.assertLength(0, _context.computeImportedLibraries(source)); |
| 479 } | 462 } |
| 480 | 463 |
| 481 void test_computeImportedLibraries_some() { | 464 void test_computeImportedLibraries_some() { |
| 482 // addSource("/lib1.dart", "library lib1;"); | 465 // addSource("/lib1.dart", "library lib1;"); |
| 483 // addSource("/lib2.dart", "library lib2;"); | 466 // addSource("/lib2.dart", "library lib2;"); |
| 484 Source source = _addSource( | 467 Source source = _addSource( |
| 485 "/test.dart", | 468 "/test.dart", |
| 486 "library test; import 'lib1.dart'; import 'lib2.dart';"); | 469 "library test; import 'lib1.dart'; import 'lib2.dart';"); |
| 487 EngineTestCase.assertLength(2, _context.computeImportedLibraries(source)); | 470 EngineTestCase.assertLength(2, _context.computeImportedLibraries(source)); |
| 488 } | 471 } |
| 489 | 472 |
| 490 void test_computeKindOf_html() { | 473 void test_computeKindOf_html() { |
| 491 Source source = _addSource("/test.html", ""); | 474 Source source = _addSource("/test.html", ""); |
| 492 JUnitTestCase.assertSame(SourceKind.HTML, _context.computeKindOf(source)); | 475 expect(_context.computeKindOf(source), same(SourceKind.HTML)); |
| 493 } | 476 } |
| 494 | 477 |
| 495 void test_computeKindOf_library() { | 478 void test_computeKindOf_library() { |
| 496 Source source = _addSource("/test.dart", "library lib;"); | 479 Source source = _addSource("/test.dart", "library lib;"); |
| 497 JUnitTestCase.assertSame( | 480 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); |
| 498 SourceKind.LIBRARY, | |
| 499 _context.computeKindOf(source)); | |
| 500 } | 481 } |
| 501 | 482 |
| 502 void test_computeKindOf_libraryAndPart() { | 483 void test_computeKindOf_libraryAndPart() { |
| 503 Source source = _addSource("/test.dart", "library lib; part of lib;"); | 484 Source source = _addSource("/test.dart", "library lib; part of lib;"); |
| 504 JUnitTestCase.assertSame( | 485 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); |
| 505 SourceKind.LIBRARY, | |
| 506 _context.computeKindOf(source)); | |
| 507 } | 486 } |
| 508 | 487 |
| 509 void test_computeKindOf_part() { | 488 void test_computeKindOf_part() { |
| 510 Source source = _addSource("/test.dart", "part of lib;"); | 489 Source source = _addSource("/test.dart", "part of lib;"); |
| 511 JUnitTestCase.assertSame(SourceKind.PART, _context.computeKindOf(source)); | 490 expect(_context.computeKindOf(source), same(SourceKind.PART)); |
| 512 } | 491 } |
| 513 | 492 |
| 514 void test_computeLibraryElement() { | 493 void test_computeLibraryElement() { |
| 515 _context = AnalysisContextFactory.contextWithCore(); | 494 _context = AnalysisContextFactory.contextWithCore(); |
| 516 _sourceFactory = _context.sourceFactory; | 495 _sourceFactory = _context.sourceFactory; |
| 517 Source source = _addSource("/test.dart", "library lib;"); | 496 Source source = _addSource("/test.dart", "library lib;"); |
| 518 LibraryElement element = _context.computeLibraryElement(source); | 497 LibraryElement element = _context.computeLibraryElement(source); |
| 519 JUnitTestCase.assertNotNull(element); | 498 expect(element, isNotNull); |
| 520 } | 499 } |
| 521 | 500 |
| 522 void test_computeLineInfo_dart() { | 501 void test_computeLineInfo_dart() { |
| 523 Source source = _addSource( | 502 Source source = _addSource( |
| 524 "/test.dart", | 503 "/test.dart", |
| 525 r''' | 504 r''' |
| 526 library lib; | 505 library lib; |
| 527 | 506 |
| 528 main() {}'''); | 507 main() {}'''); |
| 529 LineInfo info = _context.computeLineInfo(source); | 508 LineInfo info = _context.computeLineInfo(source); |
| 530 JUnitTestCase.assertNotNull(info); | 509 expect(info, isNotNull); |
| 531 } | 510 } |
| 532 | 511 |
| 533 void test_computeLineInfo_html() { | 512 void test_computeLineInfo_html() { |
| 534 Source source = _addSource( | 513 Source source = _addSource( |
| 535 "/test.html", | 514 "/test.html", |
| 536 r''' | 515 r''' |
| 537 <html> | 516 <html> |
| 538 <body> | 517 <body> |
| 539 <h1>A</h1> | 518 <h1>A</h1> |
| 540 </body> | 519 </body> |
| 541 </html>'''); | 520 </html>'''); |
| 542 LineInfo info = _context.computeLineInfo(source); | 521 LineInfo info = _context.computeLineInfo(source); |
| 543 JUnitTestCase.assertNotNull(info); | 522 expect(info, isNotNull); |
| 544 } | 523 } |
| 545 | 524 |
| 546 void test_computeResolvableCompilationUnit_dart_exception() { | 525 void test_computeResolvableCompilationUnit_dart_exception() { |
| 547 TestSource source = _addSourceWithException("/test.dart"); | 526 TestSource source = _addSourceWithException("/test.dart"); |
| 548 try { | 527 try { |
| 549 _context.computeResolvableCompilationUnit(source); | 528 _context.computeResolvableCompilationUnit(source); |
| 550 JUnitTestCase.fail("Expected AnalysisException"); | 529 fail("Expected AnalysisException"); |
| 551 } on AnalysisException catch (exception) { | 530 } on AnalysisException catch (exception) { |
| 552 // Expected | 531 // Expected |
| 553 } | 532 } |
| 554 } | 533 } |
| 555 | 534 |
| 556 void test_computeResolvableCompilationUnit_html_exception() { | 535 void test_computeResolvableCompilationUnit_html_exception() { |
| 557 Source source = _addSource("/lib.html", "<html></html>"); | 536 Source source = _addSource("/lib.html", "<html></html>"); |
| 558 try { | 537 try { |
| 559 _context.computeResolvableCompilationUnit(source); | 538 _context.computeResolvableCompilationUnit(source); |
| 560 JUnitTestCase.fail("Expected AnalysisException"); | 539 fail("Expected AnalysisException"); |
| 561 } on AnalysisException catch (exception) { | 540 } on AnalysisException catch (exception) { |
| 562 // Expected | 541 // Expected |
| 563 } | 542 } |
| 564 } | 543 } |
| 565 | 544 |
| 566 void test_computeResolvableCompilationUnit_valid() { | 545 void test_computeResolvableCompilationUnit_valid() { |
| 567 Source source = _addSource("/lib.dart", "library lib;"); | 546 Source source = _addSource("/lib.dart", "library lib;"); |
| 568 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); | 547 CompilationUnit parsedUnit = _context.parseCompilationUnit(source); |
| 569 JUnitTestCase.assertNotNull(parsedUnit); | 548 expect(parsedUnit, isNotNull); |
| 570 CompilationUnit resolvedUnit = | 549 CompilationUnit resolvedUnit = |
| 571 _context.computeResolvableCompilationUnit(source); | 550 _context.computeResolvableCompilationUnit(source); |
| 572 JUnitTestCase.assertNotNull(resolvedUnit); | 551 expect(resolvedUnit, isNotNull); |
| 573 JUnitTestCase.assertSame(parsedUnit, resolvedUnit); | 552 expect(resolvedUnit, same(parsedUnit)); |
| 574 } | 553 } |
| 575 | 554 |
| 576 void test_dispose() { | 555 void test_dispose() { |
| 577 JUnitTestCase.assertFalse(_context.isDisposed); | 556 expect(_context.isDisposed, isFalse); |
| 578 _context.dispose(); | 557 _context.dispose(); |
| 579 JUnitTestCase.assertTrue(_context.isDisposed); | 558 expect(_context.isDisposed, isTrue); |
| 580 } | 559 } |
| 581 | 560 |
| 582 void test_exists_false() { | 561 void test_exists_false() { |
| 583 TestSource source = new TestSource(); | 562 TestSource source = new TestSource(); |
| 584 source.exists2 = false; | 563 source.exists2 = false; |
| 585 JUnitTestCase.assertFalse(_context.exists(source)); | 564 expect(_context.exists(source), isFalse); |
| 586 } | 565 } |
| 587 | 566 |
| 588 void test_exists_null() { | 567 void test_exists_null() { |
| 589 JUnitTestCase.assertFalse(_context.exists(null)); | 568 expect(_context.exists(null), isFalse); |
| 590 } | 569 } |
| 591 | 570 |
| 592 void test_exists_overridden() { | 571 void test_exists_overridden() { |
| 593 Source source = new TestSource(); | 572 Source source = new TestSource(); |
| 594 _context.setContents(source, ""); | 573 _context.setContents(source, ""); |
| 595 JUnitTestCase.assertTrue(_context.exists(source)); | 574 expect(_context.exists(source), isTrue); |
| 596 } | 575 } |
| 597 | 576 |
| 598 void test_exists_true() { | 577 void test_exists_true() { |
| 599 JUnitTestCase.assertTrue( | 578 expect(_context.exists(new AnalysisContextImplTest_Source_exists_true()), is
True); |
| 600 _context.exists(new AnalysisContextImplTest_Source_exists_true())); | |
| 601 } | 579 } |
| 602 | 580 |
| 603 void test_getAnalysisOptions() { | 581 void test_getAnalysisOptions() { |
| 604 JUnitTestCase.assertNotNull(_context.analysisOptions); | 582 expect(_context.analysisOptions, isNotNull); |
| 605 } | 583 } |
| 606 | 584 |
| 607 void test_getContents_fromSource() { | 585 void test_getContents_fromSource() { |
| 608 String content = "library lib;"; | 586 String content = "library lib;"; |
| 609 TimestampedData<String> contents = | 587 TimestampedData<String> contents = |
| 610 _context.getContents(new TestSource('/test.dart', content)); | 588 _context.getContents(new TestSource('/test.dart', content)); |
| 611 JUnitTestCase.assertEquals(content, contents.data.toString()); | 589 expect(contents.data.toString(), content); |
| 612 } | 590 } |
| 613 | 591 |
| 614 void test_getContents_overridden() { | 592 void test_getContents_overridden() { |
| 615 String content = "library lib;"; | 593 String content = "library lib;"; |
| 616 Source source = new TestSource(); | 594 Source source = new TestSource(); |
| 617 _context.setContents(source, content); | 595 _context.setContents(source, content); |
| 618 TimestampedData<String> contents = _context.getContents(source); | 596 TimestampedData<String> contents = _context.getContents(source); |
| 619 JUnitTestCase.assertEquals(content, contents.data.toString()); | 597 expect(contents.data.toString(), content); |
| 620 } | 598 } |
| 621 | 599 |
| 622 void test_getContents_unoverridden() { | 600 void test_getContents_unoverridden() { |
| 623 String content = "library lib;"; | 601 String content = "library lib;"; |
| 624 Source source = new TestSource('/test.dart', content); | 602 Source source = new TestSource('/test.dart', content); |
| 625 _context.setContents(source, "part of lib;"); | 603 _context.setContents(source, "part of lib;"); |
| 626 _context.setContents(source, null); | 604 _context.setContents(source, null); |
| 627 TimestampedData<String> contents = _context.getContents(source); | 605 TimestampedData<String> contents = _context.getContents(source); |
| 628 JUnitTestCase.assertEquals(content, contents.data.toString()); | 606 expect(contents.data.toString(), content); |
| 629 } | 607 } |
| 630 | 608 |
| 631 void test_getDeclaredVariables() { | 609 void test_getDeclaredVariables() { |
| 632 _context = AnalysisContextFactory.contextWithCore(); | 610 _context = AnalysisContextFactory.contextWithCore(); |
| 633 JUnitTestCase.assertNotNull(_context.declaredVariables); | 611 expect(_context.declaredVariables, isNotNull); |
| 634 } | 612 } |
| 635 | 613 |
| 636 void test_getElement() { | 614 void test_getElement() { |
| 637 _context = AnalysisContextFactory.contextWithCore(); | 615 _context = AnalysisContextFactory.contextWithCore(); |
| 638 _sourceFactory = _context.sourceFactory; | 616 _sourceFactory = _context.sourceFactory; |
| 639 LibraryElement core = | 617 LibraryElement core = |
| 640 _context.computeLibraryElement(_sourceFactory.forUri("dart:core")); | 618 _context.computeLibraryElement(_sourceFactory.forUri("dart:core")); |
| 641 JUnitTestCase.assertNotNull(core); | 619 expect(core, isNotNull); |
| 642 ClassElement classObject = | 620 ClassElement classObject = |
| 643 _findClass(core.definingCompilationUnit, "Object"); | 621 _findClass(core.definingCompilationUnit, "Object"); |
| 644 JUnitTestCase.assertNotNull(classObject); | 622 expect(classObject, isNotNull); |
| 645 ElementLocation location = classObject.location; | 623 ElementLocation location = classObject.location; |
| 646 Element element = _context.getElement(location); | 624 Element element = _context.getElement(location); |
| 647 JUnitTestCase.assertSame(classObject, element); | 625 expect(element, same(classObject)); |
| 648 } | 626 } |
| 649 | 627 |
| 650 void test_getElement_constructor_named() { | 628 void test_getElement_constructor_named() { |
| 651 Source source = _addSource( | 629 Source source = _addSource( |
| 652 "/lib.dart", | 630 "/lib.dart", |
| 653 r''' | 631 r''' |
| 654 class A { | 632 class A { |
| 655 A.named() {} | 633 A.named() {} |
| 656 }'''); | 634 }'''); |
| 657 _analyzeAll_assertFinished(); | 635 _analyzeAll_assertFinished(); |
| 658 LibraryElement library = _context.computeLibraryElement(source); | 636 LibraryElement library = _context.computeLibraryElement(source); |
| 659 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | 637 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 660 ConstructorElement constructor = classA.constructors[0]; | 638 ConstructorElement constructor = classA.constructors[0]; |
| 661 ElementLocation location = constructor.location; | 639 ElementLocation location = constructor.location; |
| 662 Element element = _context.getElement(location); | 640 Element element = _context.getElement(location); |
| 663 JUnitTestCase.assertSame(constructor, element); | 641 expect(element, same(constructor)); |
| 664 } | 642 } |
| 665 | 643 |
| 666 void test_getElement_constructor_unnamed() { | 644 void test_getElement_constructor_unnamed() { |
| 667 Source source = _addSource( | 645 Source source = _addSource( |
| 668 "/lib.dart", | 646 "/lib.dart", |
| 669 r''' | 647 r''' |
| 670 class A { | 648 class A { |
| 671 A() {} | 649 A() {} |
| 672 }'''); | 650 }'''); |
| 673 _analyzeAll_assertFinished(); | 651 _analyzeAll_assertFinished(); |
| 674 LibraryElement library = _context.computeLibraryElement(source); | 652 LibraryElement library = _context.computeLibraryElement(source); |
| 675 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | 653 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 676 ConstructorElement constructor = classA.constructors[0]; | 654 ConstructorElement constructor = classA.constructors[0]; |
| 677 ElementLocation location = constructor.location; | 655 ElementLocation location = constructor.location; |
| 678 Element element = _context.getElement(location); | 656 Element element = _context.getElement(location); |
| 679 JUnitTestCase.assertSame(constructor, element); | 657 expect(element, same(constructor)); |
| 680 } | 658 } |
| 681 | 659 |
| 682 void test_getElement_enum() { | 660 void test_getElement_enum() { |
| 683 Source source = _addSource('/test.dart', 'enum MyEnum {A, B, C}'); | 661 Source source = _addSource('/test.dart', 'enum MyEnum {A, B, C}'); |
| 684 _analyzeAll_assertFinished(); | 662 _analyzeAll_assertFinished(); |
| 685 LibraryElement library = _context.computeLibraryElement(source); | 663 LibraryElement library = _context.computeLibraryElement(source); |
| 686 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); | 664 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); |
| 687 ElementLocation location = myEnum.location; | 665 ElementLocation location = myEnum.location; |
| 688 Element element = _context.getElement(location); | 666 Element element = _context.getElement(location); |
| 689 JUnitTestCase.assertSame(myEnum, element); | 667 expect(element, same(myEnum)); |
| 690 } | 668 } |
| 691 | 669 |
| 692 void test_getErrors_dart_none() { | 670 void test_getErrors_dart_none() { |
| 693 Source source = _addSource("/lib.dart", "library lib;"); | 671 Source source = _addSource("/lib.dart", "library lib;"); |
| 694 List<AnalysisError> errors = _context.getErrors(source).errors; | 672 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 695 EngineTestCase.assertLength(0, errors); | 673 EngineTestCase.assertLength(0, errors); |
| 696 _context.computeErrors(source); | 674 _context.computeErrors(source); |
| 697 errors = _context.getErrors(source).errors; | 675 errors = _context.getErrors(source).errors; |
| 698 EngineTestCase.assertLength(0, errors); | 676 EngineTestCase.assertLength(0, errors); |
| 699 } | 677 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 725 </head></html>'''); | 703 </head></html>'''); |
| 726 List<AnalysisError> errors = _context.getErrors(source).errors; | 704 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 727 EngineTestCase.assertLength(0, errors); | 705 EngineTestCase.assertLength(0, errors); |
| 728 _context.computeErrors(source); | 706 _context.computeErrors(source); |
| 729 errors = _context.getErrors(source).errors; | 707 errors = _context.getErrors(source).errors; |
| 730 EngineTestCase.assertLength(1, errors); | 708 EngineTestCase.assertLength(1, errors); |
| 731 } | 709 } |
| 732 | 710 |
| 733 void test_getHtmlElement_dart() { | 711 void test_getHtmlElement_dart() { |
| 734 Source source = _addSource("/test.dart", ""); | 712 Source source = _addSource("/test.dart", ""); |
| 735 JUnitTestCase.assertNull(_context.getHtmlElement(source)); | 713 expect(_context.getHtmlElement(source), isNull); |
| 736 JUnitTestCase.assertNull(_context.computeHtmlElement(source)); | 714 expect(_context.computeHtmlElement(source), isNull); |
| 737 JUnitTestCase.assertNull(_context.getHtmlElement(source)); | 715 expect(_context.getHtmlElement(source), isNull); |
| 738 } | 716 } |
| 739 | 717 |
| 740 void test_getHtmlElement_html() { | 718 void test_getHtmlElement_html() { |
| 741 Source source = _addSource("/test.html", "<html></html>"); | 719 Source source = _addSource("/test.html", "<html></html>"); |
| 742 HtmlElement element = _context.getHtmlElement(source); | 720 HtmlElement element = _context.getHtmlElement(source); |
| 743 JUnitTestCase.assertNull(element); | 721 expect(element, isNull); |
| 744 _context.computeHtmlElement(source); | 722 _context.computeHtmlElement(source); |
| 745 element = _context.getHtmlElement(source); | 723 element = _context.getHtmlElement(source); |
| 746 JUnitTestCase.assertNotNull(element); | 724 expect(element, isNotNull); |
| 747 } | 725 } |
| 748 | 726 |
| 749 void test_getHtmlFilesReferencing_html() { | 727 void test_getHtmlFilesReferencing_html() { |
| 750 _context = AnalysisContextFactory.contextWithCore(); | 728 _context = AnalysisContextFactory.contextWithCore(); |
| 751 _sourceFactory = _context.sourceFactory; | 729 _sourceFactory = _context.sourceFactory; |
| 752 Source htmlSource = _addSource( | 730 Source htmlSource = _addSource( |
| 753 "/test.html", | 731 "/test.html", |
| 754 r''' | 732 r''' |
| 755 <html><head> | 733 <html><head> |
| 756 <script type='application/dart' src='test.dart'/> | 734 <script type='application/dart' src='test.dart'/> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 773 <html><head> | 751 <html><head> |
| 774 <script type='application/dart' src='test.dart'/> | 752 <script type='application/dart' src='test.dart'/> |
| 775 <script type='application/dart' src='test.js'/> | 753 <script type='application/dart' src='test.js'/> |
| 776 </head></html>'''); | 754 </head></html>'''); |
| 777 Source librarySource = _addSource("/test.dart", "library lib;"); | 755 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 778 List<Source> result = _context.getHtmlFilesReferencing(librarySource); | 756 List<Source> result = _context.getHtmlFilesReferencing(librarySource); |
| 779 EngineTestCase.assertLength(0, result); | 757 EngineTestCase.assertLength(0, result); |
| 780 _context.parseHtmlUnit(htmlSource); | 758 _context.parseHtmlUnit(htmlSource); |
| 781 result = _context.getHtmlFilesReferencing(librarySource); | 759 result = _context.getHtmlFilesReferencing(librarySource); |
| 782 EngineTestCase.assertLength(1, result); | 760 EngineTestCase.assertLength(1, result); |
| 783 JUnitTestCase.assertEquals(htmlSource, result[0]); | 761 expect(result[0], htmlSource); |
| 784 } | 762 } |
| 785 | 763 |
| 786 void test_getHtmlFilesReferencing_part() { | 764 void test_getHtmlFilesReferencing_part() { |
| 787 _context = AnalysisContextFactory.contextWithCore(); | 765 _context = AnalysisContextFactory.contextWithCore(); |
| 788 _sourceFactory = _context.sourceFactory; | 766 _sourceFactory = _context.sourceFactory; |
| 789 Source htmlSource = _addSource( | 767 Source htmlSource = _addSource( |
| 790 "/test.html", | 768 "/test.html", |
| 791 r''' | 769 r''' |
| 792 <html><head> | 770 <html><head> |
| 793 <script type='application/dart' src='test.dart'/> | 771 <script type='application/dart' src='test.dart'/> |
| 794 <script type='application/dart' src='test.js'/> | 772 <script type='application/dart' src='test.js'/> |
| 795 </head></html>'''); | 773 </head></html>'''); |
| 796 Source librarySource = | 774 Source librarySource = |
| 797 _addSource("/test.dart", "library lib; part 'part.dart';"); | 775 _addSource("/test.dart", "library lib; part 'part.dart';"); |
| 798 Source partSource = _addSource("/part.dart", "part of lib;"); | 776 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 799 _context.computeLibraryElement(librarySource); | 777 _context.computeLibraryElement(librarySource); |
| 800 List<Source> result = _context.getHtmlFilesReferencing(partSource); | 778 List<Source> result = _context.getHtmlFilesReferencing(partSource); |
| 801 EngineTestCase.assertLength(0, result); | 779 EngineTestCase.assertLength(0, result); |
| 802 _context.parseHtmlUnit(htmlSource); | 780 _context.parseHtmlUnit(htmlSource); |
| 803 result = _context.getHtmlFilesReferencing(partSource); | 781 result = _context.getHtmlFilesReferencing(partSource); |
| 804 EngineTestCase.assertLength(1, result); | 782 EngineTestCase.assertLength(1, result); |
| 805 JUnitTestCase.assertEquals(htmlSource, result[0]); | 783 expect(result[0], htmlSource); |
| 806 } | 784 } |
| 807 | 785 |
| 808 void test_getHtmlSources() { | 786 void test_getHtmlSources() { |
| 809 List<Source> sources = _context.htmlSources; | 787 List<Source> sources = _context.htmlSources; |
| 810 EngineTestCase.assertLength(0, sources); | 788 EngineTestCase.assertLength(0, sources); |
| 811 Source source = _addSource("/test.html", ""); | 789 Source source = _addSource("/test.html", ""); |
| 812 _context.computeKindOf(source); | 790 _context.computeKindOf(source); |
| 813 sources = _context.htmlSources; | 791 sources = _context.htmlSources; |
| 814 EngineTestCase.assertLength(1, sources); | 792 EngineTestCase.assertLength(1, sources); |
| 815 JUnitTestCase.assertEquals(source, sources[0]); | 793 expect(sources[0], source); |
| 816 } | 794 } |
| 817 | 795 |
| 818 void test_getKindOf_html() { | 796 void test_getKindOf_html() { |
| 819 Source source = _addSource("/test.html", ""); | 797 Source source = _addSource("/test.html", ""); |
| 820 JUnitTestCase.assertSame(SourceKind.HTML, _context.getKindOf(source)); | 798 expect(_context.getKindOf(source), same(SourceKind.HTML)); |
| 821 } | 799 } |
| 822 | 800 |
| 823 void test_getKindOf_library() { | 801 void test_getKindOf_library() { |
| 824 Source source = _addSource("/test.dart", "library lib;"); | 802 Source source = _addSource("/test.dart", "library lib;"); |
| 825 JUnitTestCase.assertSame(SourceKind.UNKNOWN, _context.getKindOf(source)); | 803 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); |
| 826 _context.computeKindOf(source); | 804 _context.computeKindOf(source); |
| 827 JUnitTestCase.assertSame(SourceKind.LIBRARY, _context.getKindOf(source)); | 805 expect(_context.getKindOf(source), same(SourceKind.LIBRARY)); |
| 828 } | 806 } |
| 829 | 807 |
| 830 void test_getKindOf_part() { | 808 void test_getKindOf_part() { |
| 831 Source source = _addSource("/test.dart", "part of lib;"); | 809 Source source = _addSource("/test.dart", "part of lib;"); |
| 832 JUnitTestCase.assertSame(SourceKind.UNKNOWN, _context.getKindOf(source)); | 810 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); |
| 833 _context.computeKindOf(source); | 811 _context.computeKindOf(source); |
| 834 JUnitTestCase.assertSame(SourceKind.PART, _context.getKindOf(source)); | 812 expect(_context.getKindOf(source), same(SourceKind.PART)); |
| 835 } | 813 } |
| 836 | 814 |
| 837 void test_getKindOf_unknown() { | 815 void test_getKindOf_unknown() { |
| 838 Source source = _addSource("/test.css", ""); | 816 Source source = _addSource("/test.css", ""); |
| 839 JUnitTestCase.assertSame(SourceKind.UNKNOWN, _context.getKindOf(source)); | 817 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); |
| 840 } | 818 } |
| 841 | 819 |
| 842 void test_getLaunchableClientLibrarySources() { | 820 void test_getLaunchableClientLibrarySources() { |
| 843 _context = AnalysisContextFactory.contextWithCore(); | 821 _context = AnalysisContextFactory.contextWithCore(); |
| 844 _sourceFactory = _context.sourceFactory; | 822 _sourceFactory = _context.sourceFactory; |
| 845 List<Source> sources = _context.launchableClientLibrarySources; | 823 List<Source> sources = _context.launchableClientLibrarySources; |
| 846 EngineTestCase.assertLength(0, sources); | 824 EngineTestCase.assertLength(0, sources); |
| 847 Source source = _addSource( | 825 Source source = _addSource( |
| 848 "/test.dart", | 826 "/test.dart", |
| 849 r''' | 827 r''' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 870 _sourceFactory = _context.sourceFactory; | 848 _sourceFactory = _context.sourceFactory; |
| 871 Source librarySource = _addSource( | 849 Source librarySource = _addSource( |
| 872 "/lib.dart", | 850 "/lib.dart", |
| 873 r''' | 851 r''' |
| 874 library lib; | 852 library lib; |
| 875 part 'part.dart';'''); | 853 part 'part.dart';'''); |
| 876 Source partSource = _addSource("/part.dart", "part of lib;"); | 854 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 877 _context.computeLibraryElement(librarySource); | 855 _context.computeLibraryElement(librarySource); |
| 878 List<Source> result = _context.getLibrariesContaining(librarySource); | 856 List<Source> result = _context.getLibrariesContaining(librarySource); |
| 879 EngineTestCase.assertLength(1, result); | 857 EngineTestCase.assertLength(1, result); |
| 880 JUnitTestCase.assertEquals(librarySource, result[0]); | 858 expect(result[0], librarySource); |
| 881 result = _context.getLibrariesContaining(partSource); | 859 result = _context.getLibrariesContaining(partSource); |
| 882 EngineTestCase.assertLength(1, result); | 860 EngineTestCase.assertLength(1, result); |
| 883 JUnitTestCase.assertEquals(librarySource, result[0]); | 861 expect(result[0], librarySource); |
| 884 } | 862 } |
| 885 | 863 |
| 886 void test_getLibrariesDependingOn() { | 864 void test_getLibrariesDependingOn() { |
| 887 _context = AnalysisContextFactory.contextWithCore(); | 865 _context = AnalysisContextFactory.contextWithCore(); |
| 888 _sourceFactory = _context.sourceFactory; | 866 _sourceFactory = _context.sourceFactory; |
| 889 Source libASource = _addSource("/libA.dart", "library libA;"); | 867 Source libASource = _addSource("/libA.dart", "library libA;"); |
| 890 _addSource("/libB.dart", "library libB;"); | 868 _addSource("/libB.dart", "library libB;"); |
| 891 Source lib1Source = _addSource( | 869 Source lib1Source = _addSource( |
| 892 "/lib1.dart", | 870 "/lib1.dart", |
| 893 r''' | 871 r''' |
| (...skipping 20 matching lines...) Expand all Loading... |
| 914 r''' | 892 r''' |
| 915 <html><head> | 893 <html><head> |
| 916 <script type='application/dart' src='test.dart'/> | 894 <script type='application/dart' src='test.dart'/> |
| 917 <script type='application/dart' src='test.js'/> | 895 <script type='application/dart' src='test.js'/> |
| 918 </head></html>'''); | 896 </head></html>'''); |
| 919 Source librarySource = _addSource("/test.dart", "library lib;"); | 897 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 920 _context.computeLibraryElement(librarySource); | 898 _context.computeLibraryElement(librarySource); |
| 921 _context.parseHtmlUnit(htmlSource); | 899 _context.parseHtmlUnit(htmlSource); |
| 922 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 900 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 923 EngineTestCase.assertLength(1, result); | 901 EngineTestCase.assertLength(1, result); |
| 924 JUnitTestCase.assertEquals(librarySource, result[0]); | 902 expect(result[0], librarySource); |
| 925 } | 903 } |
| 926 | 904 |
| 927 void test_getLibrariesReferencedFromHtml_no() { | 905 void test_getLibrariesReferencedFromHtml_no() { |
| 928 _context = AnalysisContextFactory.contextWithCore(); | 906 _context = AnalysisContextFactory.contextWithCore(); |
| 929 _sourceFactory = _context.sourceFactory; | 907 _sourceFactory = _context.sourceFactory; |
| 930 Source htmlSource = _addSource( | 908 Source htmlSource = _addSource( |
| 931 "/test.html", | 909 "/test.html", |
| 932 r''' | 910 r''' |
| 933 <html><head> | 911 <html><head> |
| 934 <script type='application/dart' src='test.js'/> | 912 <script type='application/dart' src='test.js'/> |
| 935 </head></html>'''); | 913 </head></html>'''); |
| 936 _addSource("/test.dart", "library lib;"); | 914 _addSource("/test.dart", "library lib;"); |
| 937 _context.parseHtmlUnit(htmlSource); | 915 _context.parseHtmlUnit(htmlSource); |
| 938 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 916 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 939 EngineTestCase.assertLength(0, result); | 917 EngineTestCase.assertLength(0, result); |
| 940 } | 918 } |
| 941 | 919 |
| 942 void test_getLibraryElement() { | 920 void test_getLibraryElement() { |
| 943 _context = AnalysisContextFactory.contextWithCore(); | 921 _context = AnalysisContextFactory.contextWithCore(); |
| 944 _sourceFactory = _context.sourceFactory; | 922 _sourceFactory = _context.sourceFactory; |
| 945 Source source = _addSource("/test.dart", "library lib;"); | 923 Source source = _addSource("/test.dart", "library lib;"); |
| 946 LibraryElement element = _context.getLibraryElement(source); | 924 LibraryElement element = _context.getLibraryElement(source); |
| 947 JUnitTestCase.assertNull(element); | 925 expect(element, isNull); |
| 948 _context.computeLibraryElement(source); | 926 _context.computeLibraryElement(source); |
| 949 element = _context.getLibraryElement(source); | 927 element = _context.getLibraryElement(source); |
| 950 JUnitTestCase.assertNotNull(element); | 928 expect(element, isNotNull); |
| 951 } | 929 } |
| 952 | 930 |
| 953 void test_getLibrarySources() { | 931 void test_getLibrarySources() { |
| 954 List<Source> sources = _context.librarySources; | 932 List<Source> sources = _context.librarySources; |
| 955 int originalLength = sources.length; | 933 int originalLength = sources.length; |
| 956 Source source = _addSource("/test.dart", "library lib;"); | 934 Source source = _addSource("/test.dart", "library lib;"); |
| 957 _context.computeKindOf(source); | 935 _context.computeKindOf(source); |
| 958 sources = _context.librarySources; | 936 sources = _context.librarySources; |
| 959 EngineTestCase.assertLength(originalLength + 1, sources); | 937 EngineTestCase.assertLength(originalLength + 1, sources); |
| 960 for (Source returnedSource in sources) { | 938 for (Source returnedSource in sources) { |
| 961 if (returnedSource == source) { | 939 if (returnedSource == source) { |
| 962 return; | 940 return; |
| 963 } | 941 } |
| 964 } | 942 } |
| 965 JUnitTestCase.fail( | 943 fail("The added source was not in the list of library sources"); |
| 966 "The added source was not in the list of library sources"); | |
| 967 } | 944 } |
| 968 | 945 |
| 969 void test_getLineInfo() { | 946 void test_getLineInfo() { |
| 970 Source source = _addSource( | 947 Source source = _addSource( |
| 971 "/test.dart", | 948 "/test.dart", |
| 972 r''' | 949 r''' |
| 973 library lib; | 950 library lib; |
| 974 | 951 |
| 975 main() {}'''); | 952 main() {}'''); |
| 976 LineInfo info = _context.getLineInfo(source); | 953 LineInfo info = _context.getLineInfo(source); |
| 977 JUnitTestCase.assertNull(info); | 954 expect(info, isNull); |
| 978 _context.parseCompilationUnit(source); | 955 _context.parseCompilationUnit(source); |
| 979 info = _context.getLineInfo(source); | 956 info = _context.getLineInfo(source); |
| 980 JUnitTestCase.assertNotNull(info); | 957 expect(info, isNotNull); |
| 981 } | 958 } |
| 982 | 959 |
| 983 void test_getModificationStamp_fromSource() { | 960 void test_getModificationStamp_fromSource() { |
| 984 int stamp = 42; | 961 int stamp = 42; |
| 985 JUnitTestCase.assertEquals( | 962 expect(_context.getModificationStamp( |
| 986 stamp, | 963 new AnalysisContextImplTest_Source_getModificationStamp_fromSource(s
tamp)), stamp); |
| 987 _context.getModificationStamp( | |
| 988 new AnalysisContextImplTest_Source_getModificationStamp_fromSource(s
tamp))); | |
| 989 } | 964 } |
| 990 | 965 |
| 991 void test_getModificationStamp_overridden() { | 966 void test_getModificationStamp_overridden() { |
| 992 int stamp = 42; | 967 int stamp = 42; |
| 993 Source source = | 968 Source source = |
| 994 new AnalysisContextImplTest_Source_getModificationStamp_overridden(stamp
); | 969 new AnalysisContextImplTest_Source_getModificationStamp_overridden(stamp
); |
| 995 _context.setContents(source, ""); | 970 _context.setContents(source, ""); |
| 996 JUnitTestCase.assertTrue(stamp != _context.getModificationStamp(source)); | 971 expect(stamp != _context.getModificationStamp(source), isTrue); |
| 997 } | 972 } |
| 998 | 973 |
| 999 void test_getPublicNamespace_element() { | 974 void test_getPublicNamespace_element() { |
| 1000 _context = AnalysisContextFactory.contextWithCore(); | 975 _context = AnalysisContextFactory.contextWithCore(); |
| 1001 _sourceFactory = _context.sourceFactory; | 976 _sourceFactory = _context.sourceFactory; |
| 1002 Source source = _addSource("/test.dart", "class A {}"); | 977 Source source = _addSource("/test.dart", "class A {}"); |
| 1003 LibraryElement library = _context.computeLibraryElement(source); | 978 LibraryElement library = _context.computeLibraryElement(source); |
| 1004 Namespace namespace = _context.getPublicNamespace(library); | 979 Namespace namespace = _context.getPublicNamespace(library); |
| 1005 JUnitTestCase.assertNotNull(namespace); | 980 expect(namespace, isNotNull); |
| 1006 EngineTestCase.assertInstanceOf( | 981 EngineTestCase.assertInstanceOf( |
| 1007 (obj) => obj is ClassElement, | 982 (obj) => obj is ClassElement, |
| 1008 ClassElement, | 983 ClassElement, |
| 1009 namespace.get("A")); | 984 namespace.get("A")); |
| 1010 } | 985 } |
| 1011 | 986 |
| 1012 void test_getRefactoringUnsafeSources() { | 987 void test_getRefactoringUnsafeSources() { |
| 1013 // not sources initially | 988 // not sources initially |
| 1014 List<Source> sources = _context.refactoringUnsafeSources; | 989 List<Source> sources = _context.refactoringUnsafeSources; |
| 1015 EngineTestCase.assertLength(0, sources); | 990 EngineTestCase.assertLength(0, sources); |
| 1016 // add new source, unresolved | 991 // add new source, unresolved |
| 1017 Source source = _addSource("/test.dart", "library lib;"); | 992 Source source = _addSource("/test.dart", "library lib;"); |
| 1018 sources = _context.refactoringUnsafeSources; | 993 sources = _context.refactoringUnsafeSources; |
| 1019 EngineTestCase.assertLength(1, sources); | 994 EngineTestCase.assertLength(1, sources); |
| 1020 JUnitTestCase.assertEquals(source, sources[0]); | 995 expect(sources[0], source); |
| 1021 // resolve source | 996 // resolve source |
| 1022 _context.computeLibraryElement(source); | 997 _context.computeLibraryElement(source); |
| 1023 sources = _context.refactoringUnsafeSources; | 998 sources = _context.refactoringUnsafeSources; |
| 1024 EngineTestCase.assertLength(0, sources); | 999 EngineTestCase.assertLength(0, sources); |
| 1025 } | 1000 } |
| 1026 | 1001 |
| 1027 void test_getResolvedCompilationUnit_library() { | 1002 void test_getResolvedCompilationUnit_library() { |
| 1028 _context = AnalysisContextFactory.contextWithCore(); | 1003 _context = AnalysisContextFactory.contextWithCore(); |
| 1029 _sourceFactory = _context.sourceFactory; | 1004 _sourceFactory = _context.sourceFactory; |
| 1030 Source source = _addSource("/lib.dart", "library libb;"); | 1005 Source source = _addSource("/lib.dart", "library libb;"); |
| 1031 LibraryElement library = _context.computeLibraryElement(source); | 1006 LibraryElement library = _context.computeLibraryElement(source); |
| 1032 JUnitTestCase.assertNotNull( | 1007 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); |
| 1033 _context.getResolvedCompilationUnit(source, library)); | |
| 1034 _context.setContents(source, "library lib;"); | 1008 _context.setContents(source, "library lib;"); |
| 1035 JUnitTestCase.assertNull( | 1009 expect(_context.getResolvedCompilationUnit(source, library), isNull); |
| 1036 _context.getResolvedCompilationUnit(source, library)); | |
| 1037 } | 1010 } |
| 1038 | 1011 |
| 1039 void test_getResolvedCompilationUnit_library_null() { | 1012 void test_getResolvedCompilationUnit_library_null() { |
| 1040 _context = AnalysisContextFactory.contextWithCore(); | 1013 _context = AnalysisContextFactory.contextWithCore(); |
| 1041 _sourceFactory = _context.sourceFactory; | 1014 _sourceFactory = _context.sourceFactory; |
| 1042 Source source = _addSource("/lib.dart", "library lib;"); | 1015 Source source = _addSource("/lib.dart", "library lib;"); |
| 1043 JUnitTestCase.assertNull(_context.getResolvedCompilationUnit(source, null)); | 1016 expect(_context.getResolvedCompilationUnit(source, null), isNull); |
| 1044 } | 1017 } |
| 1045 | 1018 |
| 1046 void test_getResolvedCompilationUnit_source_dart() { | 1019 void test_getResolvedCompilationUnit_source_dart() { |
| 1047 _context = AnalysisContextFactory.contextWithCore(); | 1020 _context = AnalysisContextFactory.contextWithCore(); |
| 1048 _sourceFactory = _context.sourceFactory; | 1021 _sourceFactory = _context.sourceFactory; |
| 1049 Source source = _addSource("/lib.dart", "library lib;"); | 1022 Source source = _addSource("/lib.dart", "library lib;"); |
| 1050 JUnitTestCase.assertNull( | 1023 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1051 _context.getResolvedCompilationUnit2(source, source)); | |
| 1052 _context.resolveCompilationUnit2(source, source); | 1024 _context.resolveCompilationUnit2(source, source); |
| 1053 JUnitTestCase.assertNotNull( | 1025 expect(_context.getResolvedCompilationUnit2(source, source), isNotNull); |
| 1054 _context.getResolvedCompilationUnit2(source, source)); | |
| 1055 } | 1026 } |
| 1056 | 1027 |
| 1057 void test_getResolvedCompilationUnit_source_html() { | 1028 void test_getResolvedCompilationUnit_source_html() { |
| 1058 _context = AnalysisContextFactory.contextWithCore(); | 1029 _context = AnalysisContextFactory.contextWithCore(); |
| 1059 _sourceFactory = _context.sourceFactory; | 1030 _sourceFactory = _context.sourceFactory; |
| 1060 Source source = _addSource("/test.html", "<html></html>"); | 1031 Source source = _addSource("/test.html", "<html></html>"); |
| 1061 JUnitTestCase.assertNull( | 1032 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1062 _context.getResolvedCompilationUnit2(source, source)); | 1033 expect(_context.resolveCompilationUnit2(source, source), isNull); |
| 1063 JUnitTestCase.assertNull(_context.resolveCompilationUnit2(source, source)); | 1034 expect(_context.getResolvedCompilationUnit2(source, source), isNull); |
| 1064 JUnitTestCase.assertNull( | |
| 1065 _context.getResolvedCompilationUnit2(source, source)); | |
| 1066 } | 1035 } |
| 1067 | 1036 |
| 1068 void test_getResolvedHtmlUnit() { | 1037 void test_getResolvedHtmlUnit() { |
| 1069 _context = AnalysisContextFactory.contextWithCore(); | 1038 _context = AnalysisContextFactory.contextWithCore(); |
| 1070 _sourceFactory = _context.sourceFactory; | 1039 _sourceFactory = _context.sourceFactory; |
| 1071 Source source = _addSource("/test.html", "<html></html>"); | 1040 Source source = _addSource("/test.html", "<html></html>"); |
| 1072 JUnitTestCase.assertNull(_context.getResolvedHtmlUnit(source)); | 1041 expect(_context.getResolvedHtmlUnit(source), isNull); |
| 1073 _context.resolveHtmlUnit(source); | 1042 _context.resolveHtmlUnit(source); |
| 1074 JUnitTestCase.assertNotNull(_context.getResolvedHtmlUnit(source)); | 1043 expect(_context.getResolvedHtmlUnit(source), isNotNull); |
| 1075 } | 1044 } |
| 1076 | 1045 |
| 1077 void test_getSourceFactory() { | 1046 void test_getSourceFactory() { |
| 1078 JUnitTestCase.assertSame(_sourceFactory, _context.sourceFactory); | 1047 expect(_context.sourceFactory, same(_sourceFactory)); |
| 1079 } | 1048 } |
| 1080 | 1049 |
| 1081 void test_getStatistics() { | 1050 void test_getStatistics() { |
| 1082 AnalysisContextStatistics statistics = _context.statistics; | 1051 AnalysisContextStatistics statistics = _context.statistics; |
| 1083 JUnitTestCase.assertNotNull(statistics); | 1052 expect(statistics, isNotNull); |
| 1084 // The following lines are fragile. | 1053 // The following lines are fragile. |
| 1085 // The values depend on the number of libraries in the SDK. | 1054 // The values depend on the number of libraries in the SDK. |
| 1086 // assertLength(0, statistics.getCacheRows()); | 1055 // assertLength(0, statistics.getCacheRows()); |
| 1087 // assertLength(0, statistics.getExceptions()); | 1056 // assertLength(0, statistics.getExceptions()); |
| 1088 // assertLength(0, statistics.getSources()); | 1057 // assertLength(0, statistics.getSources()); |
| 1089 } | 1058 } |
| 1090 | 1059 |
| 1091 void test_isClientLibrary_dart() { | 1060 void test_isClientLibrary_dart() { |
| 1092 _context = AnalysisContextFactory.contextWithCore(); | 1061 _context = AnalysisContextFactory.contextWithCore(); |
| 1093 _sourceFactory = _context.sourceFactory; | 1062 _sourceFactory = _context.sourceFactory; |
| 1094 Source source = _addSource( | 1063 Source source = _addSource( |
| 1095 "/test.dart", | 1064 "/test.dart", |
| 1096 r''' | 1065 r''' |
| 1097 import 'dart:html'; | 1066 import 'dart:html'; |
| 1098 | 1067 |
| 1099 main() {}'''); | 1068 main() {}'''); |
| 1100 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1069 expect(_context.isClientLibrary(source), isFalse); |
| 1101 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1070 expect(_context.isServerLibrary(source), isFalse); |
| 1102 _context.computeLibraryElement(source); | 1071 _context.computeLibraryElement(source); |
| 1103 JUnitTestCase.assertTrue(_context.isClientLibrary(source)); | 1072 expect(_context.isClientLibrary(source), isTrue); |
| 1104 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1073 expect(_context.isServerLibrary(source), isFalse); |
| 1105 } | 1074 } |
| 1106 | 1075 |
| 1107 void test_isClientLibrary_html() { | 1076 void test_isClientLibrary_html() { |
| 1108 Source source = _addSource("/test.html", "<html></html>"); | 1077 Source source = _addSource("/test.html", "<html></html>"); |
| 1109 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1078 expect(_context.isClientLibrary(source), isFalse); |
| 1110 } | 1079 } |
| 1111 | 1080 |
| 1112 void test_isServerLibrary_dart() { | 1081 void test_isServerLibrary_dart() { |
| 1113 _context = AnalysisContextFactory.contextWithCore(); | 1082 _context = AnalysisContextFactory.contextWithCore(); |
| 1114 _sourceFactory = _context.sourceFactory; | 1083 _sourceFactory = _context.sourceFactory; |
| 1115 Source source = _addSource( | 1084 Source source = _addSource( |
| 1116 "/test.dart", | 1085 "/test.dart", |
| 1117 r''' | 1086 r''' |
| 1118 library lib; | 1087 library lib; |
| 1119 | 1088 |
| 1120 main() {}'''); | 1089 main() {}'''); |
| 1121 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1090 expect(_context.isClientLibrary(source), isFalse); |
| 1122 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1091 expect(_context.isServerLibrary(source), isFalse); |
| 1123 _context.computeLibraryElement(source); | 1092 _context.computeLibraryElement(source); |
| 1124 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1093 expect(_context.isClientLibrary(source), isFalse); |
| 1125 JUnitTestCase.assertTrue(_context.isServerLibrary(source)); | 1094 expect(_context.isServerLibrary(source), isTrue); |
| 1126 } | 1095 } |
| 1127 | 1096 |
| 1128 void test_isServerLibrary_html() { | 1097 void test_isServerLibrary_html() { |
| 1129 Source source = _addSource("/test.html", "<html></html>"); | 1098 Source source = _addSource("/test.html", "<html></html>"); |
| 1130 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1099 expect(_context.isServerLibrary(source), isFalse); |
| 1131 } | 1100 } |
| 1132 | 1101 |
| 1133 void test_parseCompilationUnit_errors() { | 1102 void test_parseCompilationUnit_errors() { |
| 1134 Source source = _addSource("/lib.dart", "library {"); | 1103 Source source = _addSource("/lib.dart", "library {"); |
| 1135 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | 1104 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 1136 JUnitTestCase.assertNotNull(compilationUnit); | 1105 expect(compilationUnit, isNotNull); |
| 1137 List<AnalysisError> errors = _context.getErrors(source).errors; | 1106 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 1138 JUnitTestCase.assertNotNull(errors); | 1107 expect(errors, isNotNull); |
| 1139 JUnitTestCase.assertTrue(errors.length > 0); | 1108 expect(errors.length > 0, isTrue); |
| 1140 } | 1109 } |
| 1141 | 1110 |
| 1142 void test_parseCompilationUnit_exception() { | 1111 void test_parseCompilationUnit_exception() { |
| 1143 Source source = _addSourceWithException("/test.dart"); | 1112 Source source = _addSourceWithException("/test.dart"); |
| 1144 try { | 1113 try { |
| 1145 _context.parseCompilationUnit(source); | 1114 _context.parseCompilationUnit(source); |
| 1146 JUnitTestCase.fail("Expected AnalysisException"); | 1115 fail("Expected AnalysisException"); |
| 1147 } on AnalysisException catch (exception) { | 1116 } on AnalysisException catch (exception) { |
| 1148 // Expected | 1117 // Expected |
| 1149 } | 1118 } |
| 1150 } | 1119 } |
| 1151 | 1120 |
| 1152 void test_parseCompilationUnit_html() { | 1121 void test_parseCompilationUnit_html() { |
| 1153 Source source = _addSource("/test.html", "<html></html>"); | 1122 Source source = _addSource("/test.html", "<html></html>"); |
| 1154 JUnitTestCase.assertNull(_context.parseCompilationUnit(source)); | 1123 expect(_context.parseCompilationUnit(source), isNull); |
| 1155 } | 1124 } |
| 1156 | 1125 |
| 1157 void test_parseCompilationUnit_noErrors() { | 1126 void test_parseCompilationUnit_noErrors() { |
| 1158 Source source = _addSource("/lib.dart", "library lib;"); | 1127 Source source = _addSource("/lib.dart", "library lib;"); |
| 1159 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | 1128 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 1160 JUnitTestCase.assertNotNull(compilationUnit); | 1129 expect(compilationUnit, isNotNull); |
| 1161 EngineTestCase.assertLength(0, _context.getErrors(source).errors); | 1130 EngineTestCase.assertLength(0, _context.getErrors(source).errors); |
| 1162 } | 1131 } |
| 1163 | 1132 |
| 1164 void test_parseCompilationUnit_nonExistentSource() { | 1133 void test_parseCompilationUnit_nonExistentSource() { |
| 1165 Source source = | 1134 Source source = |
| 1166 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 1135 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 1167 try { | 1136 try { |
| 1168 _context.parseCompilationUnit(source); | 1137 _context.parseCompilationUnit(source); |
| 1169 JUnitTestCase.fail( | 1138 fail("Expected AnalysisException because file does not exist"); |
| 1170 "Expected AnalysisException because file does not exist"); | |
| 1171 } on AnalysisException catch (exception) { | 1139 } on AnalysisException catch (exception) { |
| 1172 // Expected result | 1140 // Expected result |
| 1173 } | 1141 } |
| 1174 } | 1142 } |
| 1175 | 1143 |
| 1176 void test_parseHtmlUnit_noErrors() { | 1144 void test_parseHtmlUnit_noErrors() { |
| 1177 Source source = _addSource("/lib.html", "<html></html>"); | 1145 Source source = _addSource("/lib.html", "<html></html>"); |
| 1178 ht.HtmlUnit unit = _context.parseHtmlUnit(source); | 1146 ht.HtmlUnit unit = _context.parseHtmlUnit(source); |
| 1179 JUnitTestCase.assertNotNull(unit); | 1147 expect(unit, isNotNull); |
| 1180 } | 1148 } |
| 1181 | 1149 |
| 1182 void test_parseHtmlUnit_resolveDirectives() { | 1150 void test_parseHtmlUnit_resolveDirectives() { |
| 1183 Source libSource = _addSource( | 1151 Source libSource = _addSource( |
| 1184 "/lib.dart", | 1152 "/lib.dart", |
| 1185 r''' | 1153 r''' |
| 1186 library lib; | 1154 library lib; |
| 1187 class ClassA {}'''); | 1155 class ClassA {}'''); |
| 1188 Source source = _addSource( | 1156 Source source = _addSource( |
| 1189 "/lib.html", | 1157 "/lib.html", |
| 1190 r''' | 1158 r''' |
| 1191 <html> | 1159 <html> |
| 1192 <head> | 1160 <head> |
| 1193 <script type='application/dart'> | 1161 <script type='application/dart'> |
| 1194 import 'lib.dart'; | 1162 import 'lib.dart'; |
| 1195 ClassA v = null; | 1163 ClassA v = null; |
| 1196 </script> | 1164 </script> |
| 1197 </head> | 1165 </head> |
| 1198 <body> | 1166 <body> |
| 1199 </body> | 1167 </body> |
| 1200 </html>'''); | 1168 </html>'''); |
| 1201 ht.HtmlUnit unit = _context.parseHtmlUnit(source); | 1169 ht.HtmlUnit unit = _context.parseHtmlUnit(source); |
| 1202 // import directive should be resolved | 1170 // import directive should be resolved |
| 1203 ht.XmlTagNode htmlNode = unit.tagNodes[0]; | 1171 ht.XmlTagNode htmlNode = unit.tagNodes[0]; |
| 1204 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; | 1172 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; |
| 1205 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; | 1173 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; |
| 1206 CompilationUnit script = scriptNode.script; | 1174 CompilationUnit script = scriptNode.script; |
| 1207 ImportDirective importNode = script.directives[0] as ImportDirective; | 1175 ImportDirective importNode = script.directives[0] as ImportDirective; |
| 1208 JUnitTestCase.assertNotNull(importNode.uriContent); | 1176 expect(importNode.uriContent, isNotNull); |
| 1209 JUnitTestCase.assertEquals(libSource, importNode.source); | 1177 expect(importNode.source, libSource); |
| 1210 } | 1178 } |
| 1211 | 1179 |
| 1212 void test_performAnalysisTask_IOException() { | 1180 void test_performAnalysisTask_IOException() { |
| 1213 TestSource source = _addSourceWithException2("/test.dart", "library test;"); | 1181 TestSource source = _addSourceWithException2("/test.dart", "library test;"); |
| 1214 int oldTimestamp = _context.getModificationStamp(source); | 1182 int oldTimestamp = _context.getModificationStamp(source); |
| 1215 source.generateExceptionOnRead = false; | 1183 source.generateExceptionOnRead = false; |
| 1216 _analyzeAll_assertFinished(); | 1184 _analyzeAll_assertFinished(); |
| 1217 JUnitTestCase.assertEquals(1, source.readCount); | 1185 expect(source.readCount, 1); |
| 1218 source.generateExceptionOnRead = true; | 1186 source.generateExceptionOnRead = true; |
| 1219 do { | 1187 do { |
| 1220 _changeSource(source, ""); | 1188 _changeSource(source, ""); |
| 1221 // Ensure that the timestamp differs, | 1189 // Ensure that the timestamp differs, |
| 1222 // so that analysis engine notices the change | 1190 // so that analysis engine notices the change |
| 1223 } while (oldTimestamp == _context.getModificationStamp(source)); | 1191 } while (oldTimestamp == _context.getModificationStamp(source)); |
| 1224 _analyzeAll_assertFinished(); | 1192 _analyzeAll_assertFinished(); |
| 1225 JUnitTestCase.assertEquals(2, source.readCount); | 1193 expect(source.readCount, 2); |
| 1226 } | 1194 } |
| 1227 | 1195 |
| 1228 void test_performAnalysisTask_addPart() { | 1196 void test_performAnalysisTask_addPart() { |
| 1229 Source libSource = _addSource( | 1197 Source libSource = _addSource( |
| 1230 "/lib.dart", | 1198 "/lib.dart", |
| 1231 r''' | 1199 r''' |
| 1232 library lib; | 1200 library lib; |
| 1233 part 'part.dart';'''); | 1201 part 'part.dart';'''); |
| 1234 // run all tasks without part | 1202 // run all tasks without part |
| 1235 _analyzeAll_assertFinished(); | 1203 _analyzeAll_assertFinished(); |
| 1236 // add part and run all tasks | 1204 // add part and run all tasks |
| 1237 Source partSource = | 1205 Source partSource = |
| 1238 _addSource("/part.dart", r''' | 1206 _addSource("/part.dart", r''' |
| 1239 part of lib; | 1207 part of lib; |
| 1240 '''); | 1208 '''); |
| 1241 _analyzeAll_assertFinished(); | 1209 _analyzeAll_assertFinished(); |
| 1242 // "libSource" should be here | 1210 // "libSource" should be here |
| 1243 List<Source> librariesWithPart = | 1211 List<Source> librariesWithPart = |
| 1244 _context.getLibrariesContaining(partSource); | 1212 _context.getLibrariesContaining(partSource); |
| 1245 EngineTestCase.assertContains(librariesWithPart, [libSource]); | 1213 EngineTestCase.assertContains(librariesWithPart, [libSource]); |
| 1246 } | 1214 } |
| 1247 | 1215 |
| 1248 void test_performAnalysisTask_changeLibraryContents() { | 1216 void test_performAnalysisTask_changeLibraryContents() { |
| 1249 Source libSource = | 1217 Source libSource = |
| 1250 _addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1218 _addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1251 Source partSource = _addSource("/test-part.dart", "part of lib;"); | 1219 Source partSource = _addSource("/test-part.dart", "part of lib;"); |
| 1252 _analyzeAll_assertFinished(); | 1220 _analyzeAll_assertFinished(); |
| 1253 JUnitTestCase.assertNotNullMsg( | 1221 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 1"); |
| 1254 "library resolved 1", | 1222 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 1"); |
| 1255 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1256 JUnitTestCase.assertNotNullMsg( | |
| 1257 "part resolved 1", | |
| 1258 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1259 // update and analyze #1 | 1223 // update and analyze #1 |
| 1260 _context.setContents(libSource, "library lib;"); | 1224 _context.setContents(libSource, "library lib;"); |
| 1261 JUnitTestCase.assertNullMsg( | 1225 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); |
| 1262 "library changed 2", | 1226 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); |
| 1263 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1264 JUnitTestCase.assertNullMsg( | |
| 1265 "part changed 2", | |
| 1266 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1267 _analyzeAll_assertFinished(); | 1227 _analyzeAll_assertFinished(); |
| 1268 JUnitTestCase.assertNotNullMsg( | 1228 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1269 "library resolved 2", | 1229 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part resolved 2"); |
| 1270 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1271 JUnitTestCase.assertNullMsg( | |
| 1272 "part resolved 2", | |
| 1273 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1274 // update and analyze #2 | 1230 // update and analyze #2 |
| 1275 _context.setContents(libSource, "library lib; part 'test-part.dart';"); | 1231 _context.setContents(libSource, "library lib; part 'test-part.dart';"); |
| 1276 JUnitTestCase.assertNullMsg( | 1232 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 3"); |
| 1277 "library changed 3", | 1233 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 3"); |
| 1278 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1279 JUnitTestCase.assertNullMsg( | |
| 1280 "part changed 3", | |
| 1281 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1282 _analyzeAll_assertFinished(); | 1234 _analyzeAll_assertFinished(); |
| 1283 JUnitTestCase.assertNotNullMsg( | 1235 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1284 "library resolved 2", | 1236 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 3"); |
| 1285 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1286 JUnitTestCase.assertNotNullMsg( | |
| 1287 "part resolved 3", | |
| 1288 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1289 } | 1237 } |
| 1290 | 1238 |
| 1291 void test_performAnalysisTask_changeLibraryThenPartContents() { | 1239 void test_performAnalysisTask_changeLibraryThenPartContents() { |
| 1292 Source libSource = | 1240 Source libSource = |
| 1293 _addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1241 _addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1294 Source partSource = _addSource("/test-part.dart", "part of lib;"); | 1242 Source partSource = _addSource("/test-part.dart", "part of lib;"); |
| 1295 _analyzeAll_assertFinished(); | 1243 _analyzeAll_assertFinished(); |
| 1296 JUnitTestCase.assertNotNullMsg( | 1244 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 1"); |
| 1297 "library resolved 1", | 1245 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 1"); |
| 1298 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1299 JUnitTestCase.assertNotNullMsg( | |
| 1300 "part resolved 1", | |
| 1301 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1302 // update and analyze #1 | 1246 // update and analyze #1 |
| 1303 _context.setContents(libSource, "library lib;"); | 1247 _context.setContents(libSource, "library lib;"); |
| 1304 JUnitTestCase.assertNullMsg( | 1248 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); |
| 1305 "library changed 2", | 1249 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); |
| 1306 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1307 JUnitTestCase.assertNullMsg( | |
| 1308 "part changed 2", | |
| 1309 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1310 _analyzeAll_assertFinished(); | 1250 _analyzeAll_assertFinished(); |
| 1311 JUnitTestCase.assertNotNullMsg( | 1251 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1312 "library resolved 2", | 1252 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part resolved 2"); |
| 1313 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1314 JUnitTestCase.assertNullMsg( | |
| 1315 "part resolved 2", | |
| 1316 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1317 // update and analyze #2 | 1253 // update and analyze #2 |
| 1318 _context.setContents(partSource, "part of lib; // 1"); | 1254 _context.setContents(partSource, "part of lib; // 1"); |
| 1319 // Assert that changing the part's content does not effect the library | 1255 // Assert that changing the part's content does not effect the library |
| 1320 // now that it is no longer part of that library | 1256 // now that it is no longer part of that library |
| 1321 JUnitTestCase.assertNotNullMsg( | 1257 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library changed 3"); |
| 1322 "library changed 3", | 1258 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 3"); |
| 1323 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1324 JUnitTestCase.assertNullMsg( | |
| 1325 "part changed 3", | |
| 1326 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1327 _analyzeAll_assertFinished(); | 1259 _analyzeAll_assertFinished(); |
| 1328 JUnitTestCase.assertNotNullMsg( | 1260 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 3"); |
| 1329 "library resolved 3", | 1261 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part resolved 3"); |
| 1330 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1331 JUnitTestCase.assertNullMsg( | |
| 1332 "part resolved 3", | |
| 1333 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1334 } | 1262 } |
| 1335 | 1263 |
| 1336 void test_performAnalysisTask_changePartContents_makeItAPart() { | 1264 void test_performAnalysisTask_changePartContents_makeItAPart() { |
| 1337 Source libSource = _addSource( | 1265 Source libSource = _addSource( |
| 1338 "/lib.dart", | 1266 "/lib.dart", |
| 1339 r''' | 1267 r''' |
| 1340 library lib; | 1268 library lib; |
| 1341 part 'part.dart'; | 1269 part 'part.dart'; |
| 1342 void f(x) {}'''); | 1270 void f(x) {}'''); |
| 1343 Source partSource = _addSource( | 1271 Source partSource = _addSource( |
| 1344 "/part.dart", | 1272 "/part.dart", |
| 1345 "void g() { f(null); }"); | 1273 "void g() { f(null); }"); |
| 1346 _analyzeAll_assertFinished(); | 1274 _analyzeAll_assertFinished(); |
| 1347 JUnitTestCase.assertNotNullMsg( | 1275 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 1"); |
| 1348 "library resolved 1", | 1276 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 1"); |
| 1349 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1350 JUnitTestCase.assertNotNullMsg( | |
| 1351 "part resolved 1", | |
| 1352 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1353 // update and analyze | 1277 // update and analyze |
| 1354 _context.setContents( | 1278 _context.setContents( |
| 1355 partSource, | 1279 partSource, |
| 1356 r''' | 1280 r''' |
| 1357 part of lib; | 1281 part of lib; |
| 1358 void g() { f(null); }'''); | 1282 void g() { f(null); }'''); |
| 1359 JUnitTestCase.assertNullMsg( | 1283 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); |
| 1360 "library changed 2", | 1284 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); |
| 1361 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1362 JUnitTestCase.assertNullMsg( | |
| 1363 "part changed 2", | |
| 1364 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1365 _analyzeAll_assertFinished(); | 1285 _analyzeAll_assertFinished(); |
| 1366 JUnitTestCase.assertNotNullMsg( | 1286 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1367 "library resolved 2", | 1287 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 2"); |
| 1368 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1369 JUnitTestCase.assertNotNullMsg( | |
| 1370 "part resolved 2", | |
| 1371 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1372 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1288 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); |
| 1373 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1289 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); |
| 1374 } | 1290 } |
| 1375 | 1291 |
| 1376 /** | 1292 /** |
| 1377 * https://code.google.com/p/dart/issues/detail?id=12424 | 1293 * https://code.google.com/p/dart/issues/detail?id=12424 |
| 1378 */ | 1294 */ |
| 1379 void test_performAnalysisTask_changePartContents_makeItNotPart() { | 1295 void test_performAnalysisTask_changePartContents_makeItNotPart() { |
| 1380 Source libSource = _addSource( | 1296 Source libSource = _addSource( |
| 1381 "/lib.dart", | 1297 "/lib.dart", |
| 1382 r''' | 1298 r''' |
| 1383 library lib; | 1299 library lib; |
| 1384 part 'part.dart'; | 1300 part 'part.dart'; |
| 1385 void f(x) {}'''); | 1301 void f(x) {}'''); |
| 1386 Source partSource = _addSource( | 1302 Source partSource = _addSource( |
| 1387 "/part.dart", | 1303 "/part.dart", |
| 1388 r''' | 1304 r''' |
| 1389 part of lib; | 1305 part of lib; |
| 1390 void g() { f(null); }'''); | 1306 void g() { f(null); }'''); |
| 1391 _analyzeAll_assertFinished(); | 1307 _analyzeAll_assertFinished(); |
| 1392 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1308 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); |
| 1393 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1309 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); |
| 1394 // Remove 'part' directive, which should make "f(null)" an error. | 1310 // Remove 'part' directive, which should make "f(null)" an error. |
| 1395 _context.setContents( | 1311 _context.setContents( |
| 1396 partSource, | 1312 partSource, |
| 1397 r''' | 1313 r''' |
| 1398 //part of lib; | 1314 //part of lib; |
| 1399 void g() { f(null); }'''); | 1315 void g() { f(null); }'''); |
| 1400 _analyzeAll_assertFinished(); | 1316 _analyzeAll_assertFinished(); |
| 1401 JUnitTestCase.assertTrue(_context.getErrors(libSource).errors.length != 0); | 1317 expect(_context.getErrors(libSource).errors.length != 0, isTrue); |
| 1402 } | 1318 } |
| 1403 | 1319 |
| 1404 void test_performAnalysisTask_changePartContents_noSemanticChanges() { | 1320 void test_performAnalysisTask_changePartContents_noSemanticChanges() { |
| 1405 Source libSource = | 1321 Source libSource = |
| 1406 _addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1322 _addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1407 Source partSource = _addSource("/test-part.dart", "part of lib;"); | 1323 Source partSource = _addSource("/test-part.dart", "part of lib;"); |
| 1408 _analyzeAll_assertFinished(); | 1324 _analyzeAll_assertFinished(); |
| 1409 JUnitTestCase.assertNotNullMsg( | 1325 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 1"); |
| 1410 "library resolved 1", | 1326 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 1"); |
| 1411 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1412 JUnitTestCase.assertNotNullMsg( | |
| 1413 "part resolved 1", | |
| 1414 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1415 // update and analyze #1 | 1327 // update and analyze #1 |
| 1416 _context.setContents(partSource, "part of lib; // 1"); | 1328 _context.setContents(partSource, "part of lib; // 1"); |
| 1417 JUnitTestCase.assertNullMsg( | 1329 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); |
| 1418 "library changed 2", | 1330 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); |
| 1419 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1420 JUnitTestCase.assertNullMsg( | |
| 1421 "part changed 2", | |
| 1422 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1423 _analyzeAll_assertFinished(); | 1331 _analyzeAll_assertFinished(); |
| 1424 JUnitTestCase.assertNotNullMsg( | 1332 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1425 "library resolved 2", | 1333 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 2"); |
| 1426 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1427 JUnitTestCase.assertNotNullMsg( | |
| 1428 "part resolved 2", | |
| 1429 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1430 // update and analyze #2 | 1334 // update and analyze #2 |
| 1431 _context.setContents(partSource, "part of lib; // 12"); | 1335 _context.setContents(partSource, "part of lib; // 12"); |
| 1432 JUnitTestCase.assertNullMsg( | 1336 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 3"); |
| 1433 "library changed 3", | 1337 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 3"); |
| 1434 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1435 JUnitTestCase.assertNullMsg( | |
| 1436 "part changed 3", | |
| 1437 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1438 _analyzeAll_assertFinished(); | 1338 _analyzeAll_assertFinished(); |
| 1439 JUnitTestCase.assertNotNullMsg( | 1339 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 3"); |
| 1440 "library resolved 3", | 1340 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 3"); |
| 1441 _context.getResolvedCompilationUnit2(libSource, libSource)); | |
| 1442 JUnitTestCase.assertNotNullMsg( | |
| 1443 "part resolved 3", | |
| 1444 _context.getResolvedCompilationUnit2(partSource, libSource)); | |
| 1445 } | 1341 } |
| 1446 | 1342 |
| 1447 void test_performAnalysisTask_importedLibraryAdd() { | 1343 void test_performAnalysisTask_importedLibraryAdd() { |
| 1448 Source libASource = | 1344 Source libASource = |
| 1449 _addSource("/libA.dart", "library libA; import 'libB.dart';"); | 1345 _addSource("/libA.dart", "library libA; import 'libB.dart';"); |
| 1450 _analyzeAll_assertFinished(); | 1346 _analyzeAll_assertFinished(); |
| 1451 JUnitTestCase.assertNotNullMsg( | 1347 expect(_context.getResolvedCompilationUnit2(libASource, libASource), isNotNu
ll, reason: "libA resolved 1"); |
| 1452 "libA resolved 1", | 1348 expect(_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource)), i
sTrue, reason: "libA has an error"); |
| 1453 _context.getResolvedCompilationUnit2(libASource, libASource)); | |
| 1454 JUnitTestCase.assertTrueMsg( | |
| 1455 "libA has an error", | |
| 1456 _hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); | |
| 1457 // add libB.dart and analyze | 1349 // add libB.dart and analyze |
| 1458 Source libBSource = _addSource("/libB.dart", "library libB;"); | 1350 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 1459 _analyzeAll_assertFinished(); | 1351 _analyzeAll_assertFinished(); |
| 1460 JUnitTestCase.assertNotNullMsg( | 1352 expect(_context.getResolvedCompilationUnit2(libASource, libASource), isNotNu
ll, reason: "libA resolved 2"); |
| 1461 "libA resolved 2", | 1353 expect(_context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNu
ll, reason: "libB resolved 2"); |
| 1462 _context.getResolvedCompilationUnit2(libASource, libASource)); | 1354 expect(!_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource)),
isTrue, reason: "libA doesn't have errors"); |
| 1463 JUnitTestCase.assertNotNullMsg( | |
| 1464 "libB resolved 2", | |
| 1465 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | |
| 1466 JUnitTestCase.assertTrueMsg( | |
| 1467 "libA doesn't have errors", | |
| 1468 !_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); | |
| 1469 } | 1355 } |
| 1470 | 1356 |
| 1471 void test_performAnalysisTask_importedLibraryAdd_html() { | 1357 void test_performAnalysisTask_importedLibraryAdd_html() { |
| 1472 Source htmlSource = _addSource( | 1358 Source htmlSource = _addSource( |
| 1473 "/page.html", | 1359 "/page.html", |
| 1474 r''' | 1360 r''' |
| 1475 <html><body><script type="application/dart"> | 1361 <html><body><script type="application/dart"> |
| 1476 import '/libB.dart'; | 1362 import '/libB.dart'; |
| 1477 main() {print('hello dart');} | 1363 main() {print('hello dart');} |
| 1478 </script></body></html>'''); | 1364 </script></body></html>'''); |
| 1479 _analyzeAll_assertFinished(); | 1365 _analyzeAll_assertFinished(); |
| 1480 JUnitTestCase.assertNotNullMsg( | 1366 expect(_context.getResolvedHtmlUnit(htmlSource), isNotNull, reason: "htmlUni
t resolved 1"); |
| 1481 "htmlUnit resolved 1", | 1367 expect(_hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource)), i
sTrue, reason: "htmlSource has an error"); |
| 1482 _context.getResolvedHtmlUnit(htmlSource)); | |
| 1483 JUnitTestCase.assertTrueMsg( | |
| 1484 "htmlSource has an error", | |
| 1485 _hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource))); | |
| 1486 // add libB.dart and analyze | 1368 // add libB.dart and analyze |
| 1487 Source libBSource = _addSource("/libB.dart", "library libB;"); | 1369 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 1488 _analyzeAll_assertFinished(); | 1370 _analyzeAll_assertFinished(); |
| 1489 JUnitTestCase.assertNotNullMsg( | 1371 expect(_context.getResolvedHtmlUnit(htmlSource), isNotNull, reason: "htmlUni
t resolved 1"); |
| 1490 "htmlUnit resolved 1", | 1372 expect(_context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNu
ll, reason: "libB resolved 2"); |
| 1491 _context.getResolvedHtmlUnit(htmlSource)); | |
| 1492 JUnitTestCase.assertNotNullMsg( | |
| 1493 "libB resolved 2", | |
| 1494 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | |
| 1495 AnalysisErrorInfo errors = _context.getErrors(htmlSource); | 1373 AnalysisErrorInfo errors = _context.getErrors(htmlSource); |
| 1496 JUnitTestCase.assertTrueMsg( | 1374 expect(!_hasAnalysisErrorWithErrorSeverity(errors), isTrue, reason: "htmlSou
rce doesn't have errors"); |
| 1497 "htmlSource doesn't have errors", | |
| 1498 !_hasAnalysisErrorWithErrorSeverity(errors)); | |
| 1499 } | 1375 } |
| 1500 | 1376 |
| 1501 void test_performAnalysisTask_importedLibraryDelete() { | 1377 void test_performAnalysisTask_importedLibraryDelete() { |
| 1502 Source libASource = | 1378 Source libASource = |
| 1503 _addSource("/libA.dart", "library libA; import 'libB.dart';"); | 1379 _addSource("/libA.dart", "library libA; import 'libB.dart';"); |
| 1504 Source libBSource = _addSource("/libB.dart", "library libB;"); | 1380 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 1505 _analyzeAll_assertFinished(); | 1381 _analyzeAll_assertFinished(); |
| 1506 JUnitTestCase.assertNotNullMsg( | 1382 expect(_context.getResolvedCompilationUnit2(libASource, libASource), isNotNu
ll, reason: "libA resolved 1"); |
| 1507 "libA resolved 1", | 1383 expect(_context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNu
ll, reason: "libB resolved 1"); |
| 1508 _context.getResolvedCompilationUnit2(libASource, libASource)); | 1384 expect(!_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource)),
isTrue, reason: "libA doesn't have errors"); |
| 1509 JUnitTestCase.assertNotNullMsg( | |
| 1510 "libB resolved 1", | |
| 1511 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | |
| 1512 JUnitTestCase.assertTrueMsg( | |
| 1513 "libA doesn't have errors", | |
| 1514 !_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); | |
| 1515 // remove libB.dart content and analyze | 1385 // remove libB.dart content and analyze |
| 1516 _context.setContents(libBSource, null); | 1386 _context.setContents(libBSource, null); |
| 1517 _analyzeAll_assertFinished(); | 1387 _analyzeAll_assertFinished(); |
| 1518 JUnitTestCase.assertNotNullMsg( | 1388 expect(_context.getResolvedCompilationUnit2(libASource, libASource), isNotNu
ll, reason: "libA resolved 2"); |
| 1519 "libA resolved 2", | 1389 expect(_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource)), i
sTrue, reason: "libA has an error"); |
| 1520 _context.getResolvedCompilationUnit2(libASource, libASource)); | |
| 1521 JUnitTestCase.assertTrueMsg( | |
| 1522 "libA has an error", | |
| 1523 _hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); | |
| 1524 } | 1390 } |
| 1525 | 1391 |
| 1526 void test_performAnalysisTask_missingPart() { | 1392 void test_performAnalysisTask_missingPart() { |
| 1527 Source source = | 1393 Source source = |
| 1528 _addSource("/test.dart", "library lib; part 'no-such-file.dart';"); | 1394 _addSource("/test.dart", "library lib; part 'no-such-file.dart';"); |
| 1529 _analyzeAll_assertFinished(); | 1395 _analyzeAll_assertFinished(); |
| 1530 JUnitTestCase.assertNotNullMsg( | 1396 expect(_context.getLibraryElement(source), isNotNull, reason: "performAnalys
isTask failed to compute an element model"); |
| 1531 "performAnalysisTask failed to compute an element model", | |
| 1532 _context.getLibraryElement(source)); | |
| 1533 } | 1397 } |
| 1534 | 1398 |
| 1535 void test_performAnalysisTask_modifiedAfterParse() { | 1399 void test_performAnalysisTask_modifiedAfterParse() { |
| 1536 // TODO(scheglov) no threads in Dart | 1400 // TODO(scheglov) no threads in Dart |
| 1537 // Source source = _addSource("/test.dart", "library lib;"); | 1401 // Source source = _addSource("/test.dart", "library lib;"); |
| 1538 // int initialTime = _context.getModificationStamp(source); | 1402 // int initialTime = _context.getModificationStamp(source); |
| 1539 // List<Source> sources = new List<Source>(); | 1403 // List<Source> sources = new List<Source>(); |
| 1540 // sources.add(source); | 1404 // sources.add(source); |
| 1541 // _context.analysisPriorityOrder = sources; | 1405 // _context.analysisPriorityOrder = sources; |
| 1542 // _context.parseCompilationUnit(source); | 1406 // _context.parseCompilationUnit(source); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); | 1442 assertNamedElements(visibleLibraries, ["dart.core", "libA", "libB"]); |
| 1579 } | 1443 } |
| 1580 | 1444 |
| 1581 void test_resolveCompilationUnit_library() { | 1445 void test_resolveCompilationUnit_library() { |
| 1582 _context = AnalysisContextFactory.contextWithCore(); | 1446 _context = AnalysisContextFactory.contextWithCore(); |
| 1583 _sourceFactory = _context.sourceFactory; | 1447 _sourceFactory = _context.sourceFactory; |
| 1584 Source source = _addSource("/lib.dart", "library lib;"); | 1448 Source source = _addSource("/lib.dart", "library lib;"); |
| 1585 LibraryElement library = _context.computeLibraryElement(source); | 1449 LibraryElement library = _context.computeLibraryElement(source); |
| 1586 CompilationUnit compilationUnit = | 1450 CompilationUnit compilationUnit = |
| 1587 _context.resolveCompilationUnit(source, library); | 1451 _context.resolveCompilationUnit(source, library); |
| 1588 JUnitTestCase.assertNotNull(compilationUnit); | 1452 expect(compilationUnit, isNotNull); |
| 1589 JUnitTestCase.assertNotNull(compilationUnit.element); | 1453 expect(compilationUnit.element, isNotNull); |
| 1590 } | 1454 } |
| 1591 | 1455 |
| 1592 void test_resolveCompilationUnit_source() { | 1456 void test_resolveCompilationUnit_source() { |
| 1593 _context = AnalysisContextFactory.contextWithCore(); | 1457 _context = AnalysisContextFactory.contextWithCore(); |
| 1594 _sourceFactory = _context.sourceFactory; | 1458 _sourceFactory = _context.sourceFactory; |
| 1595 Source source = _addSource("/lib.dart", "library lib;"); | 1459 Source source = _addSource("/lib.dart", "library lib;"); |
| 1596 CompilationUnit compilationUnit = | 1460 CompilationUnit compilationUnit = |
| 1597 _context.resolveCompilationUnit2(source, source); | 1461 _context.resolveCompilationUnit2(source, source); |
| 1598 JUnitTestCase.assertNotNull(compilationUnit); | 1462 expect(compilationUnit, isNotNull); |
| 1599 } | 1463 } |
| 1600 | 1464 |
| 1601 void test_resolveCompilationUnit_sourceChangeDuringResolution() { | 1465 void test_resolveCompilationUnit_sourceChangeDuringResolution() { |
| 1602 _context = new _AnalysisContext_sourceChangeDuringResolution(); | 1466 _context = new _AnalysisContext_sourceChangeDuringResolution(); |
| 1603 AnalysisContextFactory.initContextWithCore(_context); | 1467 AnalysisContextFactory.initContextWithCore(_context); |
| 1604 _sourceFactory = _context.sourceFactory; | 1468 _sourceFactory = _context.sourceFactory; |
| 1605 Source source = _addSource("/lib.dart", "library lib;"); | 1469 Source source = _addSource("/lib.dart", "library lib;"); |
| 1606 CompilationUnit compilationUnit = | 1470 CompilationUnit compilationUnit = |
| 1607 _context.resolveCompilationUnit2(source, source); | 1471 _context.resolveCompilationUnit2(source, source); |
| 1608 JUnitTestCase.assertNotNull(compilationUnit); | 1472 expect(compilationUnit, isNotNull); |
| 1609 JUnitTestCase.assertNotNull(_context.getLineInfo(source)); | 1473 expect(_context.getLineInfo(source), isNotNull); |
| 1610 } | 1474 } |
| 1611 | 1475 |
| 1612 void test_resolveHtmlUnit() { | 1476 void test_resolveHtmlUnit() { |
| 1613 Source source = _addSource("/lib.html", "<html></html>"); | 1477 Source source = _addSource("/lib.html", "<html></html>"); |
| 1614 ht.HtmlUnit unit = _context.resolveHtmlUnit(source); | 1478 ht.HtmlUnit unit = _context.resolveHtmlUnit(source); |
| 1615 JUnitTestCase.assertNotNull(unit); | 1479 expect(unit, isNotNull); |
| 1616 } | 1480 } |
| 1617 | 1481 |
| 1618 void test_setAnalysisOptions() { | 1482 void test_setAnalysisOptions() { |
| 1619 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1483 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 1620 options.cacheSize = 42; | 1484 options.cacheSize = 42; |
| 1621 options.dart2jsHint = false; | 1485 options.dart2jsHint = false; |
| 1622 options.hint = false; | 1486 options.hint = false; |
| 1623 _context.analysisOptions = options; | 1487 _context.analysisOptions = options; |
| 1624 AnalysisOptions result = _context.analysisOptions; | 1488 AnalysisOptions result = _context.analysisOptions; |
| 1625 JUnitTestCase.assertEquals(options.cacheSize, result.cacheSize); | 1489 expect(result.cacheSize, options.cacheSize); |
| 1626 JUnitTestCase.assertEquals(options.dart2jsHint, result.dart2jsHint); | 1490 expect(result.dart2jsHint, options.dart2jsHint); |
| 1627 JUnitTestCase.assertEquals(options.hint, result.hint); | 1491 expect(result.hint, options.hint); |
| 1628 } | 1492 } |
| 1629 | 1493 |
| 1630 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 1494 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
| 1631 AnalysisOptionsImpl options = | 1495 AnalysisOptionsImpl options = |
| 1632 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1496 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1633 List<Source> sources = new List<Source>(); | 1497 List<Source> sources = new List<Source>(); |
| 1634 for (int index = 0; index < options.cacheSize; index++) { | 1498 for (int index = 0; index < options.cacheSize; index++) { |
| 1635 sources.add(_addSource("/lib.dart$index", "")); | 1499 sources.add(_addSource("/lib.dart$index", "")); |
| 1636 } | 1500 } |
| 1637 _context.analysisPriorityOrder = sources; | 1501 _context.analysisPriorityOrder = sources; |
| 1638 int oldPriorityOrderSize = _getPriorityOrder(_context).length; | 1502 int oldPriorityOrderSize = _getPriorityOrder(_context).length; |
| 1639 options.cacheSize = options.cacheSize - 10; | 1503 options.cacheSize = options.cacheSize - 10; |
| 1640 _context.analysisOptions = options; | 1504 _context.analysisOptions = options; |
| 1641 JUnitTestCase.assertTrue( | 1505 expect(oldPriorityOrderSize > _getPriorityOrder(_context).length, isTrue); |
| 1642 oldPriorityOrderSize > _getPriorityOrder(_context).length); | |
| 1643 } | 1506 } |
| 1644 | 1507 |
| 1645 void test_setAnalysisPriorityOrder_empty() { | 1508 void test_setAnalysisPriorityOrder_empty() { |
| 1646 _context.analysisPriorityOrder = new List<Source>(); | 1509 _context.analysisPriorityOrder = new List<Source>(); |
| 1647 } | 1510 } |
| 1648 | 1511 |
| 1649 void test_setAnalysisPriorityOrder_lessThanCacheSize() { | 1512 void test_setAnalysisPriorityOrder_lessThanCacheSize() { |
| 1650 AnalysisOptions options = _context.analysisOptions; | 1513 AnalysisOptions options = _context.analysisOptions; |
| 1651 List<Source> sources = new List<Source>(); | 1514 List<Source> sources = new List<Source>(); |
| 1652 for (int index = 0; index < options.cacheSize; index++) { | 1515 for (int index = 0; index < options.cacheSize; index++) { |
| 1653 sources.add(_addSource("/lib.dart$index", "")); | 1516 sources.add(_addSource("/lib.dart$index", "")); |
| 1654 } | 1517 } |
| 1655 _context.analysisPriorityOrder = sources; | 1518 _context.analysisPriorityOrder = sources; |
| 1656 JUnitTestCase.assertTrue( | 1519 expect(options.cacheSize > _getPriorityOrder(_context).length, isTrue); |
| 1657 options.cacheSize > _getPriorityOrder(_context).length); | |
| 1658 } | 1520 } |
| 1659 | 1521 |
| 1660 void test_setAnalysisPriorityOrder_nonEmpty() { | 1522 void test_setAnalysisPriorityOrder_nonEmpty() { |
| 1661 List<Source> sources = new List<Source>(); | 1523 List<Source> sources = new List<Source>(); |
| 1662 sources.add(_addSource("/lib.dart", "library lib;")); | 1524 sources.add(_addSource("/lib.dart", "library lib;")); |
| 1663 _context.analysisPriorityOrder = sources; | 1525 _context.analysisPriorityOrder = sources; |
| 1664 } | 1526 } |
| 1665 | 1527 |
| 1666 void test_setChangedContents_libraryWithPart() { | 1528 void test_setChangedContents_libraryWithPart() { |
| 1667 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1529 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 1668 options.incremental = true; | 1530 options.incremental = true; |
| 1669 _context = AnalysisContextFactory.contextWithCoreAndOptions(options); | 1531 _context = AnalysisContextFactory.contextWithCoreAndOptions(options); |
| 1670 _sourceFactory = _context.sourceFactory; | 1532 _sourceFactory = _context.sourceFactory; |
| 1671 String oldCode = r''' | 1533 String oldCode = r''' |
| 1672 library lib; | 1534 library lib; |
| 1673 part 'part.dart'; | 1535 part 'part.dart'; |
| 1674 int a = 0;'''; | 1536 int a = 0;'''; |
| 1675 Source librarySource = _addSource("/lib.dart", oldCode); | 1537 Source librarySource = _addSource("/lib.dart", oldCode); |
| 1676 Source partSource = _addSource( | 1538 Source partSource = _addSource( |
| 1677 "/part.dart", | 1539 "/part.dart", |
| 1678 r''' | 1540 r''' |
| 1679 part of lib; | 1541 part of lib; |
| 1680 int b = a;'''); | 1542 int b = a;'''); |
| 1681 LibraryElement element = _context.computeLibraryElement(librarySource); | 1543 LibraryElement element = _context.computeLibraryElement(librarySource); |
| 1682 CompilationUnit unit = | 1544 CompilationUnit unit = |
| 1683 _context.getResolvedCompilationUnit(librarySource, element); | 1545 _context.getResolvedCompilationUnit(librarySource, element); |
| 1684 JUnitTestCase.assertNotNull(unit); | 1546 expect(unit, isNotNull); |
| 1685 int offset = oldCode.indexOf("int a") + 4; | 1547 int offset = oldCode.indexOf("int a") + 4; |
| 1686 String newCode = r''' | 1548 String newCode = r''' |
| 1687 library lib; | 1549 library lib; |
| 1688 part 'part.dart'; | 1550 part 'part.dart'; |
| 1689 int ya = 0;'''; | 1551 int ya = 0;'''; |
| 1690 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | 1552 expect(_getIncrementalAnalysisCache(_context), isNull); |
| 1691 _context.setChangedContents(librarySource, newCode, offset, 0, 1); | 1553 _context.setChangedContents(librarySource, newCode, offset, 0, 1); |
| 1692 JUnitTestCase.assertEquals( | 1554 expect(_context.getContents(librarySource).data, newCode); |
| 1693 newCode, | |
| 1694 _context.getContents(librarySource).data); | |
| 1695 IncrementalAnalysisCache incrementalCache = | 1555 IncrementalAnalysisCache incrementalCache = |
| 1696 _getIncrementalAnalysisCache(_context); | 1556 _getIncrementalAnalysisCache(_context); |
| 1697 JUnitTestCase.assertEquals(librarySource, incrementalCache.librarySource); | 1557 expect(incrementalCache.librarySource, librarySource); |
| 1698 JUnitTestCase.assertSame(unit, incrementalCache.resolvedUnit); | 1558 expect(incrementalCache.resolvedUnit, same(unit)); |
| 1699 JUnitTestCase.assertNull( | 1559 expect(_context.getResolvedCompilationUnit2(partSource, librarySource), isNu
ll); |
| 1700 _context.getResolvedCompilationUnit2(partSource, librarySource)); | 1560 expect(incrementalCache.newContents, newCode); |
| 1701 JUnitTestCase.assertEquals(newCode, incrementalCache.newContents); | |
| 1702 } | 1561 } |
| 1703 | 1562 |
| 1704 void test_setChangedContents_notResolved() { | 1563 void test_setChangedContents_notResolved() { |
| 1705 _context = AnalysisContextFactory.contextWithCore(); | 1564 _context = AnalysisContextFactory.contextWithCore(); |
| 1706 AnalysisOptionsImpl options = | 1565 AnalysisOptionsImpl options = |
| 1707 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1566 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1708 options.incremental = true; | 1567 options.incremental = true; |
| 1709 _context.analysisOptions = options; | 1568 _context.analysisOptions = options; |
| 1710 _sourceFactory = _context.sourceFactory; | 1569 _sourceFactory = _context.sourceFactory; |
| 1711 String oldCode = | 1570 String oldCode = |
| 1712 r''' | 1571 r''' |
| 1713 library lib; | 1572 library lib; |
| 1714 int a = 0;'''; | 1573 int a = 0;'''; |
| 1715 Source librarySource = _addSource("/lib.dart", oldCode); | 1574 Source librarySource = _addSource("/lib.dart", oldCode); |
| 1716 int offset = oldCode.indexOf("int a") + 4; | 1575 int offset = oldCode.indexOf("int a") + 4; |
| 1717 String newCode = | 1576 String newCode = |
| 1718 r''' | 1577 r''' |
| 1719 library lib; | 1578 library lib; |
| 1720 int ya = 0;'''; | 1579 int ya = 0;'''; |
| 1721 _context.setChangedContents(librarySource, newCode, offset, 0, 1); | 1580 _context.setChangedContents(librarySource, newCode, offset, 0, 1); |
| 1722 JUnitTestCase.assertEquals( | 1581 expect(_context.getContents(librarySource).data, newCode); |
| 1723 newCode, | 1582 expect(_getIncrementalAnalysisCache(_context), isNull); |
| 1724 _context.getContents(librarySource).data); | |
| 1725 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | |
| 1726 } | 1583 } |
| 1727 | 1584 |
| 1728 void test_setContents_libraryWithPart() { | 1585 void test_setContents_libraryWithPart() { |
| 1729 _context = AnalysisContextFactory.contextWithCore(); | 1586 _context = AnalysisContextFactory.contextWithCore(); |
| 1730 _sourceFactory = _context.sourceFactory; | 1587 _sourceFactory = _context.sourceFactory; |
| 1731 Source librarySource = _addSource( | 1588 Source librarySource = _addSource( |
| 1732 "/lib.dart", | 1589 "/lib.dart", |
| 1733 r''' | 1590 r''' |
| 1734 library lib; | 1591 library lib; |
| 1735 part 'part.dart'; | 1592 part 'part.dart'; |
| 1736 int a = 0;'''); | 1593 int a = 0;'''); |
| 1737 Source partSource = _addSource( | 1594 Source partSource = _addSource( |
| 1738 "/part.dart", | 1595 "/part.dart", |
| 1739 r''' | 1596 r''' |
| 1740 part of lib; | 1597 part of lib; |
| 1741 int b = a;'''); | 1598 int b = a;'''); |
| 1742 _context.computeLibraryElement(librarySource); | 1599 _context.computeLibraryElement(librarySource); |
| 1743 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1600 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
| 1744 librarySource, | 1601 librarySource, |
| 1745 librarySource, | 1602 librarySource, |
| 1746 null, | 1603 null, |
| 1747 null, | 1604 null, |
| 1748 null, | 1605 null, |
| 1749 0, | 1606 0, |
| 1750 0, | 1607 0, |
| 1751 0); | 1608 0); |
| 1752 _setIncrementalAnalysisCache(_context, incrementalCache); | 1609 _setIncrementalAnalysisCache(_context, incrementalCache); |
| 1753 JUnitTestCase.assertSame( | 1610 expect(_getIncrementalAnalysisCache(_context), same(incrementalCache)); |
| 1754 incrementalCache, | |
| 1755 _getIncrementalAnalysisCache(_context)); | |
| 1756 _context.setContents( | 1611 _context.setContents( |
| 1757 librarySource, | 1612 librarySource, |
| 1758 r''' | 1613 r''' |
| 1759 library lib; | 1614 library lib; |
| 1760 part 'part.dart'; | 1615 part 'part.dart'; |
| 1761 int aa = 0;'''); | 1616 int aa = 0;'''); |
| 1762 JUnitTestCase.assertNull( | 1617 expect(_context.getResolvedCompilationUnit2(partSource, librarySource), isNu
ll); |
| 1763 _context.getResolvedCompilationUnit2(partSource, librarySource)); | 1618 expect(_getIncrementalAnalysisCache(_context), isNull); |
| 1764 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | |
| 1765 } | 1619 } |
| 1766 | 1620 |
| 1767 void test_setContents_null() { | 1621 void test_setContents_null() { |
| 1768 _context = AnalysisContextFactory.contextWithCore(); | 1622 _context = AnalysisContextFactory.contextWithCore(); |
| 1769 _sourceFactory = _context.sourceFactory; | 1623 _sourceFactory = _context.sourceFactory; |
| 1770 Source librarySource = _addSource( | 1624 Source librarySource = _addSource( |
| 1771 "/lib.dart", | 1625 "/lib.dart", |
| 1772 r''' | 1626 r''' |
| 1773 library lib; | 1627 library lib; |
| 1774 int a = 0;'''); | 1628 int a = 0;'''); |
| 1775 _context.computeLibraryElement(librarySource); | 1629 _context.computeLibraryElement(librarySource); |
| 1776 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1630 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
| 1777 librarySource, | 1631 librarySource, |
| 1778 librarySource, | 1632 librarySource, |
| 1779 null, | 1633 null, |
| 1780 null, | 1634 null, |
| 1781 null, | 1635 null, |
| 1782 0, | 1636 0, |
| 1783 0, | 1637 0, |
| 1784 0); | 1638 0); |
| 1785 _setIncrementalAnalysisCache(_context, incrementalCache); | 1639 _setIncrementalAnalysisCache(_context, incrementalCache); |
| 1786 JUnitTestCase.assertSame( | 1640 expect(_getIncrementalAnalysisCache(_context), same(incrementalCache)); |
| 1787 incrementalCache, | |
| 1788 _getIncrementalAnalysisCache(_context)); | |
| 1789 _context.setContents(librarySource, null); | 1641 _context.setContents(librarySource, null); |
| 1790 JUnitTestCase.assertNull( | 1642 expect(_context.getResolvedCompilationUnit2(librarySource, librarySource), i
sNull); |
| 1791 _context.getResolvedCompilationUnit2(librarySource, librarySource)); | 1643 expect(_getIncrementalAnalysisCache(_context), isNull); |
| 1792 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | |
| 1793 } | 1644 } |
| 1794 | 1645 |
| 1795 void test_setSourceFactory() { | 1646 void test_setSourceFactory() { |
| 1796 JUnitTestCase.assertEquals(_sourceFactory, _context.sourceFactory); | 1647 expect(_context.sourceFactory, _sourceFactory); |
| 1797 SourceFactory factory = new SourceFactory([]); | 1648 SourceFactory factory = new SourceFactory([]); |
| 1798 _context.sourceFactory = factory; | 1649 _context.sourceFactory = factory; |
| 1799 JUnitTestCase.assertEquals(factory, _context.sourceFactory); | 1650 expect(_context.sourceFactory, factory); |
| 1800 } | 1651 } |
| 1801 | 1652 |
| 1802 void test_unreadableSource() { | 1653 void test_unreadableSource() { |
| 1803 _context = AnalysisContextFactory.contextWithCore(); | 1654 _context = AnalysisContextFactory.contextWithCore(); |
| 1804 _sourceFactory = _context.sourceFactory; | 1655 _sourceFactory = _context.sourceFactory; |
| 1805 Source test1 = _addSource( | 1656 Source test1 = _addSource( |
| 1806 "/test1.dart", | 1657 "/test1.dart", |
| 1807 r''' | 1658 r''' |
| 1808 import 'test2.dart'; | 1659 import 'test2.dart'; |
| 1809 library test1;'''); | 1660 library test1;'''); |
| 1810 Source test2 = _addSource( | 1661 Source test2 = _addSource( |
| 1811 "/test2.dart", | 1662 "/test2.dart", |
| 1812 r''' | 1663 r''' |
| 1813 import 'test1.dart'; | 1664 import 'test1.dart'; |
| 1814 import 'test3.dart'; | 1665 import 'test3.dart'; |
| 1815 library test2;'''); | 1666 library test2;'''); |
| 1816 Source test3 = _addSourceWithException("/test3.dart"); | 1667 Source test3 = _addSourceWithException("/test3.dart"); |
| 1817 _analyzeAll_assertFinished(); | 1668 _analyzeAll_assertFinished(); |
| 1818 // test1 and test2 should have been successfully analyzed | 1669 // test1 and test2 should have been successfully analyzed |
| 1819 // despite the fact that test3 couldn't be read. | 1670 // despite the fact that test3 couldn't be read. |
| 1820 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test1)); | 1671 expect(_context.computeLibraryElement(test1), isNotNull); |
| 1821 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test2)); | 1672 expect(_context.computeLibraryElement(test2), isNotNull); |
| 1822 JUnitTestCase.assertNull(_context.computeLibraryElement(test3)); | 1673 expect(_context.computeLibraryElement(test3), isNull); |
| 1823 } | 1674 } |
| 1824 | 1675 |
| 1825 void test_updateAnalysis() { | 1676 void test_updateAnalysis() { |
| 1826 JUnitTestCase.assertTrue(_context.sourcesNeedingProcessing.isEmpty); | 1677 expect(_context.sourcesNeedingProcessing.isEmpty, isTrue); |
| 1827 Source source = | 1678 Source source = |
| 1828 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 1679 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 1829 AnalysisDelta delta = new AnalysisDelta(); | 1680 AnalysisDelta delta = new AnalysisDelta(); |
| 1830 delta.setAnalysisLevel(source, AnalysisLevel.ALL); | 1681 delta.setAnalysisLevel(source, AnalysisLevel.ALL); |
| 1831 _context.applyAnalysisDelta(delta); | 1682 _context.applyAnalysisDelta(delta); |
| 1832 JUnitTestCase.assertTrue( | 1683 expect(_context.sourcesNeedingProcessing.contains(source), isTrue); |
| 1833 _context.sourcesNeedingProcessing.contains(source)); | |
| 1834 delta = new AnalysisDelta(); | 1684 delta = new AnalysisDelta(); |
| 1835 delta.setAnalysisLevel(source, AnalysisLevel.NONE); | 1685 delta.setAnalysisLevel(source, AnalysisLevel.NONE); |
| 1836 _context.applyAnalysisDelta(delta); | 1686 _context.applyAnalysisDelta(delta); |
| 1837 JUnitTestCase.assertFalse( | 1687 expect(_context.sourcesNeedingProcessing.contains(source), isFalse); |
| 1838 _context.sourcesNeedingProcessing.contains(source)); | |
| 1839 } | 1688 } |
| 1840 | 1689 |
| 1841 void xtest_performAnalysisTask_stress() { | 1690 void xtest_performAnalysisTask_stress() { |
| 1842 int maxCacheSize = 4; | 1691 int maxCacheSize = 4; |
| 1843 AnalysisOptionsImpl options = | 1692 AnalysisOptionsImpl options = |
| 1844 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1693 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1845 options.cacheSize = maxCacheSize; | 1694 options.cacheSize = maxCacheSize; |
| 1846 _context.analysisOptions = options; | 1695 _context.analysisOptions = options; |
| 1847 int sourceCount = maxCacheSize + 2; | 1696 int sourceCount = maxCacheSize + 2; |
| 1848 List<Source> sources = new List<Source>(); | 1697 List<Source> sources = new List<Source>(); |
| 1849 ChangeSet changeSet = new ChangeSet(); | 1698 ChangeSet changeSet = new ChangeSet(); |
| 1850 for (int i = 0; i < sourceCount; i++) { | 1699 for (int i = 0; i < sourceCount; i++) { |
| 1851 Source source = _addSource("/lib$i.dart", "library lib$i;"); | 1700 Source source = _addSource("/lib$i.dart", "library lib$i;"); |
| 1852 sources.add(source); | 1701 sources.add(source); |
| 1853 changeSet.addedSource(source); | 1702 changeSet.addedSource(source); |
| 1854 } | 1703 } |
| 1855 _context.applyChanges(changeSet); | 1704 _context.applyChanges(changeSet); |
| 1856 _context.analysisPriorityOrder = sources; | 1705 _context.analysisPriorityOrder = sources; |
| 1857 for (int i = 0; i < 1000; i++) { | 1706 for (int i = 0; i < 1000; i++) { |
| 1858 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 1707 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 1859 if (notice == null) { | 1708 if (notice == null) { |
| 1860 //System.out.println("test_performAnalysisTask_stress: " + i); | 1709 //System.out.println("test_performAnalysisTask_stress: " + i); |
| 1861 break; | 1710 break; |
| 1862 } | 1711 } |
| 1863 } | 1712 } |
| 1864 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 1713 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 1865 if (notice != null) { | 1714 if (notice != null) { |
| 1866 JUnitTestCase.fail( | 1715 fail("performAnalysisTask failed to terminate after analyzing all sources"
); |
| 1867 "performAnalysisTask failed to terminate after analyzing all sources")
; | |
| 1868 } | 1716 } |
| 1869 } | 1717 } |
| 1870 | 1718 |
| 1871 Source _addSource(String fileName, String contents) { | 1719 Source _addSource(String fileName, String contents) { |
| 1872 Source source = | 1720 Source source = |
| 1873 new FileBasedSource.con1(FileUtilities2.createFile(fileName)); | 1721 new FileBasedSource.con1(FileUtilities2.createFile(fileName)); |
| 1874 ChangeSet changeSet = new ChangeSet(); | 1722 ChangeSet changeSet = new ChangeSet(); |
| 1875 changeSet.addedSource(source); | 1723 changeSet.addedSource(source); |
| 1876 _context.applyChanges(changeSet); | 1724 _context.applyChanges(changeSet); |
| 1877 _context.setContents(source, contents); | 1725 _context.setContents(source, contents); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1903 * | 1751 * |
| 1904 * @param maxIterations the maximum number of tasks to perform | 1752 * @param maxIterations the maximum number of tasks to perform |
| 1905 */ | 1753 */ |
| 1906 void _analyzeAll_assertFinished2(int maxIterations) { | 1754 void _analyzeAll_assertFinished2(int maxIterations) { |
| 1907 for (int i = 0; i < maxIterations; i++) { | 1755 for (int i = 0; i < maxIterations; i++) { |
| 1908 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 1756 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 1909 if (notice == null) { | 1757 if (notice == null) { |
| 1910 return; | 1758 return; |
| 1911 } | 1759 } |
| 1912 } | 1760 } |
| 1913 JUnitTestCase.fail( | 1761 fail("performAnalysisTask failed to terminate after analyzing all sources"); |
| 1914 "performAnalysisTask failed to terminate after analyzing all sources"); | |
| 1915 } | 1762 } |
| 1916 | 1763 |
| 1917 void _changeSource(TestSource source, String contents) { | 1764 void _changeSource(TestSource source, String contents) { |
| 1918 source.setContents(contents); | 1765 source.setContents(contents); |
| 1919 ChangeSet changeSet = new ChangeSet(); | 1766 ChangeSet changeSet = new ChangeSet(); |
| 1920 changeSet.changedSource(source); | 1767 changeSet.changedSource(source); |
| 1921 _context.applyChanges(changeSet); | 1768 _context.applyChanges(changeSet); |
| 1922 } | 1769 } |
| 1923 | 1770 |
| 1924 /** | 1771 /** |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2007 options.analyzeFunctionBodies = booleanValue; | 1854 options.analyzeFunctionBodies = booleanValue; |
| 2008 options.analyzePolymer = booleanValue; | 1855 options.analyzePolymer = booleanValue; |
| 2009 options.cacheSize = i; | 1856 options.cacheSize = i; |
| 2010 options.dart2jsHint = booleanValue; | 1857 options.dart2jsHint = booleanValue; |
| 2011 options.enableDeferredLoading = booleanValue; | 1858 options.enableDeferredLoading = booleanValue; |
| 2012 options.generateSdkErrors = booleanValue; | 1859 options.generateSdkErrors = booleanValue; |
| 2013 options.hint = booleanValue; | 1860 options.hint = booleanValue; |
| 2014 options.incremental = booleanValue; | 1861 options.incremental = booleanValue; |
| 2015 options.preserveComments = booleanValue; | 1862 options.preserveComments = booleanValue; |
| 2016 AnalysisOptionsImpl copy = new AnalysisOptionsImpl.con1(options); | 1863 AnalysisOptionsImpl copy = new AnalysisOptionsImpl.con1(options); |
| 2017 JUnitTestCase.assertEquals(options.analyzeAngular, copy.analyzeAngular); | 1864 expect(copy.analyzeAngular, options.analyzeAngular); |
| 2018 JUnitTestCase.assertEquals( | 1865 expect(copy.analyzeFunctionBodies, options.analyzeFunctionBodies); |
| 2019 options.analyzeFunctionBodies, | 1866 expect(copy.analyzePolymer, options.analyzePolymer); |
| 2020 copy.analyzeFunctionBodies); | 1867 expect(copy.cacheSize, options.cacheSize); |
| 2021 JUnitTestCase.assertEquals(options.analyzePolymer, copy.analyzePolymer); | 1868 expect(copy.dart2jsHint, options.dart2jsHint); |
| 2022 JUnitTestCase.assertEquals(options.cacheSize, copy.cacheSize); | 1869 expect(copy.enableAsync, options.enableAsync); |
| 2023 JUnitTestCase.assertEquals(options.dart2jsHint, copy.dart2jsHint); | 1870 expect(copy.enableDeferredLoading, options.enableDeferredLoading); |
| 2024 JUnitTestCase.assertEquals(options.enableAsync, copy.enableAsync); | 1871 expect(copy.enableEnum, options.enableEnum); |
| 2025 JUnitTestCase.assertEquals( | 1872 expect(copy.generateSdkErrors, options.generateSdkErrors); |
| 2026 options.enableDeferredLoading, | 1873 expect(copy.hint, options.hint); |
| 2027 copy.enableDeferredLoading); | 1874 expect(copy.incremental, options.incremental); |
| 2028 JUnitTestCase.assertEquals(options.enableEnum, copy.enableEnum); | 1875 expect(copy.preserveComments, options.preserveComments); |
| 2029 JUnitTestCase.assertEquals( | |
| 2030 options.generateSdkErrors, | |
| 2031 copy.generateSdkErrors); | |
| 2032 JUnitTestCase.assertEquals(options.hint, copy.hint); | |
| 2033 JUnitTestCase.assertEquals(options.incremental, copy.incremental); | |
| 2034 JUnitTestCase.assertEquals( | |
| 2035 options.preserveComments, | |
| 2036 copy.preserveComments); | |
| 2037 } | 1876 } |
| 2038 } | 1877 } |
| 2039 | 1878 |
| 2040 void test_getAnalyzeAngular() { | 1879 void test_getAnalyzeAngular() { |
| 2041 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1880 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2042 bool value = !options.analyzeAngular; | 1881 bool value = !options.analyzeAngular; |
| 2043 options.analyzeAngular = value; | 1882 options.analyzeAngular = value; |
| 2044 JUnitTestCase.assertEquals(value, options.analyzeAngular); | 1883 expect(options.analyzeAngular, value); |
| 2045 } | 1884 } |
| 2046 | 1885 |
| 2047 void test_getAnalyzeFunctionBodies() { | 1886 void test_getAnalyzeFunctionBodies() { |
| 2048 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1887 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2049 bool value = !options.analyzeFunctionBodies; | 1888 bool value = !options.analyzeFunctionBodies; |
| 2050 options.analyzeFunctionBodies = value; | 1889 options.analyzeFunctionBodies = value; |
| 2051 JUnitTestCase.assertEquals(value, options.analyzeFunctionBodies); | 1890 expect(options.analyzeFunctionBodies, value); |
| 2052 } | 1891 } |
| 2053 | 1892 |
| 2054 void test_getAnalyzePolymer() { | 1893 void test_getAnalyzePolymer() { |
| 2055 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1894 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2056 bool value = !options.analyzePolymer; | 1895 bool value = !options.analyzePolymer; |
| 2057 options.analyzePolymer = value; | 1896 options.analyzePolymer = value; |
| 2058 JUnitTestCase.assertEquals(value, options.analyzePolymer); | 1897 expect(options.analyzePolymer, value); |
| 2059 } | 1898 } |
| 2060 | 1899 |
| 2061 void test_getCacheSize() { | 1900 void test_getCacheSize() { |
| 2062 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1901 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2063 JUnitTestCase.assertEquals( | 1902 expect(options.cacheSize, AnalysisOptionsImpl.DEFAULT_CACHE_SIZE); |
| 2064 AnalysisOptionsImpl.DEFAULT_CACHE_SIZE, | |
| 2065 options.cacheSize); | |
| 2066 int value = options.cacheSize + 1; | 1903 int value = options.cacheSize + 1; |
| 2067 options.cacheSize = value; | 1904 options.cacheSize = value; |
| 2068 JUnitTestCase.assertEquals(value, options.cacheSize); | 1905 expect(options.cacheSize, value); |
| 2069 } | 1906 } |
| 2070 | 1907 |
| 2071 void test_getDart2jsHint() { | 1908 void test_getDart2jsHint() { |
| 2072 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1909 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2073 bool value = !options.dart2jsHint; | 1910 bool value = !options.dart2jsHint; |
| 2074 options.dart2jsHint = value; | 1911 options.dart2jsHint = value; |
| 2075 JUnitTestCase.assertEquals(value, options.dart2jsHint); | 1912 expect(options.dart2jsHint, value); |
| 2076 } | 1913 } |
| 2077 | 1914 |
| 2078 void test_getEnableAsync() { | 1915 void test_getEnableAsync() { |
| 2079 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1916 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2080 JUnitTestCase.assertEquals( | 1917 expect(options.enableAsync, AnalysisOptionsImpl.DEFAULT_ENABLE_ASYNC); |
| 2081 AnalysisOptionsImpl.DEFAULT_ENABLE_ASYNC, | |
| 2082 options.enableAsync); | |
| 2083 bool value = !options.enableAsync; | 1918 bool value = !options.enableAsync; |
| 2084 options.enableAsync = value; | 1919 options.enableAsync = value; |
| 2085 JUnitTestCase.assertEquals(value, options.enableAsync); | 1920 expect(options.enableAsync, value); |
| 2086 } | 1921 } |
| 2087 | 1922 |
| 2088 void test_getEnableDeferredLoading() { | 1923 void test_getEnableDeferredLoading() { |
| 2089 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1924 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2090 JUnitTestCase.assertEquals( | 1925 expect(options.enableDeferredLoading, AnalysisOptionsImpl.DEFAULT_ENABLE_DEF
ERRED_LOADING); |
| 2091 AnalysisOptionsImpl.DEFAULT_ENABLE_DEFERRED_LOADING, | |
| 2092 options.enableDeferredLoading); | |
| 2093 bool value = !options.enableDeferredLoading; | 1926 bool value = !options.enableDeferredLoading; |
| 2094 options.enableDeferredLoading = value; | 1927 options.enableDeferredLoading = value; |
| 2095 JUnitTestCase.assertEquals(value, options.enableDeferredLoading); | 1928 expect(options.enableDeferredLoading, value); |
| 2096 } | 1929 } |
| 2097 | 1930 |
| 2098 void test_getEnableEnum() { | 1931 void test_getEnableEnum() { |
| 2099 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1932 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2100 JUnitTestCase.assertEquals( | 1933 expect(options.enableEnum, AnalysisOptionsImpl.DEFAULT_ENABLE_ENUM); |
| 2101 AnalysisOptionsImpl.DEFAULT_ENABLE_ENUM, | |
| 2102 options.enableEnum); | |
| 2103 bool value = !options.enableEnum; | 1934 bool value = !options.enableEnum; |
| 2104 options.enableEnum = value; | 1935 options.enableEnum = value; |
| 2105 JUnitTestCase.assertEquals(value, options.enableEnum); | 1936 expect(options.enableEnum, value); |
| 2106 } | 1937 } |
| 2107 | 1938 |
| 2108 void test_getGenerateSdkErrors() { | 1939 void test_getGenerateSdkErrors() { |
| 2109 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1940 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2110 bool value = !options.generateSdkErrors; | 1941 bool value = !options.generateSdkErrors; |
| 2111 options.generateSdkErrors = value; | 1942 options.generateSdkErrors = value; |
| 2112 JUnitTestCase.assertEquals(value, options.generateSdkErrors); | 1943 expect(options.generateSdkErrors, value); |
| 2113 } | 1944 } |
| 2114 | 1945 |
| 2115 void test_getHint() { | 1946 void test_getHint() { |
| 2116 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1947 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2117 bool value = !options.hint; | 1948 bool value = !options.hint; |
| 2118 options.hint = value; | 1949 options.hint = value; |
| 2119 JUnitTestCase.assertEquals(value, options.hint); | 1950 expect(options.hint, value); |
| 2120 } | 1951 } |
| 2121 | 1952 |
| 2122 void test_getIncremental() { | 1953 void test_getIncremental() { |
| 2123 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1954 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2124 bool value = !options.incremental; | 1955 bool value = !options.incremental; |
| 2125 options.incremental = value; | 1956 options.incremental = value; |
| 2126 JUnitTestCase.assertEquals(value, options.incremental); | 1957 expect(options.incremental, value); |
| 2127 } | 1958 } |
| 2128 | 1959 |
| 2129 void test_getPreserveComments() { | 1960 void test_getPreserveComments() { |
| 2130 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1961 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 2131 bool value = !options.preserveComments; | 1962 bool value = !options.preserveComments; |
| 2132 options.preserveComments = value; | 1963 options.preserveComments = value; |
| 2133 JUnitTestCase.assertEquals(value, options.preserveComments); | 1964 expect(options.preserveComments, value); |
| 2134 } | 1965 } |
| 2135 } | 1966 } |
| 2136 | 1967 |
| 2137 | 1968 |
| 2138 class AnalysisTaskTest extends EngineTestCase { | 1969 class AnalysisTaskTest extends EngineTestCase { |
| 2139 void test_perform_exception() { | 1970 void test_perform_exception() { |
| 2140 InternalAnalysisContext context = new AnalysisContextImpl(); | 1971 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 2141 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 1972 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 2142 AnalysisTask task = new AnalysisTask_test_perform_exception(context); | 1973 AnalysisTask task = new AnalysisTask_test_perform_exception(context); |
| 2143 task.perform(new TestTaskVisitor<Object>()); | 1974 task.perform(new TestTaskVisitor<Object>()); |
| 2144 } | 1975 } |
| 2145 } | 1976 } |
| 2146 | 1977 |
| 2147 | 1978 |
| 2148 class AnalysisTask_test_perform_exception extends AnalysisTask { | 1979 class AnalysisTask_test_perform_exception extends AnalysisTask { |
| 2149 AnalysisTask_test_perform_exception(InternalAnalysisContext arg0) | 1980 AnalysisTask_test_perform_exception(InternalAnalysisContext arg0) |
| 2150 : super(arg0); | 1981 : super(arg0); |
| 2151 @override | 1982 @override |
| 2152 String get taskDescription => null; | 1983 String get taskDescription => null; |
| 2153 @override | 1984 @override |
| 2154 accept(AnalysisTaskVisitor visitor) { | 1985 accept(AnalysisTaskVisitor visitor) { |
| 2155 JUnitTestCase.assertNotNull(exception); | 1986 expect(exception, isNotNull); |
| 2156 return null; | 1987 return null; |
| 2157 } | 1988 } |
| 2158 @override | 1989 @override |
| 2159 void internalPerform() { | 1990 void internalPerform() { |
| 2160 throw new AnalysisException("Forced exception"); | 1991 throw new AnalysisException("Forced exception"); |
| 2161 } | 1992 } |
| 2162 } | 1993 } |
| 2163 | 1994 |
| 2164 | 1995 |
| 2165 class CompilationUnitMock extends TypedMock implements CompilationUnit { | 1996 class CompilationUnitMock extends TypedMock implements CompilationUnit { |
| 2166 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 1997 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 2167 } | 1998 } |
| 2168 | 1999 |
| 2169 | 2000 |
| 2170 class DartEntryTest extends EngineTestCase { | 2001 class DartEntryTest extends EngineTestCase { |
| 2171 void set state2(DataDescriptor descriptor) { | 2002 void set state2(DataDescriptor descriptor) { |
| 2172 DartEntry entry = new DartEntry(); | 2003 DartEntry entry = new DartEntry(); |
| 2173 JUnitTestCase.assertNotSame(CacheState.FLUSHED, entry.getState(descriptor)); | 2004 expect(entry.getState(descriptor), isNot(same(CacheState.FLUSHED))); |
| 2174 entry.setState(descriptor, CacheState.FLUSHED); | 2005 entry.setState(descriptor, CacheState.FLUSHED); |
| 2175 JUnitTestCase.assertSame(CacheState.FLUSHED, entry.getState(descriptor)); | 2006 expect(entry.getState(descriptor), same(CacheState.FLUSHED)); |
| 2176 } | 2007 } |
| 2177 | 2008 |
| 2178 void set state3(DataDescriptor descriptor) { | 2009 void set state3(DataDescriptor descriptor) { |
| 2179 Source source = new TestSource(); | 2010 Source source = new TestSource(); |
| 2180 DartEntry entry = new DartEntry(); | 2011 DartEntry entry = new DartEntry(); |
| 2181 JUnitTestCase.assertNotSame( | 2012 expect(entry.getStateInLibrary(descriptor, source), isNot(same(CacheState.FL
USHED))); |
| 2182 CacheState.FLUSHED, | |
| 2183 entry.getStateInLibrary(descriptor, source)); | |
| 2184 entry.setStateInLibrary(descriptor, source, CacheState.FLUSHED); | 2013 entry.setStateInLibrary(descriptor, source, CacheState.FLUSHED); |
| 2185 JUnitTestCase.assertSame( | 2014 expect(entry.getStateInLibrary(descriptor, source), same(CacheState.FLUSHED)
); |
| 2186 CacheState.FLUSHED, | |
| 2187 entry.getStateInLibrary(descriptor, source)); | |
| 2188 } | 2015 } |
| 2189 | 2016 |
| 2190 void test_creation() { | 2017 void test_creation() { |
| 2191 Source librarySource = new TestSource(); | 2018 Source librarySource = new TestSource(); |
| 2192 DartEntry entry = new DartEntry(); | 2019 DartEntry entry = new DartEntry(); |
| 2193 JUnitTestCase.assertSame( | 2020 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2194 CacheState.INVALID, | 2021 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 2195 entry.getState(SourceEntry.CONTENT)); | 2022 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2196 JUnitTestCase.assertSame( | 2023 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2197 CacheState.INVALID, | 2024 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2198 entry.getState(DartEntry.ELEMENT)); | 2025 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2199 JUnitTestCase.assertSame( | 2026 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2200 CacheState.INVALID, | 2027 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2201 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2028 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 2202 JUnitTestCase.assertSame( | 2029 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 2203 CacheState.INVALID, | 2030 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 2204 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2031 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2205 JUnitTestCase.assertSame( | 2032 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 2206 CacheState.INVALID, | 2033 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2207 entry.getState(DartEntry.INCLUDED_PARTS)); | 2034 expect(entry.getStateInLibrary(DartEntry.HINTS, librarySource), same(CacheSt
ate.INVALID)); |
| 2208 JUnitTestCase.assertSame( | 2035 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource),
same(CacheState.INVALID)); |
| 2209 CacheState.INVALID, | 2036 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource), same
(CacheState.INVALID)); |
| 2210 entry.getState(DartEntry.IS_CLIENT)); | 2037 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource)
, same(CacheState.INVALID)); |
| 2211 JUnitTestCase.assertSame( | |
| 2212 CacheState.INVALID, | |
| 2213 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2214 JUnitTestCase.assertSame( | |
| 2215 CacheState.INVALID, | |
| 2216 entry.getState(SourceEntry.LINE_INFO)); | |
| 2217 JUnitTestCase.assertSame( | |
| 2218 CacheState.INVALID, | |
| 2219 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2220 JUnitTestCase.assertSame( | |
| 2221 CacheState.INVALID, | |
| 2222 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2223 JUnitTestCase.assertSame( | |
| 2224 CacheState.INVALID, | |
| 2225 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2226 JUnitTestCase.assertSame( | |
| 2227 CacheState.INVALID, | |
| 2228 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2229 JUnitTestCase.assertSame( | |
| 2230 CacheState.INVALID, | |
| 2231 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2232 JUnitTestCase.assertSame( | |
| 2233 CacheState.INVALID, | |
| 2234 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2235 JUnitTestCase.assertSame( | |
| 2236 CacheState.INVALID, | |
| 2237 entry.getStateInLibrary(DartEntry.HINTS, librarySource)); | |
| 2238 JUnitTestCase.assertSame( | |
| 2239 CacheState.INVALID, | |
| 2240 entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource)); | |
| 2241 JUnitTestCase.assertSame( | |
| 2242 CacheState.INVALID, | |
| 2243 entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource)); | |
| 2244 JUnitTestCase.assertSame( | |
| 2245 CacheState.INVALID, | |
| 2246 entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource)); | |
| 2247 } | 2038 } |
| 2248 | 2039 |
| 2249 void test_getAllErrors() { | 2040 void test_getAllErrors() { |
| 2250 Source source = new TestSource(); | 2041 Source source = new TestSource(); |
| 2251 DartEntry entry = new DartEntry(); | 2042 DartEntry entry = new DartEntry(); |
| 2252 EngineTestCase.assertLength(0, entry.allErrors); | 2043 EngineTestCase.assertLength(0, entry.allErrors); |
| 2253 entry.setValue( | 2044 entry.setValue( |
| 2254 DartEntry.SCAN_ERRORS, | 2045 DartEntry.SCAN_ERRORS, |
| 2255 <AnalysisError>[ | 2046 <AnalysisError>[ |
| 2256 new AnalysisError.con1( | 2047 new AnalysisError.con1( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2279 [])]); | 2070 [])]); |
| 2280 entry.setValueInLibrary( | 2071 entry.setValueInLibrary( |
| 2281 DartEntry.HINTS, | 2072 DartEntry.HINTS, |
| 2282 source, | 2073 source, |
| 2283 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; | 2074 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; |
| 2284 EngineTestCase.assertLength(5, entry.allErrors); | 2075 EngineTestCase.assertLength(5, entry.allErrors); |
| 2285 } | 2076 } |
| 2286 | 2077 |
| 2287 void test_getResolvableCompilationUnit_none() { | 2078 void test_getResolvableCompilationUnit_none() { |
| 2288 DartEntry entry = new DartEntry(); | 2079 DartEntry entry = new DartEntry(); |
| 2289 JUnitTestCase.assertNull(entry.resolvableCompilationUnit); | 2080 expect(entry.resolvableCompilationUnit, isNull); |
| 2290 } | 2081 } |
| 2291 | 2082 |
| 2292 void test_getResolvableCompilationUnit_parsed_accessed() { | 2083 void test_getResolvableCompilationUnit_parsed_accessed() { |
| 2293 Source librarySource = new TestSource("/lib.dart"); | 2084 Source librarySource = new TestSource("/lib.dart"); |
| 2294 String importUri = "/f1.dart"; | 2085 String importUri = "/f1.dart"; |
| 2295 Source importSource = new TestSource(importUri); | 2086 Source importSource = new TestSource(importUri); |
| 2296 ImportDirective importDirective = | 2087 ImportDirective importDirective = |
| 2297 AstFactory.importDirective3(importUri, null, []); | 2088 AstFactory.importDirective3(importUri, null, []); |
| 2298 importDirective.source = importSource; | 2089 importDirective.source = importSource; |
| 2299 importDirective.uriContent = importUri; | 2090 importDirective.uriContent = importUri; |
| 2300 String exportUri = "/f2.dart"; | 2091 String exportUri = "/f2.dart"; |
| 2301 Source exportSource = new TestSource(exportUri); | 2092 Source exportSource = new TestSource(exportUri); |
| 2302 ExportDirective exportDirective = | 2093 ExportDirective exportDirective = |
| 2303 AstFactory.exportDirective2(exportUri, []); | 2094 AstFactory.exportDirective2(exportUri, []); |
| 2304 exportDirective.source = exportSource; | 2095 exportDirective.source = exportSource; |
| 2305 exportDirective.uriContent = exportUri; | 2096 exportDirective.uriContent = exportUri; |
| 2306 String partUri = "/f3.dart"; | 2097 String partUri = "/f3.dart"; |
| 2307 Source partSource = new TestSource(partUri); | 2098 Source partSource = new TestSource(partUri); |
| 2308 PartDirective partDirective = AstFactory.partDirective2(partUri); | 2099 PartDirective partDirective = AstFactory.partDirective2(partUri); |
| 2309 partDirective.source = partSource; | 2100 partDirective.source = partSource; |
| 2310 partDirective.uriContent = partUri; | 2101 partDirective.uriContent = partUri; |
| 2311 CompilationUnit unit = | 2102 CompilationUnit unit = |
| 2312 AstFactory.compilationUnit3([importDirective, exportDirective, partDirec
tive]); | 2103 AstFactory.compilationUnit3([importDirective, exportDirective, partDirec
tive]); |
| 2313 DartEntry entry = new DartEntry(); | 2104 DartEntry entry = new DartEntry(); |
| 2314 entry.setValue(DartEntry.PARSED_UNIT, unit); | 2105 entry.setValue(DartEntry.PARSED_UNIT, unit); |
| 2315 entry.getValue(DartEntry.PARSED_UNIT); | 2106 entry.getValue(DartEntry.PARSED_UNIT); |
| 2316 CompilationUnit result = entry.resolvableCompilationUnit; | 2107 CompilationUnit result = entry.resolvableCompilationUnit; |
| 2317 JUnitTestCase.assertSame(unit, result); | 2108 expect(result, same(unit)); |
| 2318 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); | 2109 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, librarySource, unit); |
| 2319 result = entry.resolvableCompilationUnit; | 2110 result = entry.resolvableCompilationUnit; |
| 2320 JUnitTestCase.assertNotSame(unit, result); | 2111 expect(result, isNot(same(unit))); |
| 2321 NodeList<Directive> directives = result.directives; | 2112 NodeList<Directive> directives = result.directives; |
| 2322 ImportDirective resultImportDirective = directives[0] as ImportDirective; | 2113 ImportDirective resultImportDirective = directives[0] as ImportDirective; |
| 2323 JUnitTestCase.assertEquals(importUri, resultImportDirective.uriContent); | 2114 expect(resultImportDirective.uriContent, importUri); |
| 2324 JUnitTestCase.assertSame(importSource, resultImportDirective.source); | 2115 expect(resultImportDirective.source, same(importSource)); |
| 2325 ExportDirective resultExportDirective = directives[1] as ExportDirective; | 2116 ExportDirective resultExportDirective = directives[1] as ExportDirective; |
| 2326 JUnitTestCase.assertEquals(exportUri, resultExportDirective.uriContent); | 2117 expect(resultExportDirective.uriContent, exportUri); |
| 2327 JUnitTestCase.assertSame(exportSource, resultExportDirective.source); | 2118 expect(resultExportDirective.source, same(exportSource)); |
| 2328 PartDirective resultPartDirective = directives[2] as PartDirective; | 2119 PartDirective resultPartDirective = directives[2] as PartDirective; |
| 2329 JUnitTestCase.assertEquals(partUri, resultPartDirective.uriContent); | 2120 expect(resultPartDirective.uriContent, partUri); |
| 2330 JUnitTestCase.assertSame(partSource, resultPartDirective.source); | 2121 expect(resultPartDirective.source, same(partSource)); |
| 2331 } | 2122 } |
| 2332 | 2123 |
| 2333 void test_getResolvableCompilationUnit_parsed_notAccessed() { | 2124 void test_getResolvableCompilationUnit_parsed_notAccessed() { |
| 2334 CompilationUnit unit = AstFactory.compilationUnit(); | 2125 CompilationUnit unit = AstFactory.compilationUnit(); |
| 2335 DartEntry entry = new DartEntry(); | 2126 DartEntry entry = new DartEntry(); |
| 2336 entry.setValue(DartEntry.PARSED_UNIT, unit); | 2127 entry.setValue(DartEntry.PARSED_UNIT, unit); |
| 2337 JUnitTestCase.assertSame(unit, entry.resolvableCompilationUnit); | 2128 expect(entry.resolvableCompilationUnit, same(unit)); |
| 2338 } | 2129 } |
| 2339 | 2130 |
| 2340 void test_getResolvableCompilationUnit_resolved() { | 2131 void test_getResolvableCompilationUnit_resolved() { |
| 2341 String importUri = "f1.dart"; | 2132 String importUri = "f1.dart"; |
| 2342 Source importSource = new TestSource(importUri); | 2133 Source importSource = new TestSource(importUri); |
| 2343 ImportDirective importDirective = | 2134 ImportDirective importDirective = |
| 2344 AstFactory.importDirective3(importUri, null, []); | 2135 AstFactory.importDirective3(importUri, null, []); |
| 2345 importDirective.source = importSource; | 2136 importDirective.source = importSource; |
| 2346 importDirective.uriContent = importUri; | 2137 importDirective.uriContent = importUri; |
| 2347 String exportUri = "f2.dart"; | 2138 String exportUri = "f2.dart"; |
| 2348 Source exportSource = new TestSource(exportUri); | 2139 Source exportSource = new TestSource(exportUri); |
| 2349 ExportDirective exportDirective = | 2140 ExportDirective exportDirective = |
| 2350 AstFactory.exportDirective2(exportUri, []); | 2141 AstFactory.exportDirective2(exportUri, []); |
| 2351 exportDirective.source = exportSource; | 2142 exportDirective.source = exportSource; |
| 2352 exportDirective.uriContent = exportUri; | 2143 exportDirective.uriContent = exportUri; |
| 2353 String partUri = "f3.dart"; | 2144 String partUri = "f3.dart"; |
| 2354 Source partSource = new TestSource(partUri); | 2145 Source partSource = new TestSource(partUri); |
| 2355 PartDirective partDirective = AstFactory.partDirective2(partUri); | 2146 PartDirective partDirective = AstFactory.partDirective2(partUri); |
| 2356 partDirective.source = partSource; | 2147 partDirective.source = partSource; |
| 2357 partDirective.uriContent = partUri; | 2148 partDirective.uriContent = partUri; |
| 2358 CompilationUnit unit = | 2149 CompilationUnit unit = |
| 2359 AstFactory.compilationUnit3([importDirective, exportDirective, partDirec
tive]); | 2150 AstFactory.compilationUnit3([importDirective, exportDirective, partDirec
tive]); |
| 2360 DartEntry entry = new DartEntry(); | 2151 DartEntry entry = new DartEntry(); |
| 2361 entry.setValueInLibrary( | 2152 entry.setValueInLibrary( |
| 2362 DartEntry.RESOLVED_UNIT, | 2153 DartEntry.RESOLVED_UNIT, |
| 2363 new TestSource("lib.dart"), | 2154 new TestSource("lib.dart"), |
| 2364 unit); | 2155 unit); |
| 2365 CompilationUnit result = entry.resolvableCompilationUnit; | 2156 CompilationUnit result = entry.resolvableCompilationUnit; |
| 2366 JUnitTestCase.assertNotSame(unit, result); | 2157 expect(result, isNot(same(unit))); |
| 2367 NodeList<Directive> directives = result.directives; | 2158 NodeList<Directive> directives = result.directives; |
| 2368 ImportDirective resultImportDirective = directives[0] as ImportDirective; | 2159 ImportDirective resultImportDirective = directives[0] as ImportDirective; |
| 2369 JUnitTestCase.assertEquals(importUri, resultImportDirective.uriContent); | 2160 expect(resultImportDirective.uriContent, importUri); |
| 2370 JUnitTestCase.assertSame(importSource, resultImportDirective.source); | 2161 expect(resultImportDirective.source, same(importSource)); |
| 2371 ExportDirective resultExportDirective = directives[1] as ExportDirective; | 2162 ExportDirective resultExportDirective = directives[1] as ExportDirective; |
| 2372 JUnitTestCase.assertEquals(exportUri, resultExportDirective.uriContent); | 2163 expect(resultExportDirective.uriContent, exportUri); |
| 2373 JUnitTestCase.assertSame(exportSource, resultExportDirective.source); | 2164 expect(resultExportDirective.source, same(exportSource)); |
| 2374 PartDirective resultPartDirective = directives[2] as PartDirective; | 2165 PartDirective resultPartDirective = directives[2] as PartDirective; |
| 2375 JUnitTestCase.assertEquals(partUri, resultPartDirective.uriContent); | 2166 expect(resultPartDirective.uriContent, partUri); |
| 2376 JUnitTestCase.assertSame(partSource, resultPartDirective.source); | 2167 expect(resultPartDirective.source, same(partSource)); |
| 2377 } | 2168 } |
| 2378 | 2169 |
| 2379 void test_getStateInLibrary_invalid_element() { | 2170 void test_getStateInLibrary_invalid_element() { |
| 2380 DartEntry entry = new DartEntry(); | 2171 DartEntry entry = new DartEntry(); |
| 2381 try { | 2172 try { |
| 2382 entry.getStateInLibrary(DartEntry.ELEMENT, new TestSource()); | 2173 entry.getStateInLibrary(DartEntry.ELEMENT, new TestSource()); |
| 2383 JUnitTestCase.fail("Expected IllegalArgumentException for ELEMENT"); | 2174 fail("Expected IllegalArgumentException for ELEMENT"); |
| 2384 } on ArgumentError catch (exception) { | 2175 } on ArgumentError catch (exception) { |
| 2385 // Expected | 2176 // Expected |
| 2386 } | 2177 } |
| 2387 } | 2178 } |
| 2388 | 2179 |
| 2389 void test_getState_invalid_resolutionErrors() { | 2180 void test_getState_invalid_resolutionErrors() { |
| 2390 DartEntry entry = new DartEntry(); | 2181 DartEntry entry = new DartEntry(); |
| 2391 try { | 2182 try { |
| 2392 entry.getState(DartEntry.RESOLUTION_ERRORS); | 2183 entry.getState(DartEntry.RESOLUTION_ERRORS); |
| 2393 JUnitTestCase.fail( | 2184 fail("Expected IllegalArgumentException for RESOLUTION_ERRORS"); |
| 2394 "Expected IllegalArgumentException for RESOLUTION_ERRORS"); | |
| 2395 } on ArgumentError catch (exception) { | 2185 } on ArgumentError catch (exception) { |
| 2396 // Expected | 2186 // Expected |
| 2397 } | 2187 } |
| 2398 } | 2188 } |
| 2399 | 2189 |
| 2400 void test_getState_invalid_verificationErrors() { | 2190 void test_getState_invalid_verificationErrors() { |
| 2401 DartEntry entry = new DartEntry(); | 2191 DartEntry entry = new DartEntry(); |
| 2402 try { | 2192 try { |
| 2403 entry.getState(DartEntry.VERIFICATION_ERRORS); | 2193 entry.getState(DartEntry.VERIFICATION_ERRORS); |
| 2404 JUnitTestCase.fail( | 2194 fail("Expected IllegalArgumentException for VERIFICATION_ERRORS"); |
| 2405 "Expected IllegalArgumentException for VERIFICATION_ERRORS"); | |
| 2406 } on ArgumentError catch (exception) { | 2195 } on ArgumentError catch (exception) { |
| 2407 // Expected | 2196 // Expected |
| 2408 } | 2197 } |
| 2409 } | 2198 } |
| 2410 | 2199 |
| 2411 void test_getValue_containingLibraries() { | 2200 void test_getValue_containingLibraries() { |
| 2412 Source testSource = new TestSource(); | 2201 Source testSource = new TestSource(); |
| 2413 DartEntry entry = new DartEntry(); | 2202 DartEntry entry = new DartEntry(); |
| 2414 List<Source> value = entry.containingLibraries; | 2203 List<Source> value = entry.containingLibraries; |
| 2415 EngineTestCase.assertLength(0, value); | 2204 EngineTestCase.assertLength(0, value); |
| 2416 entry.addContainingLibrary(testSource); | 2205 entry.addContainingLibrary(testSource); |
| 2417 value = entry.containingLibraries; | 2206 value = entry.containingLibraries; |
| 2418 EngineTestCase.assertLength(1, value); | 2207 EngineTestCase.assertLength(1, value); |
| 2419 JUnitTestCase.assertEquals(testSource, value[0]); | 2208 expect(value[0], testSource); |
| 2420 entry.removeContainingLibrary(testSource); | 2209 entry.removeContainingLibrary(testSource); |
| 2421 value = entry.containingLibraries; | 2210 value = entry.containingLibraries; |
| 2422 EngineTestCase.assertLength(0, value); | 2211 EngineTestCase.assertLength(0, value); |
| 2423 } | 2212 } |
| 2424 | 2213 |
| 2425 void test_getValueInLibrary_invalid_element() { | 2214 void test_getValueInLibrary_invalid_element() { |
| 2426 DartEntry entry = new DartEntry(); | 2215 DartEntry entry = new DartEntry(); |
| 2427 try { | 2216 try { |
| 2428 entry.getValueInLibrary(DartEntry.ELEMENT, new TestSource()); | 2217 entry.getValueInLibrary(DartEntry.ELEMENT, new TestSource()); |
| 2429 JUnitTestCase.fail("Expected IllegalArgumentException for ELEMENT"); | 2218 fail("Expected IllegalArgumentException for ELEMENT"); |
| 2430 } on ArgumentError catch (exception) { | 2219 } on ArgumentError catch (exception) { |
| 2431 // Expected | 2220 // Expected |
| 2432 } | 2221 } |
| 2433 } | 2222 } |
| 2434 | 2223 |
| 2435 void test_getValueInLibrary_invalid_resolutionErrors_multiple() { | 2224 void test_getValueInLibrary_invalid_resolutionErrors_multiple() { |
| 2436 Source source1 = new TestSource(); | 2225 Source source1 = new TestSource(); |
| 2437 Source source2 = new TestSource(); | 2226 Source source2 = new TestSource(); |
| 2438 Source source3 = new TestSource(); | 2227 Source source3 = new TestSource(); |
| 2439 DartEntry entry = new DartEntry(); | 2228 DartEntry entry = new DartEntry(); |
| 2440 entry.setValueInLibrary( | 2229 entry.setValueInLibrary( |
| 2441 DartEntry.RESOLVED_UNIT, | 2230 DartEntry.RESOLVED_UNIT, |
| 2442 source1, | 2231 source1, |
| 2443 AstFactory.compilationUnit()); | 2232 AstFactory.compilationUnit()); |
| 2444 entry.setValueInLibrary( | 2233 entry.setValueInLibrary( |
| 2445 DartEntry.RESOLVED_UNIT, | 2234 DartEntry.RESOLVED_UNIT, |
| 2446 source2, | 2235 source2, |
| 2447 AstFactory.compilationUnit()); | 2236 AstFactory.compilationUnit()); |
| 2448 entry.setValueInLibrary( | 2237 entry.setValueInLibrary( |
| 2449 DartEntry.RESOLVED_UNIT, | 2238 DartEntry.RESOLVED_UNIT, |
| 2450 source3, | 2239 source3, |
| 2451 AstFactory.compilationUnit()); | 2240 AstFactory.compilationUnit()); |
| 2452 try { | 2241 try { |
| 2453 entry.getValueInLibrary(DartEntry.ELEMENT, source3); | 2242 entry.getValueInLibrary(DartEntry.ELEMENT, source3); |
| 2454 JUnitTestCase.fail("Expected IllegalArgumentException for ELEMENT"); | 2243 fail("Expected IllegalArgumentException for ELEMENT"); |
| 2455 } on ArgumentError catch (exception) { | 2244 } on ArgumentError catch (exception) { |
| 2456 // Expected | 2245 // Expected |
| 2457 } | 2246 } |
| 2458 } | 2247 } |
| 2459 | 2248 |
| 2460 void test_getValue_invalid_resolutionErrors() { | 2249 void test_getValue_invalid_resolutionErrors() { |
| 2461 DartEntry entry = new DartEntry(); | 2250 DartEntry entry = new DartEntry(); |
| 2462 try { | 2251 try { |
| 2463 entry.getValue(DartEntry.RESOLUTION_ERRORS); | 2252 entry.getValue(DartEntry.RESOLUTION_ERRORS); |
| 2464 JUnitTestCase.fail( | 2253 fail("Expected IllegalArgumentException for RESOLUTION_ERRORS"); |
| 2465 "Expected IllegalArgumentException for RESOLUTION_ERRORS"); | |
| 2466 } on ArgumentError catch (exception) { | 2254 } on ArgumentError catch (exception) { |
| 2467 } | 2255 } |
| 2468 } | 2256 } |
| 2469 | 2257 |
| 2470 void test_getValue_invalid_verificationErrors() { | 2258 void test_getValue_invalid_verificationErrors() { |
| 2471 DartEntry entry = new DartEntry(); | 2259 DartEntry entry = new DartEntry(); |
| 2472 try { | 2260 try { |
| 2473 entry.getValue(DartEntry.VERIFICATION_ERRORS); | 2261 entry.getValue(DartEntry.VERIFICATION_ERRORS); |
| 2474 JUnitTestCase.fail( | 2262 fail("Expected IllegalArgumentException for VERIFICATION_ERRORS"); |
| 2475 "Expected IllegalArgumentException for VERIFICATION_ERRORS"); | |
| 2476 } on ArgumentError catch (exception) { | 2263 } on ArgumentError catch (exception) { |
| 2477 // Expected | 2264 // Expected |
| 2478 } | 2265 } |
| 2479 } | 2266 } |
| 2480 | 2267 |
| 2481 void test_hasInvalidData_false() { | 2268 void test_hasInvalidData_false() { |
| 2482 DartEntry entry = new DartEntry(); | 2269 DartEntry entry = new DartEntry(); |
| 2483 entry.recordScanError(new CaughtException(new AnalysisException(), null)); | 2270 entry.recordScanError(new CaughtException(new AnalysisException(), null)); |
| 2484 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.ELEMENT)); | 2271 expect(entry.hasInvalidData(DartEntry.ELEMENT), isFalse); |
| 2485 JUnitTestCase.assertFalse( | 2272 expect(entry.hasInvalidData(DartEntry.EXPORTED_LIBRARIES), isFalse); |
| 2486 entry.hasInvalidData(DartEntry.EXPORTED_LIBRARIES)); | 2273 expect(entry.hasInvalidData(DartEntry.HINTS), isFalse); |
| 2487 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.HINTS)); | 2274 expect(entry.hasInvalidData(DartEntry.IMPORTED_LIBRARIES), isFalse); |
| 2488 JUnitTestCase.assertFalse( | 2275 expect(entry.hasInvalidData(DartEntry.INCLUDED_PARTS), isFalse); |
| 2489 entry.hasInvalidData(DartEntry.IMPORTED_LIBRARIES)); | 2276 expect(entry.hasInvalidData(DartEntry.IS_CLIENT), isFalse); |
| 2490 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.INCLUDED_PARTS)); | 2277 expect(entry.hasInvalidData(DartEntry.IS_LAUNCHABLE), isFalse); |
| 2491 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.IS_CLIENT)); | 2278 expect(entry.hasInvalidData(SourceEntry.LINE_INFO), isFalse); |
| 2492 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.IS_LAUNCHABLE)); | 2279 expect(entry.hasInvalidData(DartEntry.PARSE_ERRORS), isFalse); |
| 2493 JUnitTestCase.assertFalse(entry.hasInvalidData(SourceEntry.LINE_INFO)); | 2280 expect(entry.hasInvalidData(DartEntry.PARSED_UNIT), isFalse); |
| 2494 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.PARSE_ERRORS)); | 2281 expect(entry.hasInvalidData(DartEntry.PUBLIC_NAMESPACE), isFalse); |
| 2495 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.PARSED_UNIT)); | 2282 expect(entry.hasInvalidData(DartEntry.SOURCE_KIND), isFalse); |
| 2496 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.PUBLIC_NAMESPACE)); | 2283 expect(entry.hasInvalidData(DartEntry.RESOLUTION_ERRORS), isFalse); |
| 2497 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.SOURCE_KIND)); | 2284 expect(entry.hasInvalidData(DartEntry.RESOLVED_UNIT), isFalse); |
| 2498 JUnitTestCase.assertFalse( | 2285 expect(entry.hasInvalidData(DartEntry.VERIFICATION_ERRORS), isFalse); |
| 2499 entry.hasInvalidData(DartEntry.RESOLUTION_ERRORS)); | |
| 2500 JUnitTestCase.assertFalse(entry.hasInvalidData(DartEntry.RESOLVED_UNIT)); | |
| 2501 JUnitTestCase.assertFalse( | |
| 2502 entry.hasInvalidData(DartEntry.VERIFICATION_ERRORS)); | |
| 2503 } | 2286 } |
| 2504 | 2287 |
| 2505 void test_hasInvalidData_true() { | 2288 void test_hasInvalidData_true() { |
| 2506 DartEntry entry = new DartEntry(); | 2289 DartEntry entry = new DartEntry(); |
| 2507 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.ELEMENT)); | 2290 expect(entry.hasInvalidData(DartEntry.ELEMENT), isTrue); |
| 2508 JUnitTestCase.assertTrue( | 2291 expect(entry.hasInvalidData(DartEntry.EXPORTED_LIBRARIES), isTrue); |
| 2509 entry.hasInvalidData(DartEntry.EXPORTED_LIBRARIES)); | 2292 expect(entry.hasInvalidData(DartEntry.HINTS), isTrue); |
| 2510 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.HINTS)); | 2293 expect(entry.hasInvalidData(DartEntry.IMPORTED_LIBRARIES), isTrue); |
| 2511 JUnitTestCase.assertTrue( | 2294 expect(entry.hasInvalidData(DartEntry.INCLUDED_PARTS), isTrue); |
| 2512 entry.hasInvalidData(DartEntry.IMPORTED_LIBRARIES)); | 2295 expect(entry.hasInvalidData(DartEntry.IS_CLIENT), isTrue); |
| 2513 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.INCLUDED_PARTS)); | 2296 expect(entry.hasInvalidData(DartEntry.IS_LAUNCHABLE), isTrue); |
| 2514 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.IS_CLIENT)); | 2297 expect(entry.hasInvalidData(SourceEntry.LINE_INFO), isTrue); |
| 2515 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.IS_LAUNCHABLE)); | 2298 expect(entry.hasInvalidData(DartEntry.PARSE_ERRORS), isTrue); |
| 2516 JUnitTestCase.assertTrue(entry.hasInvalidData(SourceEntry.LINE_INFO)); | 2299 expect(entry.hasInvalidData(DartEntry.PARSED_UNIT), isTrue); |
| 2517 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.PARSE_ERRORS)); | 2300 expect(entry.hasInvalidData(DartEntry.PUBLIC_NAMESPACE), isTrue); |
| 2518 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.PARSED_UNIT)); | 2301 expect(entry.hasInvalidData(DartEntry.SOURCE_KIND), isTrue); |
| 2519 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.PUBLIC_NAMESPACE)); | 2302 expect(entry.hasInvalidData(DartEntry.RESOLUTION_ERRORS), isTrue); |
| 2520 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.SOURCE_KIND)); | 2303 expect(entry.hasInvalidData(DartEntry.RESOLVED_UNIT), isTrue); |
| 2521 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.RESOLUTION_ERRORS)); | 2304 expect(entry.hasInvalidData(DartEntry.VERIFICATION_ERRORS), isTrue); |
| 2522 JUnitTestCase.assertTrue(entry.hasInvalidData(DartEntry.RESOLVED_UNIT)); | |
| 2523 JUnitTestCase.assertTrue( | |
| 2524 entry.hasInvalidData(DartEntry.VERIFICATION_ERRORS)); | |
| 2525 } | 2305 } |
| 2526 | 2306 |
| 2527 void test_invalidateAllInformation() { | 2307 void test_invalidateAllInformation() { |
| 2528 DartEntry entry = _entryWithValidState(); | 2308 DartEntry entry = _entryWithValidState(); |
| 2529 entry.invalidateAllInformation(); | 2309 entry.invalidateAllInformation(); |
| 2530 JUnitTestCase.assertSame( | 2310 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 2531 CacheState.INVALID, | 2311 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2532 entry.getState(DartEntry.ELEMENT)); | 2312 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2533 JUnitTestCase.assertSame( | 2313 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2534 CacheState.INVALID, | 2314 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2535 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2315 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2536 JUnitTestCase.assertSame( | 2316 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2537 CacheState.INVALID, | 2317 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 2538 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2318 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 2539 JUnitTestCase.assertSame( | 2319 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 2540 CacheState.INVALID, | 2320 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2541 entry.getState(DartEntry.INCLUDED_PARTS)); | 2321 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2542 JUnitTestCase.assertSame( | |
| 2543 CacheState.INVALID, | |
| 2544 entry.getState(DartEntry.IS_CLIENT)); | |
| 2545 JUnitTestCase.assertSame( | |
| 2546 CacheState.INVALID, | |
| 2547 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2548 JUnitTestCase.assertSame( | |
| 2549 CacheState.INVALID, | |
| 2550 entry.getState(SourceEntry.LINE_INFO)); | |
| 2551 JUnitTestCase.assertSame( | |
| 2552 CacheState.INVALID, | |
| 2553 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2554 JUnitTestCase.assertSame( | |
| 2555 CacheState.INVALID, | |
| 2556 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2557 JUnitTestCase.assertSame( | |
| 2558 CacheState.INVALID, | |
| 2559 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2560 JUnitTestCase.assertSame( | |
| 2561 CacheState.INVALID, | |
| 2562 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2563 JUnitTestCase.assertSame( | |
| 2564 CacheState.INVALID, | |
| 2565 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2566 } | 2322 } |
| 2567 | 2323 |
| 2568 void test_invalidateAllResolutionInformation() { | 2324 void test_invalidateAllResolutionInformation() { |
| 2569 DartEntry entry = _entryWithValidState(); | 2325 DartEntry entry = _entryWithValidState(); |
| 2570 entry.invalidateAllResolutionInformation(false); | 2326 entry.invalidateAllResolutionInformation(false); |
| 2571 JUnitTestCase.assertSame( | 2327 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 2572 CacheState.INVALID, | 2328 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2573 entry.getState(DartEntry.ELEMENT)); | 2329 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2574 JUnitTestCase.assertSame( | 2330 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 2575 CacheState.INVALID, | 2331 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 2576 entry.getState(DartEntry.IS_CLIENT)); | 2332 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 2577 JUnitTestCase.assertSame( | 2333 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 2578 CacheState.INVALID, | 2334 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.VALID))
; |
| 2579 entry.getState(DartEntry.IS_LAUNCHABLE)); | 2335 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.VALID))
; |
| 2580 JUnitTestCase.assertSame( | 2336 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.VALID)); |
| 2581 CacheState.VALID, | |
| 2582 entry.getState(SourceEntry.LINE_INFO)); | |
| 2583 JUnitTestCase.assertSame( | |
| 2584 CacheState.VALID, | |
| 2585 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2586 JUnitTestCase.assertSame( | |
| 2587 CacheState.VALID, | |
| 2588 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2589 JUnitTestCase.assertSame( | |
| 2590 CacheState.INVALID, | |
| 2591 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2592 JUnitTestCase.assertSame( | |
| 2593 CacheState.VALID, | |
| 2594 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | |
| 2595 JUnitTestCase.assertSame( | |
| 2596 CacheState.VALID, | |
| 2597 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | |
| 2598 JUnitTestCase.assertSame( | |
| 2599 CacheState.VALID, | |
| 2600 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2601 } | 2337 } |
| 2602 | 2338 |
| 2603 void test_invalidateAllResolutionInformation_includingUris() { | 2339 void test_invalidateAllResolutionInformation_includingUris() { |
| 2604 DartEntry entry = _entryWithValidState(); | 2340 DartEntry entry = _entryWithValidState(); |
| 2605 entry.invalidateAllResolutionInformation(true); | 2341 entry.invalidateAllResolutionInformation(true); |
| 2606 JUnitTestCase.assertSame( | 2342 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 2607 CacheState.INVALID, | 2343 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2608 entry.getState(DartEntry.ELEMENT)); | 2344 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2609 JUnitTestCase.assertSame( | 2345 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 2610 CacheState.INVALID, | 2346 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 2611 entry.getState(DartEntry.IS_CLIENT)); | 2347 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 2612 JUnitTestCase.assertSame( | 2348 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 2613 CacheState.INVALID, | 2349 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2614 entry.getState(DartEntry.IS_LAUNCHABLE)); | 2350 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2615 JUnitTestCase.assertSame( | 2351 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2616 CacheState.VALID, | |
| 2617 entry.getState(SourceEntry.LINE_INFO)); | |
| 2618 JUnitTestCase.assertSame( | |
| 2619 CacheState.VALID, | |
| 2620 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2621 JUnitTestCase.assertSame( | |
| 2622 CacheState.VALID, | |
| 2623 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2624 JUnitTestCase.assertSame( | |
| 2625 CacheState.INVALID, | |
| 2626 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2627 JUnitTestCase.assertSame( | |
| 2628 CacheState.INVALID, | |
| 2629 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | |
| 2630 JUnitTestCase.assertSame( | |
| 2631 CacheState.INVALID, | |
| 2632 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | |
| 2633 JUnitTestCase.assertSame( | |
| 2634 CacheState.INVALID, | |
| 2635 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2636 } | 2352 } |
| 2637 | 2353 |
| 2638 void test_isClient() { | 2354 void test_isClient() { |
| 2639 DartEntry entry = new DartEntry(); | 2355 DartEntry entry = new DartEntry(); |
| 2640 // true | 2356 // true |
| 2641 entry.setValue(DartEntry.IS_CLIENT, true); | 2357 entry.setValue(DartEntry.IS_CLIENT, true); |
| 2642 JUnitTestCase.assertTrue(entry.getValue(DartEntry.IS_CLIENT)); | 2358 expect(entry.getValue(DartEntry.IS_CLIENT), isTrue); |
| 2643 JUnitTestCase.assertSame( | 2359 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.VALID)); |
| 2644 CacheState.VALID, | |
| 2645 entry.getState(DartEntry.IS_CLIENT)); | |
| 2646 // invalidate | 2360 // invalidate |
| 2647 entry.setState(DartEntry.IS_CLIENT, CacheState.INVALID); | 2361 entry.setState(DartEntry.IS_CLIENT, CacheState.INVALID); |
| 2648 JUnitTestCase.assertSame( | 2362 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2649 CacheState.INVALID, | |
| 2650 entry.getState(DartEntry.IS_CLIENT)); | |
| 2651 // false | 2363 // false |
| 2652 entry.setValue(DartEntry.IS_CLIENT, false); | 2364 entry.setValue(DartEntry.IS_CLIENT, false); |
| 2653 JUnitTestCase.assertFalse(entry.getValue(DartEntry.IS_CLIENT)); | 2365 expect(entry.getValue(DartEntry.IS_CLIENT), isFalse); |
| 2654 JUnitTestCase.assertSame( | 2366 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.VALID)); |
| 2655 CacheState.VALID, | |
| 2656 entry.getState(DartEntry.IS_CLIENT)); | |
| 2657 } | 2367 } |
| 2658 | 2368 |
| 2659 void test_isLaunchable() { | 2369 void test_isLaunchable() { |
| 2660 DartEntry entry = new DartEntry(); | 2370 DartEntry entry = new DartEntry(); |
| 2661 // true | 2371 // true |
| 2662 entry.setValue(DartEntry.IS_LAUNCHABLE, true); | 2372 entry.setValue(DartEntry.IS_LAUNCHABLE, true); |
| 2663 JUnitTestCase.assertTrue(entry.getValue(DartEntry.IS_LAUNCHABLE)); | 2373 expect(entry.getValue(DartEntry.IS_LAUNCHABLE), isTrue); |
| 2664 JUnitTestCase.assertSame( | 2374 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.VALID)); |
| 2665 CacheState.VALID, | |
| 2666 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2667 // invalidate | 2375 // invalidate |
| 2668 entry.setState(DartEntry.IS_LAUNCHABLE, CacheState.INVALID); | 2376 entry.setState(DartEntry.IS_LAUNCHABLE, CacheState.INVALID); |
| 2669 JUnitTestCase.assertSame( | 2377 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2670 CacheState.INVALID, | |
| 2671 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2672 // false | 2378 // false |
| 2673 entry.setValue(DartEntry.IS_LAUNCHABLE, false); | 2379 entry.setValue(DartEntry.IS_LAUNCHABLE, false); |
| 2674 JUnitTestCase.assertFalse(entry.getValue(DartEntry.IS_LAUNCHABLE)); | 2380 expect(entry.getValue(DartEntry.IS_LAUNCHABLE), isFalse); |
| 2675 JUnitTestCase.assertSame( | 2381 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.VALID)); |
| 2676 CacheState.VALID, | |
| 2677 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2678 } | 2382 } |
| 2679 | 2383 |
| 2680 void test_recordBuildElementError() { | 2384 void test_recordBuildElementError() { |
| 2681 // TODO(brianwilkerson) This test should set the state for two libraries, | 2385 // TODO(brianwilkerson) This test should set the state for two libraries, |
| 2682 // record an error in one library, then verify that the data for the other | 2386 // record an error in one library, then verify that the data for the other |
| 2683 // library is still valid. | 2387 // library is still valid. |
| 2684 Source source = new TestSource(); | 2388 Source source = new TestSource(); |
| 2685 DartEntry entry = new DartEntry(); | 2389 DartEntry entry = new DartEntry(); |
| 2686 entry.recordBuildElementErrorInLibrary( | 2390 entry.recordBuildElementErrorInLibrary( |
| 2687 source, | 2391 source, |
| 2688 new CaughtException(new AnalysisException(), null)); | 2392 new CaughtException(new AnalysisException(), null)); |
| 2689 JUnitTestCase.assertSame( | 2393 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2690 CacheState.INVALID, | 2394 expect(entry.getStateInLibrary(DartEntry.BUILT_ELEMENT, source), same(CacheS
tate.ERROR)); |
| 2691 entry.getState(SourceEntry.CONTENT)); | 2395 expect(entry.getStateInLibrary(DartEntry.BUILT_UNIT, source), same(CacheStat
e.ERROR)); |
| 2692 JUnitTestCase.assertSame( | 2396 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 2693 CacheState.ERROR, | 2397 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2694 entry.getStateInLibrary(DartEntry.BUILT_ELEMENT, source)); | 2398 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2695 JUnitTestCase.assertSame( | 2399 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2696 CacheState.ERROR, | 2400 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 2697 entry.getStateInLibrary(DartEntry.BUILT_UNIT, source)); | 2401 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 2698 JUnitTestCase.assertSame( | 2402 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2699 CacheState.ERROR, | 2403 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 2700 entry.getState(DartEntry.ELEMENT)); | 2404 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 2701 JUnitTestCase.assertSame( | 2405 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 2702 CacheState.INVALID, | 2406 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2703 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2407 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 2704 JUnitTestCase.assertSame( | 2408 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2705 CacheState.INVALID, | 2409 expect(entry.getStateInLibrary(DartEntry.HINTS, source), same(CacheState.ERR
OR)); |
| 2706 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2410 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source), same(Ca
cheState.ERROR)); |
| 2707 JUnitTestCase.assertSame( | 2411 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source), same(CacheS
tate.ERROR)); |
| 2708 CacheState.INVALID, | 2412 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source), same(
CacheState.ERROR)); |
| 2709 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2710 JUnitTestCase.assertSame( | |
| 2711 CacheState.ERROR, | |
| 2712 entry.getState(DartEntry.IS_CLIENT)); | |
| 2713 JUnitTestCase.assertSame( | |
| 2714 CacheState.ERROR, | |
| 2715 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2716 JUnitTestCase.assertSame( | |
| 2717 CacheState.INVALID, | |
| 2718 entry.getState(SourceEntry.LINE_INFO)); | |
| 2719 JUnitTestCase.assertSame( | |
| 2720 CacheState.INVALID, | |
| 2721 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2722 JUnitTestCase.assertSame( | |
| 2723 CacheState.INVALID, | |
| 2724 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2725 JUnitTestCase.assertSame( | |
| 2726 CacheState.ERROR, | |
| 2727 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2728 JUnitTestCase.assertSame( | |
| 2729 CacheState.INVALID, | |
| 2730 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2731 JUnitTestCase.assertSame( | |
| 2732 CacheState.INVALID, | |
| 2733 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2734 JUnitTestCase.assertSame( | |
| 2735 CacheState.INVALID, | |
| 2736 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2737 JUnitTestCase.assertSame( | |
| 2738 CacheState.ERROR, | |
| 2739 entry.getStateInLibrary(DartEntry.HINTS, source)); | |
| 2740 JUnitTestCase.assertSame( | |
| 2741 CacheState.ERROR, | |
| 2742 entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source)); | |
| 2743 JUnitTestCase.assertSame( | |
| 2744 CacheState.ERROR, | |
| 2745 entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source)); | |
| 2746 JUnitTestCase.assertSame( | |
| 2747 CacheState.ERROR, | |
| 2748 entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source)); | |
| 2749 } | 2413 } |
| 2750 | 2414 |
| 2751 void test_recordContentError() { | 2415 void test_recordContentError() { |
| 2752 DartEntry entry = new DartEntry(); | 2416 DartEntry entry = new DartEntry(); |
| 2753 entry.recordContentError( | 2417 entry.recordContentError( |
| 2754 new CaughtException(new AnalysisException(), null)); | 2418 new CaughtException(new AnalysisException(), null)); |
| 2755 JUnitTestCase.assertSame( | 2419 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.ERROR)); |
| 2756 CacheState.ERROR, | 2420 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 2757 entry.getState(SourceEntry.CONTENT)); | 2421 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 2758 JUnitTestCase.assertSame( | 2422 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 2759 CacheState.ERROR, | 2423 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.ERROR)); |
| 2760 entry.getState(DartEntry.ELEMENT)); | 2424 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 2761 JUnitTestCase.assertSame( | 2425 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 2762 CacheState.ERROR, | 2426 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.ERROR)); |
| 2763 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2427 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.ERROR)); |
| 2764 JUnitTestCase.assertSame( | 2428 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.ERROR)); |
| 2765 CacheState.ERROR, | 2429 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 2766 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2430 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.ERROR)); |
| 2767 JUnitTestCase.assertSame( | 2431 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.ERROR)); |
| 2768 CacheState.ERROR, | 2432 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.ERROR)); |
| 2769 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2770 JUnitTestCase.assertSame( | |
| 2771 CacheState.ERROR, | |
| 2772 entry.getState(DartEntry.IS_CLIENT)); | |
| 2773 JUnitTestCase.assertSame( | |
| 2774 CacheState.ERROR, | |
| 2775 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2776 JUnitTestCase.assertSame( | |
| 2777 CacheState.ERROR, | |
| 2778 entry.getState(SourceEntry.LINE_INFO)); | |
| 2779 JUnitTestCase.assertSame( | |
| 2780 CacheState.ERROR, | |
| 2781 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2782 JUnitTestCase.assertSame( | |
| 2783 CacheState.ERROR, | |
| 2784 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2785 JUnitTestCase.assertSame( | |
| 2786 CacheState.ERROR, | |
| 2787 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2788 JUnitTestCase.assertSame( | |
| 2789 CacheState.ERROR, | |
| 2790 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2791 JUnitTestCase.assertSame( | |
| 2792 CacheState.ERROR, | |
| 2793 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2794 JUnitTestCase.assertSame( | |
| 2795 CacheState.ERROR, | |
| 2796 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2797 // The following lines are commented out because we don't currently have | 2433 // The following lines are commented out because we don't currently have |
| 2798 // any way of setting the state for data associated with a library we | 2434 // any way of setting the state for data associated with a library we |
| 2799 // don't know anything about. | 2435 // don't know anything about. |
| 2800 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); | 2436 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); |
| 2801 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); | 2437 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); |
| 2802 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); | 2438 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); |
| 2803 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); | 2439 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); |
| 2804 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); | 2440 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); |
| 2805 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); | 2441 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); |
| 2806 } | 2442 } |
| 2807 | 2443 |
| 2808 void test_recordHintErrorInLibrary() { | 2444 void test_recordHintErrorInLibrary() { |
| 2809 // TODO(brianwilkerson) This test should set the state for two libraries, | 2445 // TODO(brianwilkerson) This test should set the state for two libraries, |
| 2810 // record an error in one library, then verify that the data for the other | 2446 // record an error in one library, then verify that the data for the other |
| 2811 // library is still valid. | 2447 // library is still valid. |
| 2812 Source source = new TestSource(); | 2448 Source source = new TestSource(); |
| 2813 DartEntry entry = new DartEntry(); | 2449 DartEntry entry = new DartEntry(); |
| 2814 entry.recordHintErrorInLibrary( | 2450 entry.recordHintErrorInLibrary( |
| 2815 source, | 2451 source, |
| 2816 new CaughtException(new AnalysisException(), null)); | 2452 new CaughtException(new AnalysisException(), null)); |
| 2817 JUnitTestCase.assertSame( | 2453 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2818 CacheState.INVALID, | 2454 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 2819 entry.getState(SourceEntry.CONTENT)); | 2455 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2820 JUnitTestCase.assertSame( | 2456 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2821 CacheState.INVALID, | 2457 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2822 entry.getState(DartEntry.ELEMENT)); | 2458 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 2823 JUnitTestCase.assertSame( | 2459 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 2824 CacheState.INVALID, | 2460 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2825 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2461 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 2826 JUnitTestCase.assertSame( | 2462 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 2827 CacheState.INVALID, | 2463 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 2828 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2464 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2829 JUnitTestCase.assertSame( | 2465 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 2830 CacheState.INVALID, | 2466 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2831 entry.getState(DartEntry.INCLUDED_PARTS)); | 2467 expect(entry.getStateInLibrary(DartEntry.HINTS, source), same(CacheState.ERR
OR)); |
| 2832 JUnitTestCase.assertSame( | 2468 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source), same(Ca
cheState.INVALID)); |
| 2833 CacheState.INVALID, | 2469 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source), same(CacheS
tate.INVALID)); |
| 2834 entry.getState(DartEntry.IS_CLIENT)); | 2470 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source), same(
CacheState.INVALID)); |
| 2835 JUnitTestCase.assertSame( | |
| 2836 CacheState.INVALID, | |
| 2837 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2838 JUnitTestCase.assertSame( | |
| 2839 CacheState.INVALID, | |
| 2840 entry.getState(SourceEntry.LINE_INFO)); | |
| 2841 JUnitTestCase.assertSame( | |
| 2842 CacheState.INVALID, | |
| 2843 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2844 JUnitTestCase.assertSame( | |
| 2845 CacheState.INVALID, | |
| 2846 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2847 JUnitTestCase.assertSame( | |
| 2848 CacheState.INVALID, | |
| 2849 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2850 JUnitTestCase.assertSame( | |
| 2851 CacheState.INVALID, | |
| 2852 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2853 JUnitTestCase.assertSame( | |
| 2854 CacheState.INVALID, | |
| 2855 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2856 JUnitTestCase.assertSame( | |
| 2857 CacheState.INVALID, | |
| 2858 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2859 JUnitTestCase.assertSame( | |
| 2860 CacheState.ERROR, | |
| 2861 entry.getStateInLibrary(DartEntry.HINTS, source)); | |
| 2862 JUnitTestCase.assertSame( | |
| 2863 CacheState.INVALID, | |
| 2864 entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source)); | |
| 2865 JUnitTestCase.assertSame( | |
| 2866 CacheState.INVALID, | |
| 2867 entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source)); | |
| 2868 JUnitTestCase.assertSame( | |
| 2869 CacheState.INVALID, | |
| 2870 entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source)); | |
| 2871 } | 2471 } |
| 2872 | 2472 |
| 2873 void test_recordParseError() { | 2473 void test_recordParseError() { |
| 2874 DartEntry entry = new DartEntry(); | 2474 DartEntry entry = new DartEntry(); |
| 2875 entry.recordParseError(new CaughtException(new AnalysisException(), null)); | 2475 entry.recordParseError(new CaughtException(new AnalysisException(), null)); |
| 2876 JUnitTestCase.assertSame( | 2476 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2877 CacheState.INVALID, | 2477 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 2878 entry.getState(SourceEntry.CONTENT)); | 2478 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 2879 JUnitTestCase.assertSame( | 2479 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 2880 CacheState.ERROR, | 2480 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.ERROR)); |
| 2881 entry.getState(DartEntry.ELEMENT)); | 2481 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 2882 JUnitTestCase.assertSame( | 2482 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 2883 CacheState.ERROR, | 2483 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2884 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2484 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.ERROR)); |
| 2885 JUnitTestCase.assertSame( | 2485 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.ERROR)); |
| 2886 CacheState.ERROR, | 2486 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 2887 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2487 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2888 JUnitTestCase.assertSame( | 2488 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.ERROR)); |
| 2889 CacheState.ERROR, | 2489 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2890 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2891 JUnitTestCase.assertSame( | |
| 2892 CacheState.ERROR, | |
| 2893 entry.getState(DartEntry.IS_CLIENT)); | |
| 2894 JUnitTestCase.assertSame( | |
| 2895 CacheState.ERROR, | |
| 2896 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2897 JUnitTestCase.assertSame( | |
| 2898 CacheState.INVALID, | |
| 2899 entry.getState(SourceEntry.LINE_INFO)); | |
| 2900 JUnitTestCase.assertSame( | |
| 2901 CacheState.ERROR, | |
| 2902 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2903 JUnitTestCase.assertSame( | |
| 2904 CacheState.ERROR, | |
| 2905 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2906 JUnitTestCase.assertSame( | |
| 2907 CacheState.ERROR, | |
| 2908 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2909 JUnitTestCase.assertSame( | |
| 2910 CacheState.INVALID, | |
| 2911 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2912 JUnitTestCase.assertSame( | |
| 2913 CacheState.ERROR, | |
| 2914 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2915 JUnitTestCase.assertSame( | |
| 2916 CacheState.INVALID, | |
| 2917 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2918 // The following lines are commented out because we don't currently have | 2490 // The following lines are commented out because we don't currently have |
| 2919 // any way of setting the state for data associated with a library we | 2491 // any way of setting the state for data associated with a library we |
| 2920 // don't know anything about. | 2492 // don't know anything about. |
| 2921 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); | 2493 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); |
| 2922 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); | 2494 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); |
| 2923 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); | 2495 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); |
| 2924 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); | 2496 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); |
| 2925 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); | 2497 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); |
| 2926 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); | 2498 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); |
| 2927 } | 2499 } |
| 2928 | 2500 |
| 2929 void test_recordResolutionError() { | 2501 void test_recordResolutionError() { |
| 2930 // Source source = new TestSource(); | 2502 // Source source = new TestSource(); |
| 2931 DartEntry entry = new DartEntry(); | 2503 DartEntry entry = new DartEntry(); |
| 2932 entry.recordResolutionError( | 2504 entry.recordResolutionError( |
| 2933 new CaughtException(new AnalysisException(), null)); | 2505 new CaughtException(new AnalysisException(), null)); |
| 2934 JUnitTestCase.assertSame( | 2506 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2935 CacheState.INVALID, | 2507 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 2936 entry.getState(SourceEntry.CONTENT)); | 2508 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2937 JUnitTestCase.assertSame( | 2509 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2938 CacheState.ERROR, | 2510 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 2939 entry.getState(DartEntry.ELEMENT)); | 2511 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 2940 JUnitTestCase.assertSame( | 2512 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 2941 CacheState.INVALID, | 2513 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 2942 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2514 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 2943 JUnitTestCase.assertSame( | 2515 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 2944 CacheState.INVALID, | 2516 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 2945 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2517 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 2946 JUnitTestCase.assertSame( | 2518 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 2947 CacheState.INVALID, | 2519 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2948 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 2949 JUnitTestCase.assertSame( | |
| 2950 CacheState.ERROR, | |
| 2951 entry.getState(DartEntry.IS_CLIENT)); | |
| 2952 JUnitTestCase.assertSame( | |
| 2953 CacheState.ERROR, | |
| 2954 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 2955 JUnitTestCase.assertSame( | |
| 2956 CacheState.INVALID, | |
| 2957 entry.getState(SourceEntry.LINE_INFO)); | |
| 2958 JUnitTestCase.assertSame( | |
| 2959 CacheState.INVALID, | |
| 2960 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 2961 JUnitTestCase.assertSame( | |
| 2962 CacheState.INVALID, | |
| 2963 entry.getState(DartEntry.PARSED_UNIT)); | |
| 2964 JUnitTestCase.assertSame( | |
| 2965 CacheState.ERROR, | |
| 2966 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 2967 JUnitTestCase.assertSame( | |
| 2968 CacheState.INVALID, | |
| 2969 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 2970 JUnitTestCase.assertSame( | |
| 2971 CacheState.INVALID, | |
| 2972 entry.getState(DartEntry.SOURCE_KIND)); | |
| 2973 JUnitTestCase.assertSame( | |
| 2974 CacheState.INVALID, | |
| 2975 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 2976 // The following lines are commented out because we don't currently have | 2520 // The following lines are commented out because we don't currently have |
| 2977 // any way of setting the state for data associated with a library we | 2521 // any way of setting the state for data associated with a library we |
| 2978 // don't know anything about. | 2522 // don't know anything about. |
| 2979 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); | 2523 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILD_ELEME
NT_ERRORS, source)); |
| 2980 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); | 2524 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.BUILT_UNIT,
source)); |
| 2981 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); | 2525 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.HINTS, sour
ce)); |
| 2982 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); | 2526 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLUTION_
ERRORS, source)); |
| 2983 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); | 2527 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.RESOLVED_UN
IT, source)); |
| 2984 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); | 2528 // assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEntry.VERIFICATIO
N_ERRORS, source)); |
| 2985 } | 2529 } |
| 2986 | 2530 |
| 2987 void test_recordResolutionErrorInLibrary() { | 2531 void test_recordResolutionErrorInLibrary() { |
| 2988 // TODO(brianwilkerson) This test should set the state for two libraries, | 2532 // TODO(brianwilkerson) This test should set the state for two libraries, |
| 2989 // record an error in one library, then verify that the data for the other | 2533 // record an error in one library, then verify that the data for the other |
| 2990 // library is still valid. | 2534 // library is still valid. |
| 2991 Source source = new TestSource(); | 2535 Source source = new TestSource(); |
| 2992 DartEntry entry = new DartEntry(); | 2536 DartEntry entry = new DartEntry(); |
| 2993 entry.recordResolutionErrorInLibrary( | 2537 entry.recordResolutionErrorInLibrary( |
| 2994 source, | 2538 source, |
| 2995 new CaughtException(new AnalysisException(), null)); | 2539 new CaughtException(new AnalysisException(), null)); |
| 2996 JUnitTestCase.assertSame( | 2540 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 2997 CacheState.INVALID, | 2541 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 2998 entry.getState(SourceEntry.CONTENT)); | 2542 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 2999 JUnitTestCase.assertSame( | 2543 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 3000 CacheState.ERROR, | 2544 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 3001 entry.getState(DartEntry.ELEMENT)); | 2545 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 3002 JUnitTestCase.assertSame( | 2546 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 3003 CacheState.INVALID, | 2547 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 3004 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2548 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 3005 JUnitTestCase.assertSame( | 2549 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 3006 CacheState.INVALID, | 2550 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 3007 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2551 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 3008 JUnitTestCase.assertSame( | 2552 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 3009 CacheState.INVALID, | 2553 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 3010 entry.getState(DartEntry.INCLUDED_PARTS)); | 2554 expect(entry.getStateInLibrary(DartEntry.HINTS, source), same(CacheState.ERR
OR)); |
| 3011 JUnitTestCase.assertSame( | 2555 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source), same(Ca
cheState.ERROR)); |
| 3012 CacheState.ERROR, | 2556 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source), same(CacheS
tate.ERROR)); |
| 3013 entry.getState(DartEntry.IS_CLIENT)); | 2557 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source), same(
CacheState.ERROR)); |
| 3014 JUnitTestCase.assertSame( | |
| 3015 CacheState.ERROR, | |
| 3016 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 3017 JUnitTestCase.assertSame( | |
| 3018 CacheState.INVALID, | |
| 3019 entry.getState(SourceEntry.LINE_INFO)); | |
| 3020 JUnitTestCase.assertSame( | |
| 3021 CacheState.INVALID, | |
| 3022 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 3023 JUnitTestCase.assertSame( | |
| 3024 CacheState.INVALID, | |
| 3025 entry.getState(DartEntry.PARSED_UNIT)); | |
| 3026 JUnitTestCase.assertSame( | |
| 3027 CacheState.ERROR, | |
| 3028 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 3029 JUnitTestCase.assertSame( | |
| 3030 CacheState.INVALID, | |
| 3031 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 3032 JUnitTestCase.assertSame( | |
| 3033 CacheState.INVALID, | |
| 3034 entry.getState(DartEntry.SOURCE_KIND)); | |
| 3035 JUnitTestCase.assertSame( | |
| 3036 CacheState.INVALID, | |
| 3037 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 3038 JUnitTestCase.assertSame( | |
| 3039 CacheState.ERROR, | |
| 3040 entry.getStateInLibrary(DartEntry.HINTS, source)); | |
| 3041 JUnitTestCase.assertSame( | |
| 3042 CacheState.ERROR, | |
| 3043 entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source)); | |
| 3044 JUnitTestCase.assertSame( | |
| 3045 CacheState.ERROR, | |
| 3046 entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source)); | |
| 3047 JUnitTestCase.assertSame( | |
| 3048 CacheState.ERROR, | |
| 3049 entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source)); | |
| 3050 } | 2558 } |
| 3051 | 2559 |
| 3052 void test_recordScanError() { | 2560 void test_recordScanError() { |
| 3053 // Source source = new TestSource(); | 2561 // Source source = new TestSource(); |
| 3054 DartEntry entry = new DartEntry(); | 2562 DartEntry entry = new DartEntry(); |
| 3055 entry.recordScanError(new CaughtException(new AnalysisException(), null)); | 2563 entry.recordScanError(new CaughtException(new AnalysisException(), null)); |
| 3056 JUnitTestCase.assertSame( | 2564 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 3057 CacheState.INVALID, | 2565 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.ERROR)); |
| 3058 entry.getState(SourceEntry.CONTENT)); | 2566 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 3059 JUnitTestCase.assertSame( | 2567 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.ERROR))
; |
| 3060 CacheState.ERROR, | 2568 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.ERROR)); |
| 3061 entry.getState(DartEntry.ELEMENT)); | 2569 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.ERROR)); |
| 3062 JUnitTestCase.assertSame( | 2570 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.ERROR)); |
| 3063 CacheState.ERROR, | 2571 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.ERROR)); |
| 3064 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2572 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.ERROR)); |
| 3065 JUnitTestCase.assertSame( | 2573 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.ERROR)); |
| 3066 CacheState.ERROR, | 2574 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.ERROR)); |
| 3067 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2575 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.ERROR)); |
| 3068 JUnitTestCase.assertSame( | 2576 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.ERROR)); |
| 3069 CacheState.ERROR, | 2577 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.ERROR)); |
| 3070 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 3071 JUnitTestCase.assertSame( | |
| 3072 CacheState.ERROR, | |
| 3073 entry.getState(DartEntry.IS_CLIENT)); | |
| 3074 JUnitTestCase.assertSame( | |
| 3075 CacheState.ERROR, | |
| 3076 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 3077 JUnitTestCase.assertSame( | |
| 3078 CacheState.ERROR, | |
| 3079 entry.getState(SourceEntry.LINE_INFO)); | |
| 3080 JUnitTestCase.assertSame( | |
| 3081 CacheState.ERROR, | |
| 3082 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 3083 JUnitTestCase.assertSame( | |
| 3084 CacheState.ERROR, | |
| 3085 entry.getState(DartEntry.PARSED_UNIT)); | |
| 3086 JUnitTestCase.assertSame( | |
| 3087 CacheState.ERROR, | |
| 3088 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 3089 JUnitTestCase.assertSame( | |
| 3090 CacheState.ERROR, | |
| 3091 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 3092 JUnitTestCase.assertSame( | |
| 3093 CacheState.ERROR, | |
| 3094 entry.getState(DartEntry.SOURCE_KIND)); | |
| 3095 JUnitTestCase.assertSame( | |
| 3096 CacheState.ERROR, | |
| 3097 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 3098 // The following lines are commented out because we don't currently have | 2578 // The following lines are commented out because we don't currently have |
| 3099 // any way of setting the state for data associated with a library we | 2579 // any way of setting the state for data associated with a library we |
| 3100 // don't know anything about. | 2580 // don't know anything about. |
| 3101 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.BUILT_ELEMENT, source)); | 2581 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.BUILT_ELEMENT, source)); |
| 3102 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.BUILT_UNIT, source)); | 2582 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.BUILT_UNIT, source)); |
| 3103 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.HINTS, source)); | 2583 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.HINTS, source)); |
| 3104 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.RESOLUTION_ERRORS, source)); | 2584 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.RESOLUTION_ERRORS, source)); |
| 3105 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.RESOLVED_UNIT, source)); | 2585 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.RESOLVED_UNIT, source)); |
| 3106 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.VERIFICATION_ERRORS, source)); | 2586 // JUnitTestCase.assertSame(CacheState.ERROR, entry.getStateInLibrary(DartEnt
ry.VERIFICATION_ERRORS, source)); |
| 3107 } | 2587 } |
| 3108 | 2588 |
| 3109 void test_recordVerificationErrorInLibrary() { | 2589 void test_recordVerificationErrorInLibrary() { |
| 3110 // TODO(brianwilkerson) This test should set the state for two libraries, | 2590 // TODO(brianwilkerson) This test should set the state for two libraries, |
| 3111 // record an error in one library, then verify that the data for the other | 2591 // record an error in one library, then verify that the data for the other |
| 3112 // library is still valid. | 2592 // library is still valid. |
| 3113 Source source = new TestSource(); | 2593 Source source = new TestSource(); |
| 3114 DartEntry entry = new DartEntry(); | 2594 DartEntry entry = new DartEntry(); |
| 3115 entry.recordVerificationErrorInLibrary( | 2595 entry.recordVerificationErrorInLibrary( |
| 3116 source, | 2596 source, |
| 3117 new CaughtException(new AnalysisException(), null)); | 2597 new CaughtException(new AnalysisException(), null)); |
| 3118 JUnitTestCase.assertSame( | 2598 expect(entry.getState(SourceEntry.CONTENT), same(CacheState.INVALID)); |
| 3119 CacheState.INVALID, | 2599 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.INVALID)); |
| 3120 entry.getState(SourceEntry.CONTENT)); | 2600 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 3121 JUnitTestCase.assertSame( | 2601 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.INVALID
)); |
| 3122 CacheState.INVALID, | 2602 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.INVALID)); |
| 3123 entry.getState(DartEntry.ELEMENT)); | 2603 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.INVALID)); |
| 3124 JUnitTestCase.assertSame( | 2604 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.INVALID)); |
| 3125 CacheState.INVALID, | 2605 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.INVALID)); |
| 3126 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2606 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.INVALID)); |
| 3127 JUnitTestCase.assertSame( | 2607 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.INVALID)); |
| 3128 CacheState.INVALID, | 2608 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.INVALID))
; |
| 3129 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2609 expect(entry.getState(DartEntry.SCAN_ERRORS), same(CacheState.INVALID)); |
| 3130 JUnitTestCase.assertSame( | 2610 expect(entry.getState(DartEntry.SOURCE_KIND), same(CacheState.INVALID)); |
| 3131 CacheState.INVALID, | 2611 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 3132 entry.getState(DartEntry.INCLUDED_PARTS)); | 2612 expect(entry.getStateInLibrary(DartEntry.HINTS, source), same(CacheState.ERR
OR)); |
| 3133 JUnitTestCase.assertSame( | 2613 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source), same(Ca
cheState.INVALID)); |
| 3134 CacheState.INVALID, | 2614 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source), same(CacheS
tate.INVALID)); |
| 3135 entry.getState(DartEntry.IS_CLIENT)); | 2615 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source), same(
CacheState.ERROR)); |
| 3136 JUnitTestCase.assertSame( | |
| 3137 CacheState.INVALID, | |
| 3138 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 3139 JUnitTestCase.assertSame( | |
| 3140 CacheState.INVALID, | |
| 3141 entry.getState(SourceEntry.LINE_INFO)); | |
| 3142 JUnitTestCase.assertSame( | |
| 3143 CacheState.INVALID, | |
| 3144 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 3145 JUnitTestCase.assertSame( | |
| 3146 CacheState.INVALID, | |
| 3147 entry.getState(DartEntry.PARSED_UNIT)); | |
| 3148 JUnitTestCase.assertSame( | |
| 3149 CacheState.INVALID, | |
| 3150 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 3151 JUnitTestCase.assertSame( | |
| 3152 CacheState.INVALID, | |
| 3153 entry.getState(DartEntry.SCAN_ERRORS)); | |
| 3154 JUnitTestCase.assertSame( | |
| 3155 CacheState.INVALID, | |
| 3156 entry.getState(DartEntry.SOURCE_KIND)); | |
| 3157 JUnitTestCase.assertSame( | |
| 3158 CacheState.INVALID, | |
| 3159 entry.getState(DartEntry.TOKEN_STREAM)); | |
| 3160 JUnitTestCase.assertSame( | |
| 3161 CacheState.ERROR, | |
| 3162 entry.getStateInLibrary(DartEntry.HINTS, source)); | |
| 3163 JUnitTestCase.assertSame( | |
| 3164 CacheState.INVALID, | |
| 3165 entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, source)); | |
| 3166 JUnitTestCase.assertSame( | |
| 3167 CacheState.INVALID, | |
| 3168 entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, source)); | |
| 3169 JUnitTestCase.assertSame( | |
| 3170 CacheState.ERROR, | |
| 3171 entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, source)); | |
| 3172 } | 2616 } |
| 3173 | 2617 |
| 3174 void test_removeResolution_multiple_first() { | 2618 void test_removeResolution_multiple_first() { |
| 3175 Source source1 = new TestSource(); | 2619 Source source1 = new TestSource(); |
| 3176 Source source2 = new TestSource(); | 2620 Source source2 = new TestSource(); |
| 3177 Source source3 = new TestSource(); | 2621 Source source3 = new TestSource(); |
| 3178 DartEntry entry = new DartEntry(); | 2622 DartEntry entry = new DartEntry(); |
| 3179 entry.setValueInLibrary( | 2623 entry.setValueInLibrary( |
| 3180 DartEntry.RESOLVED_UNIT, | 2624 DartEntry.RESOLVED_UNIT, |
| 3181 source1, | 2625 source1, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3258 } | 2702 } |
| 3259 | 2703 |
| 3260 void test_setState_includedParts() { | 2704 void test_setState_includedParts() { |
| 3261 state2 = DartEntry.INCLUDED_PARTS; | 2705 state2 = DartEntry.INCLUDED_PARTS; |
| 3262 } | 2706 } |
| 3263 | 2707 |
| 3264 void test_setState_invalid_element() { | 2708 void test_setState_invalid_element() { |
| 3265 DartEntry entry = new DartEntry(); | 2709 DartEntry entry = new DartEntry(); |
| 3266 try { | 2710 try { |
| 3267 entry.setStateInLibrary(DartEntry.ELEMENT, null, CacheState.FLUSHED); | 2711 entry.setStateInLibrary(DartEntry.ELEMENT, null, CacheState.FLUSHED); |
| 3268 JUnitTestCase.fail("Expected IllegalArgumentException for ELEMENT"); | 2712 fail("Expected IllegalArgumentException for ELEMENT"); |
| 3269 } on ArgumentError catch (exception) { | 2713 } on ArgumentError catch (exception) { |
| 3270 // Expected | 2714 // Expected |
| 3271 } | 2715 } |
| 3272 } | 2716 } |
| 3273 | 2717 |
| 3274 void test_setState_invalid_resolutionErrors() { | 2718 void test_setState_invalid_resolutionErrors() { |
| 3275 DartEntry entry = new DartEntry(); | 2719 DartEntry entry = new DartEntry(); |
| 3276 try { | 2720 try { |
| 3277 entry.setState(DartEntry.RESOLUTION_ERRORS, CacheState.FLUSHED); | 2721 entry.setState(DartEntry.RESOLUTION_ERRORS, CacheState.FLUSHED); |
| 3278 JUnitTestCase.fail( | 2722 fail("Expected IllegalArgumentException for RESOLUTION_ERRORS"); |
| 3279 "Expected IllegalArgumentException for RESOLUTION_ERRORS"); | |
| 3280 } on ArgumentError catch (exception) { | 2723 } on ArgumentError catch (exception) { |
| 3281 // Expected | 2724 // Expected |
| 3282 } | 2725 } |
| 3283 } | 2726 } |
| 3284 | 2727 |
| 3285 void test_setState_invalid_validState() { | 2728 void test_setState_invalid_validState() { |
| 3286 DartEntry entry = new DartEntry(); | 2729 DartEntry entry = new DartEntry(); |
| 3287 try { | 2730 try { |
| 3288 entry.setState(SourceEntry.LINE_INFO, CacheState.VALID); | 2731 entry.setState(SourceEntry.LINE_INFO, CacheState.VALID); |
| 3289 JUnitTestCase.fail( | 2732 fail("Expected ArgumentError for a state of VALID"); |
| 3290 "Expected ArgumentError for a state of VALID"); | |
| 3291 } on ArgumentError catch (exception) { | 2733 } on ArgumentError catch (exception) { |
| 3292 } | 2734 } |
| 3293 } | 2735 } |
| 3294 | 2736 |
| 3295 void test_setState_invalid_verificationErrors() { | 2737 void test_setState_invalid_verificationErrors() { |
| 3296 DartEntry entry = new DartEntry(); | 2738 DartEntry entry = new DartEntry(); |
| 3297 try { | 2739 try { |
| 3298 entry.setState(DartEntry.VERIFICATION_ERRORS, CacheState.FLUSHED); | 2740 entry.setState(DartEntry.VERIFICATION_ERRORS, CacheState.FLUSHED); |
| 3299 JUnitTestCase.fail( | 2741 fail("Expected IllegalArgumentException for VERIFICATION_ERRORS"); |
| 3300 "Expected IllegalArgumentException for VERIFICATION_ERRORS"); | |
| 3301 } on ArgumentError catch (exception) { | 2742 } on ArgumentError catch (exception) { |
| 3302 // Expected | 2743 // Expected |
| 3303 } | 2744 } |
| 3304 } | 2745 } |
| 3305 | 2746 |
| 3306 void test_setState_isClient() { | 2747 void test_setState_isClient() { |
| 3307 state2 = DartEntry.IS_CLIENT; | 2748 state2 = DartEntry.IS_CLIENT; |
| 3308 } | 2749 } |
| 3309 | 2750 |
| 3310 void test_setState_isLaunchable() { | 2751 void test_setState_isLaunchable() { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3448 entry.setValue(DartEntry.ELEMENT, null); | 2889 entry.setValue(DartEntry.ELEMENT, null); |
| 3449 entry.setValue(DartEntry.EXPORTED_LIBRARIES, null); | 2890 entry.setValue(DartEntry.EXPORTED_LIBRARIES, null); |
| 3450 entry.setValue(DartEntry.IMPORTED_LIBRARIES, null); | 2891 entry.setValue(DartEntry.IMPORTED_LIBRARIES, null); |
| 3451 entry.setValue(DartEntry.INCLUDED_PARTS, null); | 2892 entry.setValue(DartEntry.INCLUDED_PARTS, null); |
| 3452 entry.setValue(DartEntry.IS_CLIENT, true); | 2893 entry.setValue(DartEntry.IS_CLIENT, true); |
| 3453 entry.setValue(DartEntry.IS_LAUNCHABLE, true); | 2894 entry.setValue(DartEntry.IS_LAUNCHABLE, true); |
| 3454 entry.setValue(SourceEntry.LINE_INFO, null); | 2895 entry.setValue(SourceEntry.LINE_INFO, null); |
| 3455 entry.setValue(DartEntry.PARSE_ERRORS, null); | 2896 entry.setValue(DartEntry.PARSE_ERRORS, null); |
| 3456 entry.setValue(DartEntry.PARSED_UNIT, null); | 2897 entry.setValue(DartEntry.PARSED_UNIT, null); |
| 3457 entry.setValue(DartEntry.PUBLIC_NAMESPACE, null); | 2898 entry.setValue(DartEntry.PUBLIC_NAMESPACE, null); |
| 3458 JUnitTestCase.assertSame( | 2899 expect(entry.getState(DartEntry.ELEMENT), same(CacheState.VALID)); |
| 3459 CacheState.VALID, | 2900 expect(entry.getState(DartEntry.EXPORTED_LIBRARIES), same(CacheState.VALID))
; |
| 3460 entry.getState(DartEntry.ELEMENT)); | 2901 expect(entry.getState(DartEntry.IMPORTED_LIBRARIES), same(CacheState.VALID))
; |
| 3461 JUnitTestCase.assertSame( | 2902 expect(entry.getState(DartEntry.INCLUDED_PARTS), same(CacheState.VALID)); |
| 3462 CacheState.VALID, | 2903 expect(entry.getState(DartEntry.IS_CLIENT), same(CacheState.VALID)); |
| 3463 entry.getState(DartEntry.EXPORTED_LIBRARIES)); | 2904 expect(entry.getState(DartEntry.IS_LAUNCHABLE), same(CacheState.VALID)); |
| 3464 JUnitTestCase.assertSame( | 2905 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 3465 CacheState.VALID, | 2906 expect(entry.getState(DartEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 3466 entry.getState(DartEntry.IMPORTED_LIBRARIES)); | 2907 expect(entry.getState(DartEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 3467 JUnitTestCase.assertSame( | 2908 expect(entry.getState(DartEntry.PUBLIC_NAMESPACE), same(CacheState.VALID)); |
| 3468 CacheState.VALID, | |
| 3469 entry.getState(DartEntry.INCLUDED_PARTS)); | |
| 3470 JUnitTestCase.assertSame( | |
| 3471 CacheState.VALID, | |
| 3472 entry.getState(DartEntry.IS_CLIENT)); | |
| 3473 JUnitTestCase.assertSame( | |
| 3474 CacheState.VALID, | |
| 3475 entry.getState(DartEntry.IS_LAUNCHABLE)); | |
| 3476 JUnitTestCase.assertSame( | |
| 3477 CacheState.VALID, | |
| 3478 entry.getState(SourceEntry.LINE_INFO)); | |
| 3479 JUnitTestCase.assertSame( | |
| 3480 CacheState.VALID, | |
| 3481 entry.getState(DartEntry.PARSE_ERRORS)); | |
| 3482 JUnitTestCase.assertSame( | |
| 3483 CacheState.VALID, | |
| 3484 entry.getState(DartEntry.PARSED_UNIT)); | |
| 3485 JUnitTestCase.assertSame( | |
| 3486 CacheState.VALID, | |
| 3487 entry.getState(DartEntry.PUBLIC_NAMESPACE)); | |
| 3488 return entry; | 2909 return entry; |
| 3489 } | 2910 } |
| 3490 | 2911 |
| 3491 void _setValue2(DataDescriptor descriptor, Object newValue) { | 2912 void _setValue2(DataDescriptor descriptor, Object newValue) { |
| 3492 DartEntry entry = new DartEntry(); | 2913 DartEntry entry = new DartEntry(); |
| 3493 Object value = entry.getValue(descriptor); | 2914 Object value = entry.getValue(descriptor); |
| 3494 JUnitTestCase.assertNotSame(value, newValue); | 2915 expect(newValue, isNot(same(value))); |
| 3495 entry.setValue(descriptor, newValue); | 2916 entry.setValue(descriptor, newValue); |
| 3496 JUnitTestCase.assertSame(CacheState.VALID, entry.getState(descriptor)); | 2917 expect(entry.getState(descriptor), same(CacheState.VALID)); |
| 3497 JUnitTestCase.assertSame(newValue, entry.getValue(descriptor)); | 2918 expect(entry.getValue(descriptor), same(newValue)); |
| 3498 } | 2919 } |
| 3499 | 2920 |
| 3500 void _setValue3(DataDescriptor descriptor, Object newValue) { | 2921 void _setValue3(DataDescriptor descriptor, Object newValue) { |
| 3501 Source source = new TestSource(); | 2922 Source source = new TestSource(); |
| 3502 DartEntry entry = new DartEntry(); | 2923 DartEntry entry = new DartEntry(); |
| 3503 Object value = entry.getValueInLibrary(descriptor, source); | 2924 Object value = entry.getValueInLibrary(descriptor, source); |
| 3504 JUnitTestCase.assertNotSame(value, newValue); | 2925 expect(newValue, isNot(same(value))); |
| 3505 entry.setValueInLibrary(descriptor, source, newValue); | 2926 entry.setValueInLibrary(descriptor, source, newValue); |
| 3506 JUnitTestCase.assertSame( | 2927 expect(entry.getStateInLibrary(descriptor, source), same(CacheState.VALID)); |
| 3507 CacheState.VALID, | 2928 expect(entry.getValueInLibrary(descriptor, source), same(newValue)); |
| 3508 entry.getStateInLibrary(descriptor, source)); | |
| 3509 JUnitTestCase.assertSame( | |
| 3510 newValue, | |
| 3511 entry.getValueInLibrary(descriptor, source)); | |
| 3512 } | 2929 } |
| 3513 } | 2930 } |
| 3514 | 2931 |
| 3515 | 2932 |
| 3516 class GenerateDartErrorsTaskTest extends EngineTestCase { | 2933 class GenerateDartErrorsTaskTest extends EngineTestCase { |
| 3517 void test_accept() { | 2934 void test_accept() { |
| 3518 GenerateDartErrorsTask task = | 2935 GenerateDartErrorsTask task = |
| 3519 new GenerateDartErrorsTask(null, null, null, null); | 2936 new GenerateDartErrorsTask(null, null, null, null); |
| 3520 JUnitTestCase.assertTrue( | 2937 expect(task.accept(new GenerateDartErrorsTaskTestTV_accept()), isTrue); |
| 3521 task.accept(new GenerateDartErrorsTaskTestTV_accept())); | |
| 3522 } | 2938 } |
| 3523 | 2939 |
| 3524 void test_getException() { | 2940 void test_getException() { |
| 3525 GenerateDartErrorsTask task = | 2941 GenerateDartErrorsTask task = |
| 3526 new GenerateDartErrorsTask(null, null, null, null); | 2942 new GenerateDartErrorsTask(null, null, null, null); |
| 3527 JUnitTestCase.assertNull(task.exception); | 2943 expect(task.exception, isNull); |
| 3528 } | 2944 } |
| 3529 | 2945 |
| 3530 void test_getLibraryElement() { | 2946 void test_getLibraryElement() { |
| 3531 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 2947 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3532 LibraryElement element = ElementFactory.library(context, "lib"); | 2948 LibraryElement element = ElementFactory.library(context, "lib"); |
| 3533 GenerateDartErrorsTask task = | 2949 GenerateDartErrorsTask task = |
| 3534 new GenerateDartErrorsTask(context, null, null, element); | 2950 new GenerateDartErrorsTask(context, null, null, element); |
| 3535 JUnitTestCase.assertSame(element, task.libraryElement); | 2951 expect(task.libraryElement, same(element)); |
| 3536 } | 2952 } |
| 3537 | 2953 |
| 3538 void test_getSource() { | 2954 void test_getSource() { |
| 3539 Source source = | 2955 Source source = |
| 3540 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 2956 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 3541 GenerateDartErrorsTask task = | 2957 GenerateDartErrorsTask task = |
| 3542 new GenerateDartErrorsTask(null, source, null, null); | 2958 new GenerateDartErrorsTask(null, source, null, null); |
| 3543 JUnitTestCase.assertSame(source, task.source); | 2959 expect(task.source, same(source)); |
| 3544 } | 2960 } |
| 3545 | 2961 |
| 3546 void test_perform() { | 2962 void test_perform() { |
| 3547 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 2963 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3548 Source source = | 2964 Source source = |
| 3549 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 2965 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 3550 ChangeSet changeSet = new ChangeSet(); | 2966 ChangeSet changeSet = new ChangeSet(); |
| 3551 changeSet.addedSource(source); | 2967 changeSet.addedSource(source); |
| 3552 context.applyChanges(changeSet); | 2968 context.applyChanges(changeSet); |
| 3553 context.setContents( | 2969 context.setContents( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3614 class GenerateDartErrorsTaskTestTV_perform extends TestTaskVisitor<bool> { | 3030 class GenerateDartErrorsTaskTestTV_perform extends TestTaskVisitor<bool> { |
| 3615 LibraryElement libraryElement; | 3031 LibraryElement libraryElement; |
| 3616 Source source; | 3032 Source source; |
| 3617 GenerateDartErrorsTaskTestTV_perform(this.libraryElement, this.source); | 3033 GenerateDartErrorsTaskTestTV_perform(this.libraryElement, this.source); |
| 3618 @override | 3034 @override |
| 3619 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 3035 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 3620 CaughtException exception = task.exception; | 3036 CaughtException exception = task.exception; |
| 3621 if (exception != null) { | 3037 if (exception != null) { |
| 3622 throw exception; | 3038 throw exception; |
| 3623 } | 3039 } |
| 3624 JUnitTestCase.assertSame(libraryElement, task.libraryElement); | 3040 expect(task.libraryElement, same(libraryElement)); |
| 3625 JUnitTestCase.assertSame(source, task.source); | 3041 expect(task.source, same(source)); |
| 3626 List<AnalysisError> errors = task.errors; | 3042 List<AnalysisError> errors = task.errors; |
| 3627 EngineTestCase.assertLength(1, errors); | 3043 EngineTestCase.assertLength(1, errors); |
| 3628 return true; | 3044 return true; |
| 3629 } | 3045 } |
| 3630 } | 3046 } |
| 3631 | 3047 |
| 3632 | 3048 |
| 3633 class GenerateDartErrorsTaskTestTV_perform_validateDirectives extends | 3049 class GenerateDartErrorsTaskTestTV_perform_validateDirectives extends |
| 3634 TestTaskVisitor<bool> { | 3050 TestTaskVisitor<bool> { |
| 3635 LibraryElement libraryElement; | 3051 LibraryElement libraryElement; |
| 3636 Source source; | 3052 Source source; |
| 3637 GenerateDartErrorsTaskTestTV_perform_validateDirectives(this.libraryElement, | 3053 GenerateDartErrorsTaskTestTV_perform_validateDirectives(this.libraryElement, |
| 3638 this.source); | 3054 this.source); |
| 3639 @override | 3055 @override |
| 3640 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 3056 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 3641 CaughtException exception = task.exception; | 3057 CaughtException exception = task.exception; |
| 3642 if (exception != null) { | 3058 if (exception != null) { |
| 3643 throw exception; | 3059 throw exception; |
| 3644 } | 3060 } |
| 3645 JUnitTestCase.assertSame(libraryElement, task.libraryElement); | 3061 expect(task.libraryElement, same(libraryElement)); |
| 3646 JUnitTestCase.assertSame(source, task.source); | 3062 expect(task.source, same(source)); |
| 3647 List<AnalysisError> errors = task.errors; | 3063 List<AnalysisError> errors = task.errors; |
| 3648 EngineTestCase.assertLength(1, errors); | 3064 EngineTestCase.assertLength(1, errors); |
| 3649 JUnitTestCase.assertSame( | 3065 expect(errors[0].errorCode, same(CompileTimeErrorCode.URI_DOES_NOT_EXIST)); |
| 3650 CompileTimeErrorCode.URI_DOES_NOT_EXIST, | |
| 3651 errors[0].errorCode); | |
| 3652 return true; | 3066 return true; |
| 3653 } | 3067 } |
| 3654 } | 3068 } |
| 3655 | 3069 |
| 3656 class GenerateDartHintsTaskTest extends EngineTestCase { | 3070 class GenerateDartHintsTaskTest extends EngineTestCase { |
| 3657 void test_accept() { | 3071 void test_accept() { |
| 3658 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3072 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3659 JUnitTestCase.assertTrue( | 3073 expect(task.accept(new GenerateDartHintsTaskTestTV_accept()), isTrue); |
| 3660 task.accept(new GenerateDartHintsTaskTestTV_accept())); | |
| 3661 } | 3074 } |
| 3662 void test_getException() { | 3075 void test_getException() { |
| 3663 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3076 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3664 JUnitTestCase.assertNull(task.exception); | 3077 expect(task.exception, isNull); |
| 3665 } | 3078 } |
| 3666 void test_getHintMap() { | 3079 void test_getHintMap() { |
| 3667 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3080 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3668 JUnitTestCase.assertNull(task.hintMap); | 3081 expect(task.hintMap, isNull); |
| 3669 } | 3082 } |
| 3670 void test_getLibraryElement() { | 3083 void test_getLibraryElement() { |
| 3671 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3084 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3672 LibraryElement element = ElementFactory.library(context, "lib"); | 3085 LibraryElement element = ElementFactory.library(context, "lib"); |
| 3673 GenerateDartHintsTask task = | 3086 GenerateDartHintsTask task = |
| 3674 new GenerateDartHintsTask(context, null, element); | 3087 new GenerateDartHintsTask(context, null, element); |
| 3675 JUnitTestCase.assertSame(element, task.libraryElement); | 3088 expect(task.libraryElement, same(element)); |
| 3676 } | 3089 } |
| 3677 void test_perform() { | 3090 void test_perform() { |
| 3678 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3091 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3679 ChangeSet changeSet = new ChangeSet(); | 3092 ChangeSet changeSet = new ChangeSet(); |
| 3680 Source librarySource = | 3093 Source librarySource = |
| 3681 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3094 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 3682 changeSet.addedSource(librarySource); | 3095 changeSet.addedSource(librarySource); |
| 3683 Source unusedSource = | 3096 Source unusedSource = |
| 3684 new FileBasedSource.con1(FileUtilities2.createFile("/unused.dart")); | 3097 new FileBasedSource.con1(FileUtilities2.createFile("/unused.dart")); |
| 3685 changeSet.addedSource(unusedSource); | 3098 changeSet.addedSource(unusedSource); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3725 class GenerateDartHintsTaskTestTV_perform extends TestTaskVisitor<bool> { | 3138 class GenerateDartHintsTaskTestTV_perform extends TestTaskVisitor<bool> { |
| 3726 Source librarySource; | 3139 Source librarySource; |
| 3727 Source partSource; | 3140 Source partSource; |
| 3728 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); | 3141 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); |
| 3729 @override | 3142 @override |
| 3730 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { | 3143 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 3731 CaughtException exception = task.exception; | 3144 CaughtException exception = task.exception; |
| 3732 if (exception != null) { | 3145 if (exception != null) { |
| 3733 throw exception; | 3146 throw exception; |
| 3734 } | 3147 } |
| 3735 JUnitTestCase.assertNotNull(task.libraryElement); | 3148 expect(task.libraryElement, isNotNull); |
| 3736 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; | 3149 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; |
| 3737 EngineTestCase.assertSizeOfMap(2, hintMap); | 3150 EngineTestCase.assertSizeOfMap(2, hintMap); |
| 3738 EngineTestCase.assertLength(1, hintMap[librarySource]); | 3151 EngineTestCase.assertLength(1, hintMap[librarySource]); |
| 3739 EngineTestCase.assertLength(0, hintMap[partSource]); | 3152 EngineTestCase.assertLength(0, hintMap[partSource]); |
| 3740 return true; | 3153 return true; |
| 3741 } | 3154 } |
| 3742 } | 3155 } |
| 3743 | 3156 |
| 3744 | 3157 |
| 3745 class GetContentTaskTest extends EngineTestCase { | 3158 class GetContentTaskTest extends EngineTestCase { |
| 3746 void test_accept() { | 3159 void test_accept() { |
| 3747 Source source = new TestSource('/test.dart', ''); | 3160 Source source = new TestSource('/test.dart', ''); |
| 3748 GetContentTask task = new GetContentTask(null, source); | 3161 GetContentTask task = new GetContentTask(null, source); |
| 3749 JUnitTestCase.assertTrue(task.accept(new GetContentTaskTestTV_accept())); | 3162 expect(task.accept(new GetContentTaskTestTV_accept()), isTrue); |
| 3750 } | 3163 } |
| 3751 | 3164 |
| 3752 void test_getException() { | 3165 void test_getException() { |
| 3753 Source source = new TestSource('/test.dart', ''); | 3166 Source source = new TestSource('/test.dart', ''); |
| 3754 GetContentTask task = new GetContentTask(null, source); | 3167 GetContentTask task = new GetContentTask(null, source); |
| 3755 JUnitTestCase.assertNull(task.exception); | 3168 expect(task.exception, isNull); |
| 3756 } | 3169 } |
| 3757 | 3170 |
| 3758 void test_getModificationTime() { | 3171 void test_getModificationTime() { |
| 3759 Source source = new TestSource('/test.dart', ''); | 3172 Source source = new TestSource('/test.dart', ''); |
| 3760 GetContentTask task = new GetContentTask(null, source); | 3173 GetContentTask task = new GetContentTask(null, source); |
| 3761 JUnitTestCase.assertEquals(-1, task.modificationTime); | 3174 expect(task.modificationTime, -1); |
| 3762 } | 3175 } |
| 3763 | 3176 |
| 3764 void test_getSource() { | 3177 void test_getSource() { |
| 3765 Source source = new TestSource('/test.dart', ''); | 3178 Source source = new TestSource('/test.dart', ''); |
| 3766 GetContentTask task = new GetContentTask(null, source); | 3179 GetContentTask task = new GetContentTask(null, source); |
| 3767 JUnitTestCase.assertSame(source, task.source); | 3180 expect(task.source, same(source)); |
| 3768 } | 3181 } |
| 3769 | 3182 |
| 3770 void test_perform_exception() { | 3183 void test_perform_exception() { |
| 3771 TestSource source = new TestSource(); | 3184 TestSource source = new TestSource(); |
| 3772 source.generateExceptionOnRead = true; | 3185 source.generateExceptionOnRead = true; |
| 3773 // final InternalAnalysisContext context = new AnalysisContextImpl(); | 3186 // final InternalAnalysisContext context = new AnalysisContextImpl(); |
| 3774 // context.setSourceFactory(new SourceFactory(new FileUriResolver())); | 3187 // context.setSourceFactory(new SourceFactory(new FileUriResolver())); |
| 3775 GetContentTask task = new GetContentTask(null, source); | 3188 GetContentTask task = new GetContentTask(null, source); |
| 3776 task.perform(new GetContentTaskTestTV_perform_exception()); | 3189 task.perform(new GetContentTaskTestTV_perform_exception()); |
| 3777 } | 3190 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 3788 | 3201 |
| 3789 class GetContentTaskTestTV_accept extends TestTaskVisitor<bool> { | 3202 class GetContentTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 3790 @override | 3203 @override |
| 3791 bool visitGetContentTask(GetContentTask task) => true; | 3204 bool visitGetContentTask(GetContentTask task) => true; |
| 3792 } | 3205 } |
| 3793 | 3206 |
| 3794 | 3207 |
| 3795 class GetContentTaskTestTV_perform_exception extends TestTaskVisitor<bool> { | 3208 class GetContentTaskTestTV_perform_exception extends TestTaskVisitor<bool> { |
| 3796 @override | 3209 @override |
| 3797 bool visitGetContentTask(GetContentTask task) { | 3210 bool visitGetContentTask(GetContentTask task) { |
| 3798 JUnitTestCase.assertNotNull(task.exception); | 3211 expect(task.exception, isNotNull); |
| 3799 return true; | 3212 return true; |
| 3800 } | 3213 } |
| 3801 } | 3214 } |
| 3802 | 3215 |
| 3803 | 3216 |
| 3804 class GetContentTaskTestTV_perform_valid extends TestTaskVisitor<bool> { | 3217 class GetContentTaskTestTV_perform_valid extends TestTaskVisitor<bool> { |
| 3805 InternalAnalysisContext context; | 3218 InternalAnalysisContext context; |
| 3806 Source source; | 3219 Source source; |
| 3807 GetContentTaskTestTV_perform_valid(this.context, this.source); | 3220 GetContentTaskTestTV_perform_valid(this.context, this.source); |
| 3808 @override | 3221 @override |
| 3809 bool visitGetContentTask(GetContentTask task) { | 3222 bool visitGetContentTask(GetContentTask task) { |
| 3810 CaughtException exception = task.exception; | 3223 CaughtException exception = task.exception; |
| 3811 if (exception != null) { | 3224 if (exception != null) { |
| 3812 throw exception; | 3225 throw exception; |
| 3813 } | 3226 } |
| 3814 JUnitTestCase.assertEquals( | 3227 expect(task.modificationTime, context.getModificationStamp(source)); |
| 3815 context.getModificationStamp(source), | 3228 expect(task.source, same(source)); |
| 3816 task.modificationTime); | |
| 3817 JUnitTestCase.assertSame(source, task.source); | |
| 3818 return true; | 3229 return true; |
| 3819 } | 3230 } |
| 3820 } | 3231 } |
| 3821 | 3232 |
| 3822 | 3233 |
| 3823 class HtmlEntryTest extends EngineTestCase { | 3234 class HtmlEntryTest extends EngineTestCase { |
| 3824 void set state(DataDescriptor descriptor) { | 3235 void set state(DataDescriptor descriptor) { |
| 3825 HtmlEntry entry = new HtmlEntry(); | 3236 HtmlEntry entry = new HtmlEntry(); |
| 3826 JUnitTestCase.assertNotSame(CacheState.FLUSHED, entry.getState(descriptor)); | 3237 expect(entry.getState(descriptor), isNot(same(CacheState.FLUSHED))); |
| 3827 entry.setState(descriptor, CacheState.FLUSHED); | 3238 entry.setState(descriptor, CacheState.FLUSHED); |
| 3828 JUnitTestCase.assertSame(CacheState.FLUSHED, entry.getState(descriptor)); | 3239 expect(entry.getState(descriptor), same(CacheState.FLUSHED)); |
| 3829 } | 3240 } |
| 3830 | 3241 |
| 3831 void test_creation() { | 3242 void test_creation() { |
| 3832 HtmlEntry entry = new HtmlEntry(); | 3243 HtmlEntry entry = new HtmlEntry(); |
| 3833 JUnitTestCase.assertNotNull(entry); | 3244 expect(entry, isNotNull); |
| 3834 } | 3245 } |
| 3835 | 3246 |
| 3836 void test_getAllErrors() { | 3247 void test_getAllErrors() { |
| 3837 Source source = new TestSource(); | 3248 Source source = new TestSource(); |
| 3838 HtmlEntry entry = new HtmlEntry(); | 3249 HtmlEntry entry = new HtmlEntry(); |
| 3839 EngineTestCase.assertLength(0, entry.allErrors); | 3250 EngineTestCase.assertLength(0, entry.allErrors); |
| 3840 entry.setValue( | 3251 entry.setValue( |
| 3841 HtmlEntry.PARSE_ERRORS, | 3252 HtmlEntry.PARSE_ERRORS, |
| 3842 <AnalysisError>[ | 3253 <AnalysisError>[ |
| 3843 new AnalysisError.con1(source, ParserErrorCode.EXPECTED_TOKEN, [";"]
)]); | 3254 new AnalysisError.con1(source, ParserErrorCode.EXPECTED_TOKEN, [";"]
)]); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3859 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); | 3270 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); |
| 3860 entry.setValue( | 3271 entry.setValue( |
| 3861 HtmlEntry.HINTS, | 3272 HtmlEntry.HINTS, |
| 3862 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; | 3273 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; |
| 3863 EngineTestCase.assertLength(6, entry.allErrors); | 3274 EngineTestCase.assertLength(6, entry.allErrors); |
| 3864 } | 3275 } |
| 3865 | 3276 |
| 3866 void test_invalidateAllResolutionInformation() { | 3277 void test_invalidateAllResolutionInformation() { |
| 3867 HtmlEntry entry = _entryWithValidState(); | 3278 HtmlEntry entry = _entryWithValidState(); |
| 3868 entry.invalidateAllResolutionInformation(false); | 3279 entry.invalidateAllResolutionInformation(false); |
| 3869 JUnitTestCase.assertSame( | 3280 expect(entry.getState(HtmlEntry.ANGULAR_APPLICATION), same(CacheState.VALID)
); |
| 3870 CacheState.VALID, | 3281 expect(entry.getState(HtmlEntry.ANGULAR_COMPONENT), same(CacheState.VALID)); |
| 3871 entry.getState(HtmlEntry.ANGULAR_APPLICATION)); | 3282 expect(entry.getState(HtmlEntry.ANGULAR_ENTRY), same(CacheState.INVALID)); |
| 3872 JUnitTestCase.assertSame( | 3283 expect(entry.getState(HtmlEntry.ANGULAR_ERRORS), same(CacheState.INVALID)); |
| 3873 CacheState.VALID, | 3284 expect(entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS), same(CacheState.INVAL
ID)); |
| 3874 entry.getState(HtmlEntry.ANGULAR_COMPONENT)); | 3285 expect(entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS), same(CacheState.
INVALID)); |
| 3875 JUnitTestCase.assertSame( | 3286 expect(entry.getState(HtmlEntry.ELEMENT), same(CacheState.INVALID)); |
| 3876 CacheState.INVALID, | 3287 expect(entry.getState(HtmlEntry.HINTS), same(CacheState.INVALID)); |
| 3877 entry.getState(HtmlEntry.ANGULAR_ENTRY)); | 3288 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 3878 JUnitTestCase.assertSame( | 3289 expect(entry.getState(HtmlEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 3879 CacheState.INVALID, | 3290 expect(entry.getState(HtmlEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 3880 entry.getState(HtmlEntry.ANGULAR_ERRORS)); | 3291 expect(entry.getState(HtmlEntry.REFERENCED_LIBRARIES), same(CacheState.VALID
)); |
| 3881 JUnitTestCase.assertSame( | 3292 expect(entry.getState(HtmlEntry.RESOLUTION_ERRORS), same(CacheState.INVALID)
); |
| 3882 CacheState.INVALID, | |
| 3883 entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS)); | |
| 3884 JUnitTestCase.assertSame( | |
| 3885 CacheState.INVALID, | |
| 3886 entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS)); | |
| 3887 JUnitTestCase.assertSame( | |
| 3888 CacheState.INVALID, | |
| 3889 entry.getState(HtmlEntry.ELEMENT)); | |
| 3890 JUnitTestCase.assertSame( | |
| 3891 CacheState.INVALID, | |
| 3892 entry.getState(HtmlEntry.HINTS)); | |
| 3893 JUnitTestCase.assertSame( | |
| 3894 CacheState.VALID, | |
| 3895 entry.getState(SourceEntry.LINE_INFO)); | |
| 3896 JUnitTestCase.assertSame( | |
| 3897 CacheState.VALID, | |
| 3898 entry.getState(HtmlEntry.PARSE_ERRORS)); | |
| 3899 JUnitTestCase.assertSame( | |
| 3900 CacheState.VALID, | |
| 3901 entry.getState(HtmlEntry.PARSED_UNIT)); | |
| 3902 JUnitTestCase.assertSame( | |
| 3903 CacheState.VALID, | |
| 3904 entry.getState(HtmlEntry.REFERENCED_LIBRARIES)); | |
| 3905 JUnitTestCase.assertSame( | |
| 3906 CacheState.INVALID, | |
| 3907 entry.getState(HtmlEntry.RESOLUTION_ERRORS)); | |
| 3908 } | 3293 } |
| 3909 | 3294 |
| 3910 void test_invalidateAllResolutionInformation_includingUris() { | 3295 void test_invalidateAllResolutionInformation_includingUris() { |
| 3911 HtmlEntry entry = _entryWithValidState(); | 3296 HtmlEntry entry = _entryWithValidState(); |
| 3912 entry.invalidateAllResolutionInformation(true); | 3297 entry.invalidateAllResolutionInformation(true); |
| 3913 JUnitTestCase.assertSame( | 3298 expect(entry.getState(HtmlEntry.ANGULAR_APPLICATION), same(CacheState.VALID)
); |
| 3914 CacheState.VALID, | 3299 expect(entry.getState(HtmlEntry.ANGULAR_COMPONENT), same(CacheState.VALID)); |
| 3915 entry.getState(HtmlEntry.ANGULAR_APPLICATION)); | 3300 expect(entry.getState(HtmlEntry.ANGULAR_ENTRY), same(CacheState.INVALID)); |
| 3916 JUnitTestCase.assertSame( | 3301 expect(entry.getState(HtmlEntry.ANGULAR_ERRORS), same(CacheState.INVALID)); |
| 3917 CacheState.VALID, | 3302 expect(entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS), same(CacheState.INVAL
ID)); |
| 3918 entry.getState(HtmlEntry.ANGULAR_COMPONENT)); | 3303 expect(entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS), same(CacheState.
INVALID)); |
| 3919 JUnitTestCase.assertSame( | 3304 expect(entry.getState(HtmlEntry.ELEMENT), same(CacheState.INVALID)); |
| 3920 CacheState.INVALID, | 3305 expect(entry.getState(HtmlEntry.HINTS), same(CacheState.INVALID)); |
| 3921 entry.getState(HtmlEntry.ANGULAR_ENTRY)); | 3306 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 3922 JUnitTestCase.assertSame( | 3307 expect(entry.getState(HtmlEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 3923 CacheState.INVALID, | 3308 expect(entry.getState(HtmlEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 3924 entry.getState(HtmlEntry.ANGULAR_ERRORS)); | 3309 expect(entry.getState(HtmlEntry.REFERENCED_LIBRARIES), same(CacheState.INVAL
ID)); |
| 3925 JUnitTestCase.assertSame( | 3310 expect(entry.getState(HtmlEntry.RESOLUTION_ERRORS), same(CacheState.INVALID)
); |
| 3926 CacheState.INVALID, | |
| 3927 entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS)); | |
| 3928 JUnitTestCase.assertSame( | |
| 3929 CacheState.INVALID, | |
| 3930 entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS)); | |
| 3931 JUnitTestCase.assertSame( | |
| 3932 CacheState.INVALID, | |
| 3933 entry.getState(HtmlEntry.ELEMENT)); | |
| 3934 JUnitTestCase.assertSame( | |
| 3935 CacheState.INVALID, | |
| 3936 entry.getState(HtmlEntry.HINTS)); | |
| 3937 JUnitTestCase.assertSame( | |
| 3938 CacheState.VALID, | |
| 3939 entry.getState(SourceEntry.LINE_INFO)); | |
| 3940 JUnitTestCase.assertSame( | |
| 3941 CacheState.VALID, | |
| 3942 entry.getState(HtmlEntry.PARSE_ERRORS)); | |
| 3943 JUnitTestCase.assertSame( | |
| 3944 CacheState.VALID, | |
| 3945 entry.getState(HtmlEntry.PARSED_UNIT)); | |
| 3946 JUnitTestCase.assertSame( | |
| 3947 CacheState.INVALID, | |
| 3948 entry.getState(HtmlEntry.REFERENCED_LIBRARIES)); | |
| 3949 JUnitTestCase.assertSame( | |
| 3950 CacheState.INVALID, | |
| 3951 entry.getState(HtmlEntry.RESOLUTION_ERRORS)); | |
| 3952 } | 3311 } |
| 3953 | 3312 |
| 3954 void test_setState_angularErrors() { | 3313 void test_setState_angularErrors() { |
| 3955 state = HtmlEntry.ANGULAR_ERRORS; | 3314 state = HtmlEntry.ANGULAR_ERRORS; |
| 3956 } | 3315 } |
| 3957 | 3316 |
| 3958 void test_setState_element() { | 3317 void test_setState_element() { |
| 3959 state = HtmlEntry.ELEMENT; | 3318 state = HtmlEntry.ELEMENT; |
| 3960 } | 3319 } |
| 3961 | 3320 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4005 void test_setValue_hints() { | 3364 void test_setValue_hints() { |
| 4006 _setValue( | 3365 _setValue( |
| 4007 HtmlEntry.HINTS, | 3366 HtmlEntry.HINTS, |
| 4008 <AnalysisError>[new AnalysisError.con1(null, HintCode.DEAD_CODE, [])]); | 3367 <AnalysisError>[new AnalysisError.con1(null, HintCode.DEAD_CODE, [])]); |
| 4009 } | 3368 } |
| 4010 | 3369 |
| 4011 void test_setValue_illegal() { | 3370 void test_setValue_illegal() { |
| 4012 HtmlEntry entry = new HtmlEntry(); | 3371 HtmlEntry entry = new HtmlEntry(); |
| 4013 try { | 3372 try { |
| 4014 entry.setValue(DartEntry.ELEMENT, null); | 3373 entry.setValue(DartEntry.ELEMENT, null); |
| 4015 JUnitTestCase.fail( | 3374 fail("Expected IllegalArgumentException for DartEntry.ELEMENT"); |
| 4016 "Expected IllegalArgumentException for DartEntry.ELEMENT"); | |
| 4017 } on ArgumentError catch (exception) { | 3375 } on ArgumentError catch (exception) { |
| 4018 } | 3376 } |
| 4019 } | 3377 } |
| 4020 | 3378 |
| 4021 void test_setValue_lineInfo() { | 3379 void test_setValue_lineInfo() { |
| 4022 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); | 3380 _setValue(SourceEntry.LINE_INFO, new LineInfo(<int>[0])); |
| 4023 } | 3381 } |
| 4024 | 3382 |
| 4025 void test_setValue_parseErrors() { | 3383 void test_setValue_parseErrors() { |
| 4026 _setValue( | 3384 _setValue( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4065 entry.setValue(HtmlEntry.ANGULAR_ERRORS, null); | 3423 entry.setValue(HtmlEntry.ANGULAR_ERRORS, null); |
| 4066 entry.setValue(HtmlEntry.ELEMENT, null); | 3424 entry.setValue(HtmlEntry.ELEMENT, null); |
| 4067 entry.setValue(HtmlEntry.HINTS, null); | 3425 entry.setValue(HtmlEntry.HINTS, null); |
| 4068 entry.setValue(SourceEntry.LINE_INFO, null); | 3426 entry.setValue(SourceEntry.LINE_INFO, null); |
| 4069 entry.setValue(HtmlEntry.PARSE_ERRORS, null); | 3427 entry.setValue(HtmlEntry.PARSE_ERRORS, null); |
| 4070 entry.setValue(HtmlEntry.PARSED_UNIT, null); | 3428 entry.setValue(HtmlEntry.PARSED_UNIT, null); |
| 4071 entry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, null); | 3429 entry.setValue(HtmlEntry.POLYMER_BUILD_ERRORS, null); |
| 4072 entry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, null); | 3430 entry.setValue(HtmlEntry.POLYMER_RESOLUTION_ERRORS, null); |
| 4073 entry.setValue(HtmlEntry.REFERENCED_LIBRARIES, null); | 3431 entry.setValue(HtmlEntry.REFERENCED_LIBRARIES, null); |
| 4074 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, null); | 3432 entry.setValue(HtmlEntry.RESOLUTION_ERRORS, null); |
| 4075 JUnitTestCase.assertSame( | 3433 expect(entry.getState(HtmlEntry.ANGULAR_ERRORS), same(CacheState.VALID)); |
| 4076 CacheState.VALID, | 3434 expect(entry.getState(HtmlEntry.ELEMENT), same(CacheState.VALID)); |
| 4077 entry.getState(HtmlEntry.ANGULAR_ERRORS)); | 3435 expect(entry.getState(HtmlEntry.HINTS), same(CacheState.VALID)); |
| 4078 JUnitTestCase.assertSame( | 3436 expect(entry.getState(SourceEntry.LINE_INFO), same(CacheState.VALID)); |
| 4079 CacheState.VALID, | 3437 expect(entry.getState(HtmlEntry.PARSE_ERRORS), same(CacheState.VALID)); |
| 4080 entry.getState(HtmlEntry.ELEMENT)); | 3438 expect(entry.getState(HtmlEntry.PARSED_UNIT), same(CacheState.VALID)); |
| 4081 JUnitTestCase.assertSame(CacheState.VALID, entry.getState(HtmlEntry.HINTS)); | 3439 expect(entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS), same(CacheState.VALID
)); |
| 4082 JUnitTestCase.assertSame( | 3440 expect(entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS), same(CacheState.
VALID)); |
| 4083 CacheState.VALID, | 3441 expect(entry.getState(HtmlEntry.REFERENCED_LIBRARIES), same(CacheState.VALID
)); |
| 4084 entry.getState(SourceEntry.LINE_INFO)); | 3442 expect(entry.getState(HtmlEntry.RESOLUTION_ERRORS), same(CacheState.VALID)); |
| 4085 JUnitTestCase.assertSame( | |
| 4086 CacheState.VALID, | |
| 4087 entry.getState(HtmlEntry.PARSE_ERRORS)); | |
| 4088 JUnitTestCase.assertSame( | |
| 4089 CacheState.VALID, | |
| 4090 entry.getState(HtmlEntry.PARSED_UNIT)); | |
| 4091 JUnitTestCase.assertSame( | |
| 4092 CacheState.VALID, | |
| 4093 entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS)); | |
| 4094 JUnitTestCase.assertSame( | |
| 4095 CacheState.VALID, | |
| 4096 entry.getState(HtmlEntry.POLYMER_RESOLUTION_ERRORS)); | |
| 4097 JUnitTestCase.assertSame( | |
| 4098 CacheState.VALID, | |
| 4099 entry.getState(HtmlEntry.REFERENCED_LIBRARIES)); | |
| 4100 JUnitTestCase.assertSame( | |
| 4101 CacheState.VALID, | |
| 4102 entry.getState(HtmlEntry.RESOLUTION_ERRORS)); | |
| 4103 return entry; | 3443 return entry; |
| 4104 } | 3444 } |
| 4105 | 3445 |
| 4106 void _setValue(DataDescriptor descriptor, Object newValue) { | 3446 void _setValue(DataDescriptor descriptor, Object newValue) { |
| 4107 HtmlEntry entry = new HtmlEntry(); | 3447 HtmlEntry entry = new HtmlEntry(); |
| 4108 Object value = entry.getValue(descriptor); | 3448 Object value = entry.getValue(descriptor); |
| 4109 JUnitTestCase.assertNotSame(value, newValue); | 3449 expect(newValue, isNot(same(value))); |
| 4110 entry.setValue(descriptor, newValue); | 3450 entry.setValue(descriptor, newValue); |
| 4111 JUnitTestCase.assertSame(CacheState.VALID, entry.getState(descriptor)); | 3451 expect(entry.getState(descriptor), same(CacheState.VALID)); |
| 4112 JUnitTestCase.assertSame(newValue, entry.getValue(descriptor)); | 3452 expect(entry.getValue(descriptor), same(newValue)); |
| 4113 } | 3453 } |
| 4114 } | 3454 } |
| 4115 | 3455 |
| 4116 | 3456 |
| 4117 class IncrementalAnalysisCacheTest extends JUnitTestCase { | 3457 class IncrementalAnalysisCacheTest { |
| 4118 Source _source = new TestSource(); | 3458 Source _source = new TestSource(); |
| 4119 DartEntry _entry = new DartEntry(); | 3459 DartEntry _entry = new DartEntry(); |
| 4120 CompilationUnit _unit = new CompilationUnitMock(); | 3460 CompilationUnit _unit = new CompilationUnitMock(); |
| 4121 IncrementalAnalysisCache _result; | 3461 IncrementalAnalysisCache _result; |
| 4122 @override | |
| 4123 void setUp() { | 3462 void setUp() { |
| 4124 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, _unit); | 3463 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, _unit); |
| 4125 } | 3464 } |
| 4126 void test_cacheResult() { | 3465 void test_cacheResult() { |
| 4127 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3466 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4128 null, | 3467 null, |
| 4129 _source, | 3468 _source, |
| 4130 "hello", | 3469 "hello", |
| 4131 "hbazlo", | 3470 "hbazlo", |
| 4132 1, | 3471 1, |
| 4133 2, | 3472 2, |
| 4134 3, | 3473 3, |
| 4135 _entry); | 3474 _entry); |
| 4136 CompilationUnit newUnit = new CompilationUnitMock(); | 3475 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4137 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); | 3476 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); |
| 4138 JUnitTestCase.assertNotNull(_result); | 3477 expect(_result, isNotNull); |
| 4139 JUnitTestCase.assertSame(_source, _result.source); | 3478 expect(_result.source, same(_source)); |
| 4140 JUnitTestCase.assertSame(newUnit, _result.resolvedUnit); | 3479 expect(_result.resolvedUnit, same(newUnit)); |
| 4141 JUnitTestCase.assertEquals("hbazlo", _result.oldContents); | 3480 expect(_result.oldContents, "hbazlo"); |
| 4142 JUnitTestCase.assertEquals("hbazlo", _result.newContents); | 3481 expect(_result.newContents, "hbazlo"); |
| 4143 JUnitTestCase.assertEquals(0, _result.offset); | 3482 expect(_result.offset, 0); |
| 4144 JUnitTestCase.assertEquals(0, _result.oldLength); | 3483 expect(_result.oldLength, 0); |
| 4145 JUnitTestCase.assertEquals(0, _result.newLength); | 3484 expect(_result.newLength, 0); |
| 4146 } | 3485 } |
| 4147 void test_cacheResult_noCache() { | 3486 void test_cacheResult_noCache() { |
| 4148 IncrementalAnalysisCache cache = null; | 3487 IncrementalAnalysisCache cache = null; |
| 4149 CompilationUnit newUnit = new CompilationUnitMock(); | 3488 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4150 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); | 3489 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); |
| 4151 JUnitTestCase.assertNull(_result); | 3490 expect(_result, isNull); |
| 4152 } | 3491 } |
| 4153 void test_cacheResult_noCacheNoResult() { | 3492 void test_cacheResult_noCacheNoResult() { |
| 4154 IncrementalAnalysisCache cache = null; | 3493 IncrementalAnalysisCache cache = null; |
| 4155 CompilationUnit newUnit = null; | 3494 CompilationUnit newUnit = null; |
| 4156 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); | 3495 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); |
| 4157 JUnitTestCase.assertNull(_result); | 3496 expect(_result, isNull); |
| 4158 } | 3497 } |
| 4159 void test_cacheResult_noResult() { | 3498 void test_cacheResult_noResult() { |
| 4160 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3499 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4161 null, | 3500 null, |
| 4162 _source, | 3501 _source, |
| 4163 "hello", | 3502 "hello", |
| 4164 "hbazlo", | 3503 "hbazlo", |
| 4165 1, | 3504 1, |
| 4166 2, | 3505 2, |
| 4167 3, | 3506 3, |
| 4168 _entry); | 3507 _entry); |
| 4169 CompilationUnit newUnit = null; | 3508 CompilationUnit newUnit = null; |
| 4170 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); | 3509 _result = IncrementalAnalysisCache.cacheResult(cache, newUnit); |
| 4171 JUnitTestCase.assertNull(_result); | 3510 expect(_result, isNull); |
| 4172 } | 3511 } |
| 4173 void test_clear_differentSource() { | 3512 void test_clear_differentSource() { |
| 4174 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3513 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4175 null, | 3514 null, |
| 4176 _source, | 3515 _source, |
| 4177 "hello", | 3516 "hello", |
| 4178 "hbazlo", | 3517 "hbazlo", |
| 4179 1, | 3518 1, |
| 4180 2, | 3519 2, |
| 4181 3, | 3520 3, |
| 4182 _entry); | 3521 _entry); |
| 4183 Source otherSource = new TestSource("blat.dart", "blat"); | 3522 Source otherSource = new TestSource("blat.dart", "blat"); |
| 4184 _result = IncrementalAnalysisCache.clear(cache, otherSource); | 3523 _result = IncrementalAnalysisCache.clear(cache, otherSource); |
| 4185 JUnitTestCase.assertSame(cache, _result); | 3524 expect(_result, same(cache)); |
| 4186 } | 3525 } |
| 4187 void test_clear_nullCache() { | 3526 void test_clear_nullCache() { |
| 4188 IncrementalAnalysisCache cache = null; | 3527 IncrementalAnalysisCache cache = null; |
| 4189 _result = IncrementalAnalysisCache.clear(cache, _source); | 3528 _result = IncrementalAnalysisCache.clear(cache, _source); |
| 4190 JUnitTestCase.assertNull(_result); | 3529 expect(_result, isNull); |
| 4191 } | 3530 } |
| 4192 void test_clear_sameSource() { | 3531 void test_clear_sameSource() { |
| 4193 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3532 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4194 null, | 3533 null, |
| 4195 _source, | 3534 _source, |
| 4196 "hello", | 3535 "hello", |
| 4197 "hbazlo", | 3536 "hbazlo", |
| 4198 1, | 3537 1, |
| 4199 2, | 3538 2, |
| 4200 3, | 3539 3, |
| 4201 _entry); | 3540 _entry); |
| 4202 _result = IncrementalAnalysisCache.clear(cache, _source); | 3541 _result = IncrementalAnalysisCache.clear(cache, _source); |
| 4203 JUnitTestCase.assertNull(_result); | 3542 expect(_result, isNull); |
| 4204 } | 3543 } |
| 4205 void test_update_append() { | 3544 void test_update_append() { |
| 4206 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3545 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4207 null, | 3546 null, |
| 4208 _source, | 3547 _source, |
| 4209 "hello", | 3548 "hello", |
| 4210 "hbazlo", | 3549 "hbazlo", |
| 4211 1, | 3550 1, |
| 4212 2, | 3551 2, |
| 4213 3, | 3552 3, |
| 4214 _entry); | 3553 _entry); |
| 4215 DartEntry newEntry = new DartEntry(); | 3554 DartEntry newEntry = new DartEntry(); |
| 4216 _result = IncrementalAnalysisCache.update( | 3555 _result = IncrementalAnalysisCache.update( |
| 4217 cache, | 3556 cache, |
| 4218 _source, | 3557 _source, |
| 4219 "hbazlo", | 3558 "hbazlo", |
| 4220 "hbazxlo", | 3559 "hbazxlo", |
| 4221 4, | 3560 4, |
| 4222 0, | 3561 0, |
| 4223 1, | 3562 1, |
| 4224 newEntry); | 3563 newEntry); |
| 4225 JUnitTestCase.assertNotNull(_result); | 3564 expect(_result, isNotNull); |
| 4226 JUnitTestCase.assertSame(_source, _result.source); | 3565 expect(_result.source, same(_source)); |
| 4227 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3566 expect(_result.resolvedUnit, same(_unit)); |
| 4228 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3567 expect(_result.oldContents, "hello"); |
| 4229 JUnitTestCase.assertEquals("hbazxlo", _result.newContents); | 3568 expect(_result.newContents, "hbazxlo"); |
| 4230 JUnitTestCase.assertEquals(1, _result.offset); | 3569 expect(_result.offset, 1); |
| 4231 JUnitTestCase.assertEquals(2, _result.oldLength); | 3570 expect(_result.oldLength, 2); |
| 4232 JUnitTestCase.assertEquals(4, _result.newLength); | 3571 expect(_result.newLength, 4); |
| 4233 } | 3572 } |
| 4234 void test_update_appendToCachedResult() { | 3573 void test_update_appendToCachedResult() { |
| 4235 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3574 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4236 null, | 3575 null, |
| 4237 _source, | 3576 _source, |
| 4238 "hello", | 3577 "hello", |
| 4239 "hbazlo", | 3578 "hbazlo", |
| 4240 1, | 3579 1, |
| 4241 2, | 3580 2, |
| 4242 3, | 3581 3, |
| 4243 _entry); | 3582 _entry); |
| 4244 CompilationUnit newUnit = new CompilationUnitMock(); | 3583 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4245 cache = IncrementalAnalysisCache.cacheResult(cache, newUnit); | 3584 cache = IncrementalAnalysisCache.cacheResult(cache, newUnit); |
| 4246 JUnitTestCase.assertNotNull(cache); | 3585 expect(cache, isNotNull); |
| 4247 DartEntry newEntry = new DartEntry(); | 3586 DartEntry newEntry = new DartEntry(); |
| 4248 _result = IncrementalAnalysisCache.update( | 3587 _result = IncrementalAnalysisCache.update( |
| 4249 cache, | 3588 cache, |
| 4250 _source, | 3589 _source, |
| 4251 "hbazlo", | 3590 "hbazlo", |
| 4252 "hbazxlo", | 3591 "hbazxlo", |
| 4253 4, | 3592 4, |
| 4254 0, | 3593 0, |
| 4255 1, | 3594 1, |
| 4256 newEntry); | 3595 newEntry); |
| 4257 JUnitTestCase.assertNotNull(_result); | 3596 expect(_result, isNotNull); |
| 4258 JUnitTestCase.assertSame(_source, _result.source); | 3597 expect(_result.source, same(_source)); |
| 4259 JUnitTestCase.assertSame(newUnit, _result.resolvedUnit); | 3598 expect(_result.resolvedUnit, same(newUnit)); |
| 4260 JUnitTestCase.assertEquals("hbazlo", _result.oldContents); | 3599 expect(_result.oldContents, "hbazlo"); |
| 4261 JUnitTestCase.assertEquals("hbazxlo", _result.newContents); | 3600 expect(_result.newContents, "hbazxlo"); |
| 4262 JUnitTestCase.assertEquals(4, _result.offset); | 3601 expect(_result.offset, 4); |
| 4263 JUnitTestCase.assertEquals(0, _result.oldLength); | 3602 expect(_result.oldLength, 0); |
| 4264 JUnitTestCase.assertEquals(1, _result.newLength); | 3603 expect(_result.newLength, 1); |
| 4265 } | 3604 } |
| 4266 void test_update_appendWithNewResolvedUnit() { | 3605 void test_update_appendWithNewResolvedUnit() { |
| 4267 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3606 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4268 null, | 3607 null, |
| 4269 _source, | 3608 _source, |
| 4270 "hello", | 3609 "hello", |
| 4271 "hbazlo", | 3610 "hbazlo", |
| 4272 1, | 3611 1, |
| 4273 2, | 3612 2, |
| 4274 3, | 3613 3, |
| 4275 _entry); | 3614 _entry); |
| 4276 DartEntry newEntry = new DartEntry(); | 3615 DartEntry newEntry = new DartEntry(); |
| 4277 CompilationUnit newUnit = new CompilationUnitMock(); | 3616 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4278 newEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, newUnit); | 3617 newEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, newUnit); |
| 4279 _result = IncrementalAnalysisCache.update( | 3618 _result = IncrementalAnalysisCache.update( |
| 4280 cache, | 3619 cache, |
| 4281 _source, | 3620 _source, |
| 4282 "hbazlo", | 3621 "hbazlo", |
| 4283 "hbazxlo", | 3622 "hbazxlo", |
| 4284 4, | 3623 4, |
| 4285 0, | 3624 0, |
| 4286 1, | 3625 1, |
| 4287 newEntry); | 3626 newEntry); |
| 4288 JUnitTestCase.assertNotNull(_result); | 3627 expect(_result, isNotNull); |
| 4289 JUnitTestCase.assertSame(_source, _result.source); | 3628 expect(_result.source, same(_source)); |
| 4290 JUnitTestCase.assertSame(newUnit, _result.resolvedUnit); | 3629 expect(_result.resolvedUnit, same(newUnit)); |
| 4291 JUnitTestCase.assertEquals("hbazlo", _result.oldContents); | 3630 expect(_result.oldContents, "hbazlo"); |
| 4292 JUnitTestCase.assertEquals("hbazxlo", _result.newContents); | 3631 expect(_result.newContents, "hbazxlo"); |
| 4293 JUnitTestCase.assertEquals(4, _result.offset); | 3632 expect(_result.offset, 4); |
| 4294 JUnitTestCase.assertEquals(0, _result.oldLength); | 3633 expect(_result.oldLength, 0); |
| 4295 JUnitTestCase.assertEquals(1, _result.newLength); | 3634 expect(_result.newLength, 1); |
| 4296 } | 3635 } |
| 4297 void test_update_appendWithNoNewResolvedUnit() { | 3636 void test_update_appendWithNoNewResolvedUnit() { |
| 4298 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3637 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4299 null, | 3638 null, |
| 4300 _source, | 3639 _source, |
| 4301 "hello", | 3640 "hello", |
| 4302 "hbazlo", | 3641 "hbazlo", |
| 4303 1, | 3642 1, |
| 4304 2, | 3643 2, |
| 4305 3, | 3644 3, |
| 4306 _entry); | 3645 _entry); |
| 4307 DartEntry newEntry = new DartEntry(); | 3646 DartEntry newEntry = new DartEntry(); |
| 4308 _result = IncrementalAnalysisCache.update( | 3647 _result = IncrementalAnalysisCache.update( |
| 4309 cache, | 3648 cache, |
| 4310 _source, | 3649 _source, |
| 4311 "hbazlo", | 3650 "hbazlo", |
| 4312 "hbazxlo", | 3651 "hbazxlo", |
| 4313 4, | 3652 4, |
| 4314 0, | 3653 0, |
| 4315 1, | 3654 1, |
| 4316 newEntry); | 3655 newEntry); |
| 4317 JUnitTestCase.assertNotNull(_result); | 3656 expect(_result, isNotNull); |
| 4318 JUnitTestCase.assertSame(_source, _result.source); | 3657 expect(_result.source, same(_source)); |
| 4319 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3658 expect(_result.resolvedUnit, same(_unit)); |
| 4320 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3659 expect(_result.oldContents, "hello"); |
| 4321 JUnitTestCase.assertEquals("hbazxlo", _result.newContents); | 3660 expect(_result.newContents, "hbazxlo"); |
| 4322 JUnitTestCase.assertEquals(1, _result.offset); | 3661 expect(_result.offset, 1); |
| 4323 JUnitTestCase.assertEquals(2, _result.oldLength); | 3662 expect(_result.oldLength, 2); |
| 4324 JUnitTestCase.assertEquals(4, _result.newLength); | 3663 expect(_result.newLength, 4); |
| 4325 } | 3664 } |
| 4326 void test_update_delete() { | 3665 void test_update_delete() { |
| 4327 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3666 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4328 null, | 3667 null, |
| 4329 _source, | 3668 _source, |
| 4330 "hello", | 3669 "hello", |
| 4331 "hbazlo", | 3670 "hbazlo", |
| 4332 1, | 3671 1, |
| 4333 2, | 3672 2, |
| 4334 3, | 3673 3, |
| 4335 _entry); | 3674 _entry); |
| 4336 DartEntry newEntry = new DartEntry(); | 3675 DartEntry newEntry = new DartEntry(); |
| 4337 _result = IncrementalAnalysisCache.update( | 3676 _result = IncrementalAnalysisCache.update( |
| 4338 cache, | 3677 cache, |
| 4339 _source, | 3678 _source, |
| 4340 "hbazlo", | 3679 "hbazlo", |
| 4341 "hzlo", | 3680 "hzlo", |
| 4342 1, | 3681 1, |
| 4343 2, | 3682 2, |
| 4344 0, | 3683 0, |
| 4345 newEntry); | 3684 newEntry); |
| 4346 JUnitTestCase.assertNotNull(_result); | 3685 expect(_result, isNotNull); |
| 4347 JUnitTestCase.assertSame(_source, _result.source); | 3686 expect(_result.source, same(_source)); |
| 4348 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3687 expect(_result.resolvedUnit, same(_unit)); |
| 4349 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3688 expect(_result.oldContents, "hello"); |
| 4350 JUnitTestCase.assertEquals("hzlo", _result.newContents); | 3689 expect(_result.newContents, "hzlo"); |
| 4351 JUnitTestCase.assertEquals(1, _result.offset); | 3690 expect(_result.offset, 1); |
| 4352 JUnitTestCase.assertEquals(2, _result.oldLength); | 3691 expect(_result.oldLength, 2); |
| 4353 JUnitTestCase.assertEquals(1, _result.newLength); | 3692 expect(_result.newLength, 1); |
| 4354 } | 3693 } |
| 4355 void test_update_insert_nonContiguous_after() { | 3694 void test_update_insert_nonContiguous_after() { |
| 4356 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3695 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4357 null, | 3696 null, |
| 4358 _source, | 3697 _source, |
| 4359 "hello", | 3698 "hello", |
| 4360 "hbazlo", | 3699 "hbazlo", |
| 4361 1, | 3700 1, |
| 4362 2, | 3701 2, |
| 4363 3, | 3702 3, |
| 4364 _entry); | 3703 _entry); |
| 4365 DartEntry newEntry = new DartEntry(); | 3704 DartEntry newEntry = new DartEntry(); |
| 4366 _result = IncrementalAnalysisCache.update( | 3705 _result = IncrementalAnalysisCache.update( |
| 4367 cache, | 3706 cache, |
| 4368 _source, | 3707 _source, |
| 4369 "hbazlo", | 3708 "hbazlo", |
| 4370 "hbazlox", | 3709 "hbazlox", |
| 4371 6, | 3710 6, |
| 4372 0, | 3711 0, |
| 4373 1, | 3712 1, |
| 4374 newEntry); | 3713 newEntry); |
| 4375 JUnitTestCase.assertNull(_result); | 3714 expect(_result, isNull); |
| 4376 } | 3715 } |
| 4377 void test_update_insert_nonContiguous_before() { | 3716 void test_update_insert_nonContiguous_before() { |
| 4378 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3717 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4379 null, | 3718 null, |
| 4380 _source, | 3719 _source, |
| 4381 "hello", | 3720 "hello", |
| 4382 "hbazlo", | 3721 "hbazlo", |
| 4383 1, | 3722 1, |
| 4384 2, | 3723 2, |
| 4385 3, | 3724 3, |
| 4386 _entry); | 3725 _entry); |
| 4387 DartEntry newEntry = new DartEntry(); | 3726 DartEntry newEntry = new DartEntry(); |
| 4388 _result = IncrementalAnalysisCache.update( | 3727 _result = IncrementalAnalysisCache.update( |
| 4389 cache, | 3728 cache, |
| 4390 _source, | 3729 _source, |
| 4391 "hbazlo", | 3730 "hbazlo", |
| 4392 "xhbazlo", | 3731 "xhbazlo", |
| 4393 0, | 3732 0, |
| 4394 0, | 3733 0, |
| 4395 1, | 3734 1, |
| 4396 newEntry); | 3735 newEntry); |
| 4397 JUnitTestCase.assertNull(_result); | 3736 expect(_result, isNull); |
| 4398 } | 3737 } |
| 4399 void test_update_newSource_entry() { | 3738 void test_update_newSource_entry() { |
| 4400 Source oldSource = new TestSource("blat.dart", "blat"); | 3739 Source oldSource = new TestSource("blat.dart", "blat"); |
| 4401 DartEntry oldEntry = new DartEntry(); | 3740 DartEntry oldEntry = new DartEntry(); |
| 4402 CompilationUnit oldUnit = new CompilationUnitMock(); | 3741 CompilationUnit oldUnit = new CompilationUnitMock(); |
| 4403 oldEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, oldUnit); | 3742 oldEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, oldUnit); |
| 4404 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3743 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4405 null, | 3744 null, |
| 4406 oldSource, | 3745 oldSource, |
| 4407 "hello", | 3746 "hello", |
| 4408 "hbazlo", | 3747 "hbazlo", |
| 4409 1, | 3748 1, |
| 4410 2, | 3749 2, |
| 4411 3, | 3750 3, |
| 4412 oldEntry); | 3751 oldEntry); |
| 4413 JUnitTestCase.assertSame(oldSource, cache.source); | 3752 expect(cache.source, same(oldSource)); |
| 4414 JUnitTestCase.assertSame(oldUnit, cache.resolvedUnit); | 3753 expect(cache.resolvedUnit, same(oldUnit)); |
| 4415 _result = IncrementalAnalysisCache.update( | 3754 _result = IncrementalAnalysisCache.update( |
| 4416 cache, | 3755 cache, |
| 4417 _source, | 3756 _source, |
| 4418 "foo", | 3757 "foo", |
| 4419 "foobz", | 3758 "foobz", |
| 4420 3, | 3759 3, |
| 4421 0, | 3760 0, |
| 4422 2, | 3761 2, |
| 4423 _entry); | 3762 _entry); |
| 4424 JUnitTestCase.assertNotNull(_result); | 3763 expect(_result, isNotNull); |
| 4425 JUnitTestCase.assertSame(_source, _result.source); | 3764 expect(_result.source, same(_source)); |
| 4426 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3765 expect(_result.resolvedUnit, same(_unit)); |
| 4427 JUnitTestCase.assertEquals("foo", _result.oldContents); | 3766 expect(_result.oldContents, "foo"); |
| 4428 JUnitTestCase.assertEquals("foobz", _result.newContents); | 3767 expect(_result.newContents, "foobz"); |
| 4429 JUnitTestCase.assertEquals(3, _result.offset); | 3768 expect(_result.offset, 3); |
| 4430 JUnitTestCase.assertEquals(0, _result.oldLength); | 3769 expect(_result.oldLength, 0); |
| 4431 JUnitTestCase.assertEquals(2, _result.newLength); | 3770 expect(_result.newLength, 2); |
| 4432 } | 3771 } |
| 4433 void test_update_newSource_noEntry() { | 3772 void test_update_newSource_noEntry() { |
| 4434 Source oldSource = new TestSource("blat.dart", "blat"); | 3773 Source oldSource = new TestSource("blat.dart", "blat"); |
| 4435 DartEntry oldEntry = new DartEntry(); | 3774 DartEntry oldEntry = new DartEntry(); |
| 4436 CompilationUnit oldUnit = new CompilationUnitMock(); | 3775 CompilationUnit oldUnit = new CompilationUnitMock(); |
| 4437 oldEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, oldUnit); | 3776 oldEntry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, oldUnit); |
| 4438 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3777 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4439 null, | 3778 null, |
| 4440 oldSource, | 3779 oldSource, |
| 4441 "hello", | 3780 "hello", |
| 4442 "hbazlo", | 3781 "hbazlo", |
| 4443 1, | 3782 1, |
| 4444 2, | 3783 2, |
| 4445 3, | 3784 3, |
| 4446 oldEntry); | 3785 oldEntry); |
| 4447 JUnitTestCase.assertSame(oldSource, cache.source); | 3786 expect(cache.source, same(oldSource)); |
| 4448 JUnitTestCase.assertSame(oldUnit, cache.resolvedUnit); | 3787 expect(cache.resolvedUnit, same(oldUnit)); |
| 4449 _result = IncrementalAnalysisCache.update( | 3788 _result = IncrementalAnalysisCache.update( |
| 4450 cache, | 3789 cache, |
| 4451 _source, | 3790 _source, |
| 4452 "foo", | 3791 "foo", |
| 4453 "foobar", | 3792 "foobar", |
| 4454 3, | 3793 3, |
| 4455 0, | 3794 0, |
| 4456 3, | 3795 3, |
| 4457 null); | 3796 null); |
| 4458 JUnitTestCase.assertNull(_result); | 3797 expect(_result, isNull); |
| 4459 } | 3798 } |
| 4460 void test_update_noCache_entry() { | 3799 void test_update_noCache_entry() { |
| 4461 _result = IncrementalAnalysisCache.update( | 3800 _result = IncrementalAnalysisCache.update( |
| 4462 null, | 3801 null, |
| 4463 _source, | 3802 _source, |
| 4464 "hello", | 3803 "hello", |
| 4465 "hbazlo", | 3804 "hbazlo", |
| 4466 1, | 3805 1, |
| 4467 2, | 3806 2, |
| 4468 3, | 3807 3, |
| 4469 _entry); | 3808 _entry); |
| 4470 JUnitTestCase.assertNotNull(_result); | 3809 expect(_result, isNotNull); |
| 4471 JUnitTestCase.assertSame(_source, _result.source); | 3810 expect(_result.source, same(_source)); |
| 4472 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3811 expect(_result.resolvedUnit, same(_unit)); |
| 4473 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3812 expect(_result.oldContents, "hello"); |
| 4474 JUnitTestCase.assertEquals("hbazlo", _result.newContents); | 3813 expect(_result.newContents, "hbazlo"); |
| 4475 JUnitTestCase.assertEquals(1, _result.offset); | 3814 expect(_result.offset, 1); |
| 4476 JUnitTestCase.assertEquals(2, _result.oldLength); | 3815 expect(_result.oldLength, 2); |
| 4477 JUnitTestCase.assertEquals(3, _result.newLength); | 3816 expect(_result.newLength, 3); |
| 4478 JUnitTestCase.assertTrue(_result.hasWork); | 3817 expect(_result.hasWork, isTrue); |
| 4479 } | 3818 } |
| 4480 void test_update_noCache_entry_noOldSource_append() { | 3819 void test_update_noCache_entry_noOldSource_append() { |
| 4481 _result = IncrementalAnalysisCache.update( | 3820 _result = IncrementalAnalysisCache.update( |
| 4482 null, | 3821 null, |
| 4483 _source, | 3822 _source, |
| 4484 null, | 3823 null, |
| 4485 "hellxo", | 3824 "hellxo", |
| 4486 4, | 3825 4, |
| 4487 0, | 3826 0, |
| 4488 1, | 3827 1, |
| 4489 _entry); | 3828 _entry); |
| 4490 JUnitTestCase.assertNotNull(_result); | 3829 expect(_result, isNotNull); |
| 4491 JUnitTestCase.assertSame(_source, _result.source); | 3830 expect(_result.source, same(_source)); |
| 4492 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3831 expect(_result.resolvedUnit, same(_unit)); |
| 4493 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3832 expect(_result.oldContents, "hello"); |
| 4494 JUnitTestCase.assertEquals("hellxo", _result.newContents); | 3833 expect(_result.newContents, "hellxo"); |
| 4495 JUnitTestCase.assertEquals(4, _result.offset); | 3834 expect(_result.offset, 4); |
| 4496 JUnitTestCase.assertEquals(0, _result.oldLength); | 3835 expect(_result.oldLength, 0); |
| 4497 JUnitTestCase.assertEquals(1, _result.newLength); | 3836 expect(_result.newLength, 1); |
| 4498 JUnitTestCase.assertTrue(_result.hasWork); | 3837 expect(_result.hasWork, isTrue); |
| 4499 } | 3838 } |
| 4500 void test_update_noCache_entry_noOldSource_delete() { | 3839 void test_update_noCache_entry_noOldSource_delete() { |
| 4501 _result = | 3840 _result = |
| 4502 IncrementalAnalysisCache.update(null, _source, null, "helo", 4, 1, 0, _e
ntry); | 3841 IncrementalAnalysisCache.update(null, _source, null, "helo", 4, 1, 0, _e
ntry); |
| 4503 JUnitTestCase.assertNull(_result); | 3842 expect(_result, isNull); |
| 4504 } | 3843 } |
| 4505 void test_update_noCache_entry_noOldSource_replace() { | 3844 void test_update_noCache_entry_noOldSource_replace() { |
| 4506 _result = | 3845 _result = |
| 4507 IncrementalAnalysisCache.update(null, _source, null, "helxo", 4, 1, 1, _
entry); | 3846 IncrementalAnalysisCache.update(null, _source, null, "helxo", 4, 1, 1, _
entry); |
| 4508 JUnitTestCase.assertNull(_result); | 3847 expect(_result, isNull); |
| 4509 } | 3848 } |
| 4510 void test_update_noCache_noEntry() { | 3849 void test_update_noCache_noEntry() { |
| 4511 _result = IncrementalAnalysisCache.update( | 3850 _result = IncrementalAnalysisCache.update( |
| 4512 null, | 3851 null, |
| 4513 _source, | 3852 _source, |
| 4514 "hello", | 3853 "hello", |
| 4515 "hbazlo", | 3854 "hbazlo", |
| 4516 1, | 3855 1, |
| 4517 2, | 3856 2, |
| 4518 3, | 3857 3, |
| 4519 null); | 3858 null); |
| 4520 JUnitTestCase.assertNull(_result); | 3859 expect(_result, isNull); |
| 4521 } | 3860 } |
| 4522 void test_update_replace() { | 3861 void test_update_replace() { |
| 4523 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3862 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4524 null, | 3863 null, |
| 4525 _source, | 3864 _source, |
| 4526 "hello", | 3865 "hello", |
| 4527 "hbazlo", | 3866 "hbazlo", |
| 4528 1, | 3867 1, |
| 4529 2, | 3868 2, |
| 4530 3, | 3869 3, |
| 4531 _entry); | 3870 _entry); |
| 4532 _result = IncrementalAnalysisCache.update( | 3871 _result = IncrementalAnalysisCache.update( |
| 4533 cache, | 3872 cache, |
| 4534 _source, | 3873 _source, |
| 4535 "hbazlo", | 3874 "hbazlo", |
| 4536 "hbarrlo", | 3875 "hbarrlo", |
| 4537 3, | 3876 3, |
| 4538 1, | 3877 1, |
| 4539 2, | 3878 2, |
| 4540 null); | 3879 null); |
| 4541 JUnitTestCase.assertNotNull(_result); | 3880 expect(_result, isNotNull); |
| 4542 JUnitTestCase.assertSame(_source, _result.source); | 3881 expect(_result.source, same(_source)); |
| 4543 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3882 expect(_result.resolvedUnit, same(_unit)); |
| 4544 JUnitTestCase.assertEquals("hello", _result.oldContents); | 3883 expect(_result.oldContents, "hello"); |
| 4545 JUnitTestCase.assertEquals("hbarrlo", _result.newContents); | 3884 expect(_result.newContents, "hbarrlo"); |
| 4546 JUnitTestCase.assertEquals(1, _result.offset); | 3885 expect(_result.offset, 1); |
| 4547 JUnitTestCase.assertEquals(2, _result.oldLength); | 3886 expect(_result.oldLength, 2); |
| 4548 JUnitTestCase.assertEquals(4, _result.newLength); | 3887 expect(_result.newLength, 4); |
| 4549 } | 3888 } |
| 4550 void test_verifyStructure_invalidUnit() { | 3889 void test_verifyStructure_invalidUnit() { |
| 4551 String oldCode = "main() {foo;}"; | 3890 String oldCode = "main() {foo;}"; |
| 4552 String newCode = "main() {boo;}"; | 3891 String newCode = "main() {boo;}"; |
| 4553 CompilationUnit badUnit = _parse("main() {bad;}"); | 3892 CompilationUnit badUnit = _parse("main() {bad;}"); |
| 4554 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, badUnit); | 3893 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, badUnit); |
| 4555 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3894 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4556 null, | 3895 null, |
| 4557 _source, | 3896 _source, |
| 4558 oldCode, | 3897 oldCode, |
| 4559 newCode, | 3898 newCode, |
| 4560 8, | 3899 8, |
| 4561 1, | 3900 1, |
| 4562 1, | 3901 1, |
| 4563 _entry); | 3902 _entry); |
| 4564 CompilationUnit newUnit = _parse(newCode); | 3903 CompilationUnit newUnit = _parse(newCode); |
| 4565 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); | 3904 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); |
| 4566 JUnitTestCase.assertNull(_result); | 3905 expect(_result, isNull); |
| 4567 } | 3906 } |
| 4568 void test_verifyStructure_noCache() { | 3907 void test_verifyStructure_noCache() { |
| 4569 IncrementalAnalysisCache cache = null; | 3908 IncrementalAnalysisCache cache = null; |
| 4570 CompilationUnit newUnit = new CompilationUnitMock(); | 3909 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4571 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); | 3910 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); |
| 4572 JUnitTestCase.assertNull(_result); | 3911 expect(_result, isNull); |
| 4573 } | 3912 } |
| 4574 void test_verifyStructure_noCacheNoUnit() { | 3913 void test_verifyStructure_noCacheNoUnit() { |
| 4575 IncrementalAnalysisCache cache = null; | 3914 IncrementalAnalysisCache cache = null; |
| 4576 CompilationUnit newUnit = null; | 3915 CompilationUnit newUnit = null; |
| 4577 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); | 3916 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); |
| 4578 JUnitTestCase.assertNull(_result); | 3917 expect(_result, isNull); |
| 4579 } | 3918 } |
| 4580 void test_verifyStructure_noUnit() { | 3919 void test_verifyStructure_noUnit() { |
| 4581 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3920 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4582 null, | 3921 null, |
| 4583 _source, | 3922 _source, |
| 4584 "hello", | 3923 "hello", |
| 4585 "hbazlo", | 3924 "hbazlo", |
| 4586 1, | 3925 1, |
| 4587 2, | 3926 2, |
| 4588 3, | 3927 3, |
| 4589 _entry); | 3928 _entry); |
| 4590 CompilationUnit newUnit = null; | 3929 CompilationUnit newUnit = null; |
| 4591 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); | 3930 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); |
| 4592 JUnitTestCase.assertSame(cache, _result); | 3931 expect(_result, same(cache)); |
| 4593 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3932 expect(_result.resolvedUnit, same(_unit)); |
| 4594 } | 3933 } |
| 4595 void test_verifyStructure_otherSource() { | 3934 void test_verifyStructure_otherSource() { |
| 4596 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3935 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4597 null, | 3936 null, |
| 4598 _source, | 3937 _source, |
| 4599 "hello", | 3938 "hello", |
| 4600 "hbazlo", | 3939 "hbazlo", |
| 4601 1, | 3940 1, |
| 4602 2, | 3941 2, |
| 4603 3, | 3942 3, |
| 4604 _entry); | 3943 _entry); |
| 4605 CompilationUnit newUnit = new CompilationUnitMock(); | 3944 CompilationUnit newUnit = new CompilationUnitMock(); |
| 4606 Source otherSource = new TestSource("blat.dart", "blat"); | 3945 Source otherSource = new TestSource("blat.dart", "blat"); |
| 4607 _result = | 3946 _result = |
| 4608 IncrementalAnalysisCache.verifyStructure(cache, otherSource, newUnit); | 3947 IncrementalAnalysisCache.verifyStructure(cache, otherSource, newUnit); |
| 4609 JUnitTestCase.assertSame(cache, _result); | 3948 expect(_result, same(cache)); |
| 4610 JUnitTestCase.assertSame(_unit, _result.resolvedUnit); | 3949 expect(_result.resolvedUnit, same(_unit)); |
| 4611 } | 3950 } |
| 4612 void test_verifyStructure_validUnit() { | 3951 void test_verifyStructure_validUnit() { |
| 4613 String oldCode = "main() {foo;}"; | 3952 String oldCode = "main() {foo;}"; |
| 4614 String newCode = "main() {boo;}"; | 3953 String newCode = "main() {boo;}"; |
| 4615 CompilationUnit goodUnit = _parse(newCode); | 3954 CompilationUnit goodUnit = _parse(newCode); |
| 4616 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, goodUnit); | 3955 _entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, _source, goodUnit); |
| 4617 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 3956 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4618 null, | 3957 null, |
| 4619 _source, | 3958 _source, |
| 4620 oldCode, | 3959 oldCode, |
| 4621 newCode, | 3960 newCode, |
| 4622 1, | 3961 1, |
| 4623 2, | 3962 2, |
| 4624 3, | 3963 3, |
| 4625 _entry); | 3964 _entry); |
| 4626 CompilationUnit newUnit = _parse(newCode); | 3965 CompilationUnit newUnit = _parse(newCode); |
| 4627 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); | 3966 _result = IncrementalAnalysisCache.verifyStructure(cache, _source, newUnit); |
| 4628 JUnitTestCase.assertSame(cache, _result); | 3967 expect(_result, same(cache)); |
| 4629 JUnitTestCase.assertSame(goodUnit, _result.resolvedUnit); | 3968 expect(_result.resolvedUnit, same(goodUnit)); |
| 4630 } | 3969 } |
| 4631 CompilationUnit _parse(String code) { | 3970 CompilationUnit _parse(String code) { |
| 4632 Scanner scanner = new Scanner( | 3971 Scanner scanner = new Scanner( |
| 4633 _source, | 3972 _source, |
| 4634 new CharSequenceReader(code), | 3973 new CharSequenceReader(code), |
| 4635 AnalysisErrorListener.NULL_LISTENER); | 3974 AnalysisErrorListener.NULL_LISTENER); |
| 4636 Parser parser = new Parser(_source, AnalysisErrorListener.NULL_LISTENER); | 3975 Parser parser = new Parser(_source, AnalysisErrorListener.NULL_LISTENER); |
| 4637 return parser.parseCompilationUnit(scanner.tokenize()); | 3976 return parser.parseCompilationUnit(scanner.tokenize()); |
| 4638 } | 3977 } |
| 4639 } | 3978 } |
| 4640 | 3979 |
| 4641 | 3980 |
| 4642 | 3981 |
| 4643 class IncrementalAnalysisTaskTest extends EngineTestCase { | 3982 class IncrementalAnalysisTaskTest extends EngineTestCase { |
| 4644 void test_accept() { | 3983 void test_accept() { |
| 4645 IncrementalAnalysisTask task = new IncrementalAnalysisTask(null, null); | 3984 IncrementalAnalysisTask task = new IncrementalAnalysisTask(null, null); |
| 4646 JUnitTestCase.assertTrue( | 3985 expect(task.accept(new IncrementalAnalysisTaskTestTV_accept()), isTrue); |
| 4647 task.accept(new IncrementalAnalysisTaskTestTV_accept())); | |
| 4648 } | 3986 } |
| 4649 | 3987 |
| 4650 void test_perform() { | 3988 void test_perform() { |
| 4651 // main() {} String foo; | 3989 // main() {} String foo; |
| 4652 // main() {String} String foo; | 3990 // main() {String} String foo; |
| 4653 CompilationUnit newUnit = | 3991 CompilationUnit newUnit = |
| 4654 _assertTask("main() {", "", "String", "} String foo;"); | 3992 _assertTask("main() {", "", "String", "} String foo;"); |
| 4655 NodeList<CompilationUnitMember> declarations = newUnit.declarations; | 3993 NodeList<CompilationUnitMember> declarations = newUnit.declarations; |
| 4656 FunctionDeclaration main = declarations[0] as FunctionDeclaration; | 3994 FunctionDeclaration main = declarations[0] as FunctionDeclaration; |
| 4657 JUnitTestCase.assertEquals("main", main.name.name); | 3995 expect(main.name.name, "main"); |
| 4658 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; | 3996 BlockFunctionBody body = main.functionExpression.body as BlockFunctionBody; |
| 4659 ExpressionStatement statement = | 3997 ExpressionStatement statement = |
| 4660 body.block.statements[0] as ExpressionStatement; | 3998 body.block.statements[0] as ExpressionStatement; |
| 4661 JUnitTestCase.assertEquals("String;", statement.toSource()); | 3999 expect(statement.toSource(), "String;"); |
| 4662 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; | 4000 SimpleIdentifier identifier = statement.expression as SimpleIdentifier; |
| 4663 JUnitTestCase.assertEquals("String", identifier.name); | 4001 expect(identifier.name, "String"); |
| 4664 JUnitTestCase.assertNotNull(identifier.staticElement); | 4002 expect(identifier.staticElement, isNotNull); |
| 4665 TopLevelVariableDeclaration fooDecl = | 4003 TopLevelVariableDeclaration fooDecl = |
| 4666 declarations[1] as TopLevelVariableDeclaration; | 4004 declarations[1] as TopLevelVariableDeclaration; |
| 4667 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; | 4005 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; |
| 4668 JUnitTestCase.assertEquals("foo", fooName.name); | 4006 expect(fooName.name, "foo"); |
| 4669 JUnitTestCase.assertNotNull(fooName.staticElement); | 4007 expect(fooName.staticElement, isNotNull); |
| 4670 // assert element reference is preserved | 4008 // assert element reference is preserved |
| 4671 } | 4009 } |
| 4672 | 4010 |
| 4673 CompilationUnit _assertTask(String prefix, String removed, String added, | 4011 CompilationUnit _assertTask(String prefix, String removed, String added, |
| 4674 String suffix) { | 4012 String suffix) { |
| 4675 String oldCode = "$prefix$removed$suffix"; | 4013 String oldCode = "$prefix$removed$suffix"; |
| 4676 String newCode = "$prefix$added$suffix"; | 4014 String newCode = "$prefix$added$suffix"; |
| 4677 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4015 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 4678 Source source = new TestSource("/test.dart", oldCode); | 4016 Source source = new TestSource("/test.dart", oldCode); |
| 4679 DartEntry entry = new DartEntry(); | 4017 DartEntry entry = new DartEntry(); |
| 4680 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); | 4018 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); |
| 4681 JUnitTestCase.assertNotNull(oldUnit); | 4019 expect(oldUnit, isNotNull); |
| 4682 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); | 4020 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); |
| 4683 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 4021 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4684 null, | 4022 null, |
| 4685 source, | 4023 source, |
| 4686 oldCode, | 4024 oldCode, |
| 4687 newCode, | 4025 newCode, |
| 4688 prefix.length, | 4026 prefix.length, |
| 4689 removed.length, | 4027 removed.length, |
| 4690 added.length, | 4028 added.length, |
| 4691 entry); | 4029 entry); |
| 4692 JUnitTestCase.assertNotNull(cache); | 4030 expect(cache, isNotNull); |
| 4693 IncrementalAnalysisTask task = new IncrementalAnalysisTask(context, cache); | 4031 IncrementalAnalysisTask task = new IncrementalAnalysisTask(context, cache); |
| 4694 CompilationUnit newUnit = | 4032 CompilationUnit newUnit = |
| 4695 task.perform(new IncrementalAnalysisTaskTestTV_assertTask(task)); | 4033 task.perform(new IncrementalAnalysisTaskTestTV_assertTask(task)); |
| 4696 JUnitTestCase.assertNotNull(newUnit); | 4034 expect(newUnit, isNotNull); |
| 4697 return newUnit; | 4035 return newUnit; |
| 4698 } | 4036 } |
| 4699 } | 4037 } |
| 4700 | 4038 |
| 4701 | 4039 |
| 4702 class IncrementalAnalysisTaskTestTV_accept extends TestTaskVisitor<bool> { | 4040 class IncrementalAnalysisTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 4703 @override | 4041 @override |
| 4704 bool visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => true; | 4042 bool visitIncrementalAnalysisTask(IncrementalAnalysisTask task) => true; |
| 4705 } | 4043 } |
| 4706 | 4044 |
| 4707 | 4045 |
| 4708 class IncrementalAnalysisTaskTestTV_assertTask extends | 4046 class IncrementalAnalysisTaskTestTV_assertTask extends |
| 4709 TestTaskVisitor<CompilationUnit> { | 4047 TestTaskVisitor<CompilationUnit> { |
| 4710 IncrementalAnalysisTask task; | 4048 IncrementalAnalysisTask task; |
| 4711 IncrementalAnalysisTaskTestTV_assertTask(this.task); | 4049 IncrementalAnalysisTaskTestTV_assertTask(this.task); |
| 4712 @override | 4050 @override |
| 4713 CompilationUnit | 4051 CompilationUnit |
| 4714 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) => | 4052 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) => |
| 4715 task.compilationUnit; | 4053 task.compilationUnit; |
| 4716 } | 4054 } |
| 4717 | 4055 |
| 4718 | 4056 |
| 4719 class InstrumentedAnalysisContextImplTest extends EngineTestCase { | 4057 class InstrumentedAnalysisContextImplTest extends EngineTestCase { |
| 4720 void test_addSourceInfo() { | 4058 void test_addSourceInfo() { |
| 4721 List<bool> invoked = [false]; | 4059 List<bool> invoked = [false]; |
| 4722 InstrumentedAnalysisContextImpl context = | 4060 InstrumentedAnalysisContextImpl context = |
| 4723 new InstrumentedAnalysisContextImpl.con1( | 4061 new InstrumentedAnalysisContextImpl.con1( |
| 4724 new TestAnalysisContext_test_addSourceInfo(invoked)); | 4062 new TestAnalysisContext_test_addSourceInfo(invoked)); |
| 4725 context.addSourceInfo(null, null); | 4063 context.addSourceInfo(null, null); |
| 4726 JUnitTestCase.assertTrue(invoked[0]); | 4064 expect(invoked[0], isTrue); |
| 4727 } | 4065 } |
| 4728 | 4066 |
| 4729 void test_applyChanges() { | 4067 void test_applyChanges() { |
| 4730 List<bool> invoked = [false]; | 4068 List<bool> invoked = [false]; |
| 4731 InstrumentedAnalysisContextImpl context = | 4069 InstrumentedAnalysisContextImpl context = |
| 4732 new InstrumentedAnalysisContextImpl.con1( | 4070 new InstrumentedAnalysisContextImpl.con1( |
| 4733 new TestAnalysisContext_test_applyChanges(invoked)); | 4071 new TestAnalysisContext_test_applyChanges(invoked)); |
| 4734 context.applyChanges(null); | 4072 context.applyChanges(null); |
| 4735 JUnitTestCase.assertTrue(invoked[0]); | 4073 expect(invoked[0], isTrue); |
| 4736 } | 4074 } |
| 4737 | 4075 |
| 4738 void test_computeDocumentationComment() { | 4076 void test_computeDocumentationComment() { |
| 4739 List<bool> invoked = [false]; | 4077 List<bool> invoked = [false]; |
| 4740 InstrumentedAnalysisContextImpl context = | 4078 InstrumentedAnalysisContextImpl context = |
| 4741 new InstrumentedAnalysisContextImpl.con1( | 4079 new InstrumentedAnalysisContextImpl.con1( |
| 4742 new TestAnalysisContext_test_computeDocumentationComment(invoked)); | 4080 new TestAnalysisContext_test_computeDocumentationComment(invoked)); |
| 4743 context.computeDocumentationComment(null); | 4081 context.computeDocumentationComment(null); |
| 4744 JUnitTestCase.assertTrue(invoked[0]); | 4082 expect(invoked[0], isTrue); |
| 4745 } | 4083 } |
| 4746 | 4084 |
| 4747 void test_computeErrors() { | 4085 void test_computeErrors() { |
| 4748 List<bool> invoked = [false]; | 4086 List<bool> invoked = [false]; |
| 4749 InstrumentedAnalysisContextImpl context = | 4087 InstrumentedAnalysisContextImpl context = |
| 4750 new InstrumentedAnalysisContextImpl.con1( | 4088 new InstrumentedAnalysisContextImpl.con1( |
| 4751 new TestAnalysisContext_test_computeErrors(invoked)); | 4089 new TestAnalysisContext_test_computeErrors(invoked)); |
| 4752 context.computeErrors(null); | 4090 context.computeErrors(null); |
| 4753 JUnitTestCase.assertTrue(invoked[0]); | 4091 expect(invoked[0], isTrue); |
| 4754 } | 4092 } |
| 4755 | 4093 |
| 4756 void test_computeExportedLibraries() { | 4094 void test_computeExportedLibraries() { |
| 4757 List<bool> invoked = [false]; | 4095 List<bool> invoked = [false]; |
| 4758 InstrumentedAnalysisContextImpl context = | 4096 InstrumentedAnalysisContextImpl context = |
| 4759 new InstrumentedAnalysisContextImpl.con1( | 4097 new InstrumentedAnalysisContextImpl.con1( |
| 4760 new TestAnalysisContext_test_computeExportedLibraries(invoked)); | 4098 new TestAnalysisContext_test_computeExportedLibraries(invoked)); |
| 4761 context.computeExportedLibraries(null); | 4099 context.computeExportedLibraries(null); |
| 4762 JUnitTestCase.assertTrue(invoked[0]); | 4100 expect(invoked[0], isTrue); |
| 4763 } | 4101 } |
| 4764 | 4102 |
| 4765 void test_computeHtmlElement() { | 4103 void test_computeHtmlElement() { |
| 4766 List<bool> invoked = [false]; | 4104 List<bool> invoked = [false]; |
| 4767 InstrumentedAnalysisContextImpl context = | 4105 InstrumentedAnalysisContextImpl context = |
| 4768 new InstrumentedAnalysisContextImpl.con1( | 4106 new InstrumentedAnalysisContextImpl.con1( |
| 4769 new TestAnalysisContext_test_computeHtmlElement(invoked)); | 4107 new TestAnalysisContext_test_computeHtmlElement(invoked)); |
| 4770 context.computeHtmlElement(null); | 4108 context.computeHtmlElement(null); |
| 4771 JUnitTestCase.assertTrue(invoked[0]); | 4109 expect(invoked[0], isTrue); |
| 4772 } | 4110 } |
| 4773 | 4111 |
| 4774 void test_computeImportedLibraries() { | 4112 void test_computeImportedLibraries() { |
| 4775 List<bool> invoked = [false]; | 4113 List<bool> invoked = [false]; |
| 4776 InstrumentedAnalysisContextImpl context = | 4114 InstrumentedAnalysisContextImpl context = |
| 4777 new InstrumentedAnalysisContextImpl.con1( | 4115 new InstrumentedAnalysisContextImpl.con1( |
| 4778 new TestAnalysisContext_test_computeImportedLibraries(invoked)); | 4116 new TestAnalysisContext_test_computeImportedLibraries(invoked)); |
| 4779 context.computeImportedLibraries(null); | 4117 context.computeImportedLibraries(null); |
| 4780 JUnitTestCase.assertTrue(invoked[0]); | 4118 expect(invoked[0], isTrue); |
| 4781 } | 4119 } |
| 4782 | 4120 |
| 4783 void test_computeKindOf() { | 4121 void test_computeKindOf() { |
| 4784 List<bool> invoked = [false]; | 4122 List<bool> invoked = [false]; |
| 4785 InstrumentedAnalysisContextImpl context = | 4123 InstrumentedAnalysisContextImpl context = |
| 4786 new InstrumentedAnalysisContextImpl.con1( | 4124 new InstrumentedAnalysisContextImpl.con1( |
| 4787 new TestAnalysisContext_test_computeKindOf(invoked)); | 4125 new TestAnalysisContext_test_computeKindOf(invoked)); |
| 4788 context.computeKindOf(null); | 4126 context.computeKindOf(null); |
| 4789 JUnitTestCase.assertTrue(invoked[0]); | 4127 expect(invoked[0], isTrue); |
| 4790 } | 4128 } |
| 4791 | 4129 |
| 4792 void test_computeLibraryElement() { | 4130 void test_computeLibraryElement() { |
| 4793 List<bool> invoked = [false]; | 4131 List<bool> invoked = [false]; |
| 4794 InstrumentedAnalysisContextImpl context = | 4132 InstrumentedAnalysisContextImpl context = |
| 4795 new InstrumentedAnalysisContextImpl.con1( | 4133 new InstrumentedAnalysisContextImpl.con1( |
| 4796 new TestAnalysisContext_test_computeLibraryElement(invoked)); | 4134 new TestAnalysisContext_test_computeLibraryElement(invoked)); |
| 4797 context.computeLibraryElement(null); | 4135 context.computeLibraryElement(null); |
| 4798 JUnitTestCase.assertTrue(invoked[0]); | 4136 expect(invoked[0], isTrue); |
| 4799 } | 4137 } |
| 4800 | 4138 |
| 4801 void test_computeLineInfo() { | 4139 void test_computeLineInfo() { |
| 4802 List<bool> invoked = [false]; | 4140 List<bool> invoked = [false]; |
| 4803 InstrumentedAnalysisContextImpl context = | 4141 InstrumentedAnalysisContextImpl context = |
| 4804 new InstrumentedAnalysisContextImpl.con1( | 4142 new InstrumentedAnalysisContextImpl.con1( |
| 4805 new TestAnalysisContext_test_computeLineInfo(invoked)); | 4143 new TestAnalysisContext_test_computeLineInfo(invoked)); |
| 4806 context.computeLineInfo(null); | 4144 context.computeLineInfo(null); |
| 4807 JUnitTestCase.assertTrue(invoked[0]); | 4145 expect(invoked[0], isTrue); |
| 4808 } | 4146 } |
| 4809 | 4147 |
| 4810 void test_computeResolvableCompilationUnit() { | 4148 void test_computeResolvableCompilationUnit() { |
| 4811 List<bool> invoked = [false]; | 4149 List<bool> invoked = [false]; |
| 4812 InstrumentedAnalysisContextImpl context = | 4150 InstrumentedAnalysisContextImpl context = |
| 4813 new InstrumentedAnalysisContextImpl.con1( | 4151 new InstrumentedAnalysisContextImpl.con1( |
| 4814 new TestAnalysisContext_test_computeResolvableCompilationUnit(invoke
d)); | 4152 new TestAnalysisContext_test_computeResolvableCompilationUnit(invoke
d)); |
| 4815 context.computeResolvableCompilationUnit(null); | 4153 context.computeResolvableCompilationUnit(null); |
| 4816 JUnitTestCase.assertTrue(invoked[0]); | 4154 expect(invoked[0], isTrue); |
| 4817 } | 4155 } |
| 4818 | 4156 |
| 4819 void test_creation() { | 4157 void test_creation() { |
| 4820 JUnitTestCase.assertNotNull(new InstrumentedAnalysisContextImpl()); | 4158 expect(new InstrumentedAnalysisContextImpl(), isNotNull); |
| 4821 } | 4159 } |
| 4822 | 4160 |
| 4823 void test_dispose() { | 4161 void test_dispose() { |
| 4824 List<bool> invoked = [false]; | 4162 List<bool> invoked = [false]; |
| 4825 InstrumentedAnalysisContextImpl context = | 4163 InstrumentedAnalysisContextImpl context = |
| 4826 new InstrumentedAnalysisContextImpl.con1( | 4164 new InstrumentedAnalysisContextImpl.con1( |
| 4827 new TestAnalysisContext_test_dispose(invoked)); | 4165 new TestAnalysisContext_test_dispose(invoked)); |
| 4828 context.dispose(); | 4166 context.dispose(); |
| 4829 JUnitTestCase.assertTrue(invoked[0]); | 4167 expect(invoked[0], isTrue); |
| 4830 } | 4168 } |
| 4831 | 4169 |
| 4832 void test_exists() { | 4170 void test_exists() { |
| 4833 List<bool> invoked = [false]; | 4171 List<bool> invoked = [false]; |
| 4834 InstrumentedAnalysisContextImpl context = | 4172 InstrumentedAnalysisContextImpl context = |
| 4835 new InstrumentedAnalysisContextImpl.con1( | 4173 new InstrumentedAnalysisContextImpl.con1( |
| 4836 new TestAnalysisContext_test_exists(invoked)); | 4174 new TestAnalysisContext_test_exists(invoked)); |
| 4837 context.exists(null); | 4175 context.exists(null); |
| 4838 JUnitTestCase.assertTrue(invoked[0]); | 4176 expect(invoked[0], isTrue); |
| 4839 } | 4177 } |
| 4840 | 4178 |
| 4841 void test_getAnalysisOptions() { | 4179 void test_getAnalysisOptions() { |
| 4842 List<bool> invoked = [false]; | 4180 List<bool> invoked = [false]; |
| 4843 InstrumentedAnalysisContextImpl context = | 4181 InstrumentedAnalysisContextImpl context = |
| 4844 new InstrumentedAnalysisContextImpl.con1( | 4182 new InstrumentedAnalysisContextImpl.con1( |
| 4845 new TestAnalysisContext_test_getAnalysisOptions(invoked)); | 4183 new TestAnalysisContext_test_getAnalysisOptions(invoked)); |
| 4846 context.analysisOptions; | 4184 context.analysisOptions; |
| 4847 JUnitTestCase.assertTrue(invoked[0]); | 4185 expect(invoked[0], isTrue); |
| 4848 } | 4186 } |
| 4849 | 4187 |
| 4850 void test_getAngularApplicationWithHtml() { | 4188 void test_getAngularApplicationWithHtml() { |
| 4851 List<bool> invoked = [false]; | 4189 List<bool> invoked = [false]; |
| 4852 InstrumentedAnalysisContextImpl context = | 4190 InstrumentedAnalysisContextImpl context = |
| 4853 new InstrumentedAnalysisContextImpl.con1( | 4191 new InstrumentedAnalysisContextImpl.con1( |
| 4854 new TestAnalysisContext_test_getAngularApplicationWithHtml(invoked))
; | 4192 new TestAnalysisContext_test_getAngularApplicationWithHtml(invoked))
; |
| 4855 context.getAngularApplicationWithHtml(null); | 4193 context.getAngularApplicationWithHtml(null); |
| 4856 JUnitTestCase.assertTrue(invoked[0]); | 4194 expect(invoked[0], isTrue); |
| 4857 } | 4195 } |
| 4858 | 4196 |
| 4859 void test_getCompilationUnitElement() { | 4197 void test_getCompilationUnitElement() { |
| 4860 List<bool> invoked = [false]; | 4198 List<bool> invoked = [false]; |
| 4861 InstrumentedAnalysisContextImpl context = | 4199 InstrumentedAnalysisContextImpl context = |
| 4862 new InstrumentedAnalysisContextImpl.con1( | 4200 new InstrumentedAnalysisContextImpl.con1( |
| 4863 new TestAnalysisContext_test_getCompilationUnitElement(invoked)); | 4201 new TestAnalysisContext_test_getCompilationUnitElement(invoked)); |
| 4864 context.getCompilationUnitElement(null, null); | 4202 context.getCompilationUnitElement(null, null); |
| 4865 JUnitTestCase.assertTrue(invoked[0]); | 4203 expect(invoked[0], isTrue); |
| 4866 } | 4204 } |
| 4867 | 4205 |
| 4868 void test_getContents() { | 4206 void test_getContents() { |
| 4869 List<bool> invoked = [false]; | 4207 List<bool> invoked = [false]; |
| 4870 InstrumentedAnalysisContextImpl context = | 4208 InstrumentedAnalysisContextImpl context = |
| 4871 new InstrumentedAnalysisContextImpl.con1( | 4209 new InstrumentedAnalysisContextImpl.con1( |
| 4872 new TestAnalysisContext_test_getContents(invoked)); | 4210 new TestAnalysisContext_test_getContents(invoked)); |
| 4873 context.getContents(null); | 4211 context.getContents(null); |
| 4874 JUnitTestCase.assertTrue(invoked[0]); | 4212 expect(invoked[0], isTrue); |
| 4875 } | 4213 } |
| 4876 | 4214 |
| 4877 // void test_getContentsToReceiver() { | 4215 // void test_getContentsToReceiver() { |
| 4878 // List<bool> invoked = [false]; | 4216 // List<bool> invoked = [false]; |
| 4879 // InstrumentedAnalysisContextImpl context = new InstrumentedAnalysisContextI
mpl.con1(new TestAnalysisContext_test_getContentsToReceiver(invoked)); | 4217 // InstrumentedAnalysisContextImpl context = new InstrumentedAnalysisContextI
mpl.con1(new TestAnalysisContext_test_getContentsToReceiver(invoked)); |
| 4880 // context.getContentsToReceiver(null, null); | 4218 // context.getContentsToReceiver(null, null); |
| 4881 // JUnitTestCase.assertTrue(invoked[0]); | 4219 // JUnitTestCase.assertTrue(invoked[0]); |
| 4882 // } | 4220 // } |
| 4883 | 4221 |
| 4884 void test_getElement() { | 4222 void test_getElement() { |
| 4885 List<bool> invoked = [false]; | 4223 List<bool> invoked = [false]; |
| 4886 InstrumentedAnalysisContextImpl context = | 4224 InstrumentedAnalysisContextImpl context = |
| 4887 new InstrumentedAnalysisContextImpl.con1( | 4225 new InstrumentedAnalysisContextImpl.con1( |
| 4888 new TestAnalysisContext_test_getElement(invoked)); | 4226 new TestAnalysisContext_test_getElement(invoked)); |
| 4889 context.getElement(null); | 4227 context.getElement(null); |
| 4890 JUnitTestCase.assertTrue(invoked[0]); | 4228 expect(invoked[0], isTrue); |
| 4891 } | 4229 } |
| 4892 | 4230 |
| 4893 void test_getErrors() { | 4231 void test_getErrors() { |
| 4894 List<bool> invoked = [false]; | 4232 List<bool> invoked = [false]; |
| 4895 InstrumentedAnalysisContextImpl context = | 4233 InstrumentedAnalysisContextImpl context = |
| 4896 new InstrumentedAnalysisContextImpl.con1( | 4234 new InstrumentedAnalysisContextImpl.con1( |
| 4897 new TestAnalysisContext_test_getErrors(invoked)); | 4235 new TestAnalysisContext_test_getErrors(invoked)); |
| 4898 context.getErrors(null); | 4236 context.getErrors(null); |
| 4899 JUnitTestCase.assertTrue(invoked[0]); | 4237 expect(invoked[0], isTrue); |
| 4900 } | 4238 } |
| 4901 | 4239 |
| 4902 void test_getHtmlElement() { | 4240 void test_getHtmlElement() { |
| 4903 List<bool> invoked = [false]; | 4241 List<bool> invoked = [false]; |
| 4904 InstrumentedAnalysisContextImpl context = | 4242 InstrumentedAnalysisContextImpl context = |
| 4905 new InstrumentedAnalysisContextImpl.con1( | 4243 new InstrumentedAnalysisContextImpl.con1( |
| 4906 new TestAnalysisContext_test_getHtmlElement(invoked)); | 4244 new TestAnalysisContext_test_getHtmlElement(invoked)); |
| 4907 context.getHtmlElement(null); | 4245 context.getHtmlElement(null); |
| 4908 JUnitTestCase.assertTrue(invoked[0]); | 4246 expect(invoked[0], isTrue); |
| 4909 } | 4247 } |
| 4910 | 4248 |
| 4911 void test_getHtmlFilesReferencing() { | 4249 void test_getHtmlFilesReferencing() { |
| 4912 List<bool> invoked = [false]; | 4250 List<bool> invoked = [false]; |
| 4913 InstrumentedAnalysisContextImpl context = | 4251 InstrumentedAnalysisContextImpl context = |
| 4914 new InstrumentedAnalysisContextImpl.con1( | 4252 new InstrumentedAnalysisContextImpl.con1( |
| 4915 new TestAnalysisContext_test_getHtmlFilesReferencing(invoked)); | 4253 new TestAnalysisContext_test_getHtmlFilesReferencing(invoked)); |
| 4916 context.getHtmlFilesReferencing(null); | 4254 context.getHtmlFilesReferencing(null); |
| 4917 JUnitTestCase.assertTrue(invoked[0]); | 4255 expect(invoked[0], isTrue); |
| 4918 } | 4256 } |
| 4919 | 4257 |
| 4920 void test_getHtmlSources() { | 4258 void test_getHtmlSources() { |
| 4921 List<bool> invoked = [false]; | 4259 List<bool> invoked = [false]; |
| 4922 InstrumentedAnalysisContextImpl context = | 4260 InstrumentedAnalysisContextImpl context = |
| 4923 new InstrumentedAnalysisContextImpl.con1( | 4261 new InstrumentedAnalysisContextImpl.con1( |
| 4924 new TestAnalysisContext_test_getHtmlSources(invoked)); | 4262 new TestAnalysisContext_test_getHtmlSources(invoked)); |
| 4925 context.htmlSources; | 4263 context.htmlSources; |
| 4926 JUnitTestCase.assertTrue(invoked[0]); | 4264 expect(invoked[0], isTrue); |
| 4927 } | 4265 } |
| 4928 | 4266 |
| 4929 void test_getKindOf() { | 4267 void test_getKindOf() { |
| 4930 List<bool> invoked = [false]; | 4268 List<bool> invoked = [false]; |
| 4931 InstrumentedAnalysisContextImpl context = | 4269 InstrumentedAnalysisContextImpl context = |
| 4932 new InstrumentedAnalysisContextImpl.con1( | 4270 new InstrumentedAnalysisContextImpl.con1( |
| 4933 new TestAnalysisContext_test_getKindOf(invoked)); | 4271 new TestAnalysisContext_test_getKindOf(invoked)); |
| 4934 context.getKindOf(null); | 4272 context.getKindOf(null); |
| 4935 JUnitTestCase.assertTrue(invoked[0]); | 4273 expect(invoked[0], isTrue); |
| 4936 } | 4274 } |
| 4937 | 4275 |
| 4938 void test_getLaunchableClientLibrarySources() { | 4276 void test_getLaunchableClientLibrarySources() { |
| 4939 List<bool> invoked = [false]; | 4277 List<bool> invoked = [false]; |
| 4940 InstrumentedAnalysisContextImpl context = | 4278 InstrumentedAnalysisContextImpl context = |
| 4941 new InstrumentedAnalysisContextImpl.con1( | 4279 new InstrumentedAnalysisContextImpl.con1( |
| 4942 new TestAnalysisContext_test_getLaunchableClientLibrarySources(invok
ed)); | 4280 new TestAnalysisContext_test_getLaunchableClientLibrarySources(invok
ed)); |
| 4943 context.launchableClientLibrarySources; | 4281 context.launchableClientLibrarySources; |
| 4944 JUnitTestCase.assertTrue(invoked[0]); | 4282 expect(invoked[0], isTrue); |
| 4945 } | 4283 } |
| 4946 | 4284 |
| 4947 void test_getLaunchableServerLibrarySources() { | 4285 void test_getLaunchableServerLibrarySources() { |
| 4948 List<bool> invoked = [false]; | 4286 List<bool> invoked = [false]; |
| 4949 InstrumentedAnalysisContextImpl context = | 4287 InstrumentedAnalysisContextImpl context = |
| 4950 new InstrumentedAnalysisContextImpl.con1( | 4288 new InstrumentedAnalysisContextImpl.con1( |
| 4951 new TestAnalysisContext_test_getLaunchableServerLibrarySources(invok
ed)); | 4289 new TestAnalysisContext_test_getLaunchableServerLibrarySources(invok
ed)); |
| 4952 context.launchableServerLibrarySources; | 4290 context.launchableServerLibrarySources; |
| 4953 JUnitTestCase.assertTrue(invoked[0]); | 4291 expect(invoked[0], isTrue); |
| 4954 } | 4292 } |
| 4955 | 4293 |
| 4956 void test_getLibrariesContaining() { | 4294 void test_getLibrariesContaining() { |
| 4957 List<bool> invoked = [false]; | 4295 List<bool> invoked = [false]; |
| 4958 InstrumentedAnalysisContextImpl context = | 4296 InstrumentedAnalysisContextImpl context = |
| 4959 new InstrumentedAnalysisContextImpl.con1( | 4297 new InstrumentedAnalysisContextImpl.con1( |
| 4960 new TestAnalysisContext_test_getLibrariesContaining(invoked)); | 4298 new TestAnalysisContext_test_getLibrariesContaining(invoked)); |
| 4961 context.getLibrariesContaining(null); | 4299 context.getLibrariesContaining(null); |
| 4962 JUnitTestCase.assertTrue(invoked[0]); | 4300 expect(invoked[0], isTrue); |
| 4963 } | 4301 } |
| 4964 | 4302 |
| 4965 void test_getLibrariesDependingOn() { | 4303 void test_getLibrariesDependingOn() { |
| 4966 List<bool> invoked = [false]; | 4304 List<bool> invoked = [false]; |
| 4967 InstrumentedAnalysisContextImpl context = | 4305 InstrumentedAnalysisContextImpl context = |
| 4968 new InstrumentedAnalysisContextImpl.con1( | 4306 new InstrumentedAnalysisContextImpl.con1( |
| 4969 new TestAnalysisContext_test_getLibrariesDependingOn(invoked)); | 4307 new TestAnalysisContext_test_getLibrariesDependingOn(invoked)); |
| 4970 context.getLibrariesDependingOn(null); | 4308 context.getLibrariesDependingOn(null); |
| 4971 JUnitTestCase.assertTrue(invoked[0]); | 4309 expect(invoked[0], isTrue); |
| 4972 } | 4310 } |
| 4973 | 4311 |
| 4974 void test_getLibrariesReferencedFromHtml() { | 4312 void test_getLibrariesReferencedFromHtml() { |
| 4975 List<bool> invoked = [false]; | 4313 List<bool> invoked = [false]; |
| 4976 InstrumentedAnalysisContextImpl context = | 4314 InstrumentedAnalysisContextImpl context = |
| 4977 new InstrumentedAnalysisContextImpl.con1( | 4315 new InstrumentedAnalysisContextImpl.con1( |
| 4978 new TestAnalysisContext_test_getLibrariesReferencedFromHtml(invoked)
); | 4316 new TestAnalysisContext_test_getLibrariesReferencedFromHtml(invoked)
); |
| 4979 context.getLibrariesReferencedFromHtml(null); | 4317 context.getLibrariesReferencedFromHtml(null); |
| 4980 JUnitTestCase.assertTrue(invoked[0]); | 4318 expect(invoked[0], isTrue); |
| 4981 } | 4319 } |
| 4982 | 4320 |
| 4983 void test_getLibraryElement() { | 4321 void test_getLibraryElement() { |
| 4984 List<bool> invoked = [false]; | 4322 List<bool> invoked = [false]; |
| 4985 InstrumentedAnalysisContextImpl context = | 4323 InstrumentedAnalysisContextImpl context = |
| 4986 new InstrumentedAnalysisContextImpl.con1( | 4324 new InstrumentedAnalysisContextImpl.con1( |
| 4987 new TestAnalysisContext_test_getLibraryElement(invoked)); | 4325 new TestAnalysisContext_test_getLibraryElement(invoked)); |
| 4988 context.getLibraryElement(null); | 4326 context.getLibraryElement(null); |
| 4989 JUnitTestCase.assertTrue(invoked[0]); | 4327 expect(invoked[0], isTrue); |
| 4990 } | 4328 } |
| 4991 | 4329 |
| 4992 void test_getLibrarySources() { | 4330 void test_getLibrarySources() { |
| 4993 List<bool> invoked = [false]; | 4331 List<bool> invoked = [false]; |
| 4994 InstrumentedAnalysisContextImpl context = | 4332 InstrumentedAnalysisContextImpl context = |
| 4995 new InstrumentedAnalysisContextImpl.con1( | 4333 new InstrumentedAnalysisContextImpl.con1( |
| 4996 new TestAnalysisContext_test_getLibrarySources(invoked)); | 4334 new TestAnalysisContext_test_getLibrarySources(invoked)); |
| 4997 context.librarySources; | 4335 context.librarySources; |
| 4998 JUnitTestCase.assertTrue(invoked[0]); | 4336 expect(invoked[0], isTrue); |
| 4999 } | 4337 } |
| 5000 | 4338 |
| 5001 void test_getLineInfo() { | 4339 void test_getLineInfo() { |
| 5002 List<bool> invoked = [false]; | 4340 List<bool> invoked = [false]; |
| 5003 InstrumentedAnalysisContextImpl context = | 4341 InstrumentedAnalysisContextImpl context = |
| 5004 new InstrumentedAnalysisContextImpl.con1( | 4342 new InstrumentedAnalysisContextImpl.con1( |
| 5005 new TestAnalysisContext_test_getLineInfo(invoked)); | 4343 new TestAnalysisContext_test_getLineInfo(invoked)); |
| 5006 context.getLineInfo(null); | 4344 context.getLineInfo(null); |
| 5007 JUnitTestCase.assertTrue(invoked[0]); | 4345 expect(invoked[0], isTrue); |
| 5008 } | 4346 } |
| 5009 | 4347 |
| 5010 void test_getModificationStamp() { | 4348 void test_getModificationStamp() { |
| 5011 List<bool> invoked = [false]; | 4349 List<bool> invoked = [false]; |
| 5012 InstrumentedAnalysisContextImpl context = | 4350 InstrumentedAnalysisContextImpl context = |
| 5013 new InstrumentedAnalysisContextImpl.con1( | 4351 new InstrumentedAnalysisContextImpl.con1( |
| 5014 new TestAnalysisContext_test_getModificationStamp(invoked)); | 4352 new TestAnalysisContext_test_getModificationStamp(invoked)); |
| 5015 context.getModificationStamp(null); | 4353 context.getModificationStamp(null); |
| 5016 JUnitTestCase.assertTrue(invoked[0]); | 4354 expect(invoked[0], isTrue); |
| 5017 } | 4355 } |
| 5018 | 4356 |
| 5019 void test_getPublicNamespace() { | 4357 void test_getPublicNamespace() { |
| 5020 List<bool> invoked = [false]; | 4358 List<bool> invoked = [false]; |
| 5021 InstrumentedAnalysisContextImpl context = | 4359 InstrumentedAnalysisContextImpl context = |
| 5022 new InstrumentedAnalysisContextImpl.con1( | 4360 new InstrumentedAnalysisContextImpl.con1( |
| 5023 new TestAnalysisContext_test_getPublicNamespace(invoked)); | 4361 new TestAnalysisContext_test_getPublicNamespace(invoked)); |
| 5024 context.getPublicNamespace(null); | 4362 context.getPublicNamespace(null); |
| 5025 JUnitTestCase.assertTrue(invoked[0]); | 4363 expect(invoked[0], isTrue); |
| 5026 } | 4364 } |
| 5027 | 4365 |
| 5028 void test_getRefactoringUnsafeSources() { | 4366 void test_getRefactoringUnsafeSources() { |
| 5029 List<bool> invoked = [false]; | 4367 List<bool> invoked = [false]; |
| 5030 InstrumentedAnalysisContextImpl context = | 4368 InstrumentedAnalysisContextImpl context = |
| 5031 new InstrumentedAnalysisContextImpl.con1( | 4369 new InstrumentedAnalysisContextImpl.con1( |
| 5032 new TestAnalysisContext_test_getRefactoringUnsafeSources(invoked)); | 4370 new TestAnalysisContext_test_getRefactoringUnsafeSources(invoked)); |
| 5033 context.refactoringUnsafeSources; | 4371 context.refactoringUnsafeSources; |
| 5034 JUnitTestCase.assertTrue(invoked[0]); | 4372 expect(invoked[0], isTrue); |
| 5035 } | 4373 } |
| 5036 | 4374 |
| 5037 void test_getResolvedCompilationUnit_element() { | 4375 void test_getResolvedCompilationUnit_element() { |
| 5038 List<bool> invoked = [false]; | 4376 List<bool> invoked = [false]; |
| 5039 InstrumentedAnalysisContextImpl context = | 4377 InstrumentedAnalysisContextImpl context = |
| 5040 new InstrumentedAnalysisContextImpl.con1( | 4378 new InstrumentedAnalysisContextImpl.con1( |
| 5041 new TestAnalysisContext_test_getResolvedCompilationUnit_element(invo
ked)); | 4379 new TestAnalysisContext_test_getResolvedCompilationUnit_element(invo
ked)); |
| 5042 context.getResolvedCompilationUnit(null, null); | 4380 context.getResolvedCompilationUnit(null, null); |
| 5043 JUnitTestCase.assertTrue(invoked[0]); | 4381 expect(invoked[0], isTrue); |
| 5044 } | 4382 } |
| 5045 | 4383 |
| 5046 void test_getResolvedCompilationUnit_source() { | 4384 void test_getResolvedCompilationUnit_source() { |
| 5047 List<bool> invoked = [false]; | 4385 List<bool> invoked = [false]; |
| 5048 InstrumentedAnalysisContextImpl context = | 4386 InstrumentedAnalysisContextImpl context = |
| 5049 new InstrumentedAnalysisContextImpl.con1( | 4387 new InstrumentedAnalysisContextImpl.con1( |
| 5050 new TestAnalysisContext_test_getResolvedCompilationUnit_source(invok
ed)); | 4388 new TestAnalysisContext_test_getResolvedCompilationUnit_source(invok
ed)); |
| 5051 context.getResolvedCompilationUnit2(null, null); | 4389 context.getResolvedCompilationUnit2(null, null); |
| 5052 JUnitTestCase.assertTrue(invoked[0]); | 4390 expect(invoked[0], isTrue); |
| 5053 } | 4391 } |
| 5054 | 4392 |
| 5055 void test_getResolvedHtmlUnit() { | 4393 void test_getResolvedHtmlUnit() { |
| 5056 List<bool> invoked = [false]; | 4394 List<bool> invoked = [false]; |
| 5057 InstrumentedAnalysisContextImpl context = | 4395 InstrumentedAnalysisContextImpl context = |
| 5058 new InstrumentedAnalysisContextImpl.con1( | 4396 new InstrumentedAnalysisContextImpl.con1( |
| 5059 new TestAnalysisContext_test_getResolvedHtmlUnit(invoked)); | 4397 new TestAnalysisContext_test_getResolvedHtmlUnit(invoked)); |
| 5060 context.getResolvedHtmlUnit(null); | 4398 context.getResolvedHtmlUnit(null); |
| 5061 JUnitTestCase.assertTrue(invoked[0]); | 4399 expect(invoked[0], isTrue); |
| 5062 } | 4400 } |
| 5063 | 4401 |
| 5064 void test_getSourceFactory() { | 4402 void test_getSourceFactory() { |
| 5065 List<bool> invoked = [false]; | 4403 List<bool> invoked = [false]; |
| 5066 InstrumentedAnalysisContextImpl context = | 4404 InstrumentedAnalysisContextImpl context = |
| 5067 new InstrumentedAnalysisContextImpl.con1( | 4405 new InstrumentedAnalysisContextImpl.con1( |
| 5068 new TestAnalysisContext_test_getSourceFactory(invoked)); | 4406 new TestAnalysisContext_test_getSourceFactory(invoked)); |
| 5069 context.sourceFactory; | 4407 context.sourceFactory; |
| 5070 JUnitTestCase.assertTrue(invoked[0]); | 4408 expect(invoked[0], isTrue); |
| 5071 } | 4409 } |
| 5072 | 4410 |
| 5073 void test_getStatistics() { | 4411 void test_getStatistics() { |
| 5074 List<bool> invoked = [false]; | 4412 List<bool> invoked = [false]; |
| 5075 InstrumentedAnalysisContextImpl context = | 4413 InstrumentedAnalysisContextImpl context = |
| 5076 new InstrumentedAnalysisContextImpl.con1( | 4414 new InstrumentedAnalysisContextImpl.con1( |
| 5077 new TestAnalysisContext_test_getStatistics(invoked)); | 4415 new TestAnalysisContext_test_getStatistics(invoked)); |
| 5078 context.statistics; | 4416 context.statistics; |
| 5079 JUnitTestCase.assertTrue(invoked[0]); | 4417 expect(invoked[0], isTrue); |
| 5080 } | 4418 } |
| 5081 | 4419 |
| 5082 void test_getTypeProvider() { | 4420 void test_getTypeProvider() { |
| 5083 List<bool> invoked = [false]; | 4421 List<bool> invoked = [false]; |
| 5084 InstrumentedAnalysisContextImpl context = | 4422 InstrumentedAnalysisContextImpl context = |
| 5085 new InstrumentedAnalysisContextImpl.con1( | 4423 new InstrumentedAnalysisContextImpl.con1( |
| 5086 new TestAnalysisContext_test_getTypeProvider(invoked)); | 4424 new TestAnalysisContext_test_getTypeProvider(invoked)); |
| 5087 context.typeProvider; | 4425 context.typeProvider; |
| 5088 JUnitTestCase.assertTrue(invoked[0]); | 4426 expect(invoked[0], isTrue); |
| 5089 } | 4427 } |
| 5090 | 4428 |
| 5091 void test_isClientLibrary() { | 4429 void test_isClientLibrary() { |
| 5092 List<bool> invoked = [false]; | 4430 List<bool> invoked = [false]; |
| 5093 InstrumentedAnalysisContextImpl context = | 4431 InstrumentedAnalysisContextImpl context = |
| 5094 new InstrumentedAnalysisContextImpl.con1( | 4432 new InstrumentedAnalysisContextImpl.con1( |
| 5095 new TestAnalysisContext_test_isClientLibrary(invoked)); | 4433 new TestAnalysisContext_test_isClientLibrary(invoked)); |
| 5096 context.isClientLibrary(null); | 4434 context.isClientLibrary(null); |
| 5097 JUnitTestCase.assertTrue(invoked[0]); | 4435 expect(invoked[0], isTrue); |
| 5098 } | 4436 } |
| 5099 | 4437 |
| 5100 void test_isDisposed() { | 4438 void test_isDisposed() { |
| 5101 List<bool> invoked = [false]; | 4439 List<bool> invoked = [false]; |
| 5102 InstrumentedAnalysisContextImpl context = | 4440 InstrumentedAnalysisContextImpl context = |
| 5103 new InstrumentedAnalysisContextImpl.con1( | 4441 new InstrumentedAnalysisContextImpl.con1( |
| 5104 new TestAnalysisContext_test_isDisposed(invoked)); | 4442 new TestAnalysisContext_test_isDisposed(invoked)); |
| 5105 context.isDisposed; | 4443 context.isDisposed; |
| 5106 JUnitTestCase.assertTrue(invoked[0]); | 4444 expect(invoked[0], isTrue); |
| 5107 } | 4445 } |
| 5108 | 4446 |
| 5109 void test_isServerLibrary() { | 4447 void test_isServerLibrary() { |
| 5110 List<bool> invoked = [false]; | 4448 List<bool> invoked = [false]; |
| 5111 InstrumentedAnalysisContextImpl context = | 4449 InstrumentedAnalysisContextImpl context = |
| 5112 new InstrumentedAnalysisContextImpl.con1( | 4450 new InstrumentedAnalysisContextImpl.con1( |
| 5113 new TestAnalysisContext_test_isServerLibrary(invoked)); | 4451 new TestAnalysisContext_test_isServerLibrary(invoked)); |
| 5114 context.isServerLibrary(null); | 4452 context.isServerLibrary(null); |
| 5115 JUnitTestCase.assertTrue(invoked[0]); | 4453 expect(invoked[0], isTrue); |
| 5116 } | 4454 } |
| 5117 | 4455 |
| 5118 void test_parseCompilationUnit() { | 4456 void test_parseCompilationUnit() { |
| 5119 List<bool> invoked = [false]; | 4457 List<bool> invoked = [false]; |
| 5120 InstrumentedAnalysisContextImpl context = | 4458 InstrumentedAnalysisContextImpl context = |
| 5121 new InstrumentedAnalysisContextImpl.con1( | 4459 new InstrumentedAnalysisContextImpl.con1( |
| 5122 new TestAnalysisContext_test_parseCompilationUnit(invoked)); | 4460 new TestAnalysisContext_test_parseCompilationUnit(invoked)); |
| 5123 context.parseCompilationUnit(null); | 4461 context.parseCompilationUnit(null); |
| 5124 JUnitTestCase.assertTrue(invoked[0]); | 4462 expect(invoked[0], isTrue); |
| 5125 } | 4463 } |
| 5126 | 4464 |
| 5127 void test_parseHtmlUnit() { | 4465 void test_parseHtmlUnit() { |
| 5128 List<bool> invoked = [false]; | 4466 List<bool> invoked = [false]; |
| 5129 InstrumentedAnalysisContextImpl context = | 4467 InstrumentedAnalysisContextImpl context = |
| 5130 new InstrumentedAnalysisContextImpl.con1( | 4468 new InstrumentedAnalysisContextImpl.con1( |
| 5131 new TestAnalysisContext_test_parseHtmlUnit(invoked)); | 4469 new TestAnalysisContext_test_parseHtmlUnit(invoked)); |
| 5132 context.parseHtmlUnit(null); | 4470 context.parseHtmlUnit(null); |
| 5133 JUnitTestCase.assertTrue(invoked[0]); | 4471 expect(invoked[0], isTrue); |
| 5134 } | 4472 } |
| 5135 | 4473 |
| 5136 void test_performAnalysisTask() { | 4474 void test_performAnalysisTask() { |
| 5137 List<bool> invoked = [false]; | 4475 List<bool> invoked = [false]; |
| 5138 InstrumentedAnalysisContextImpl context = | 4476 InstrumentedAnalysisContextImpl context = |
| 5139 new InstrumentedAnalysisContextImpl.con1( | 4477 new InstrumentedAnalysisContextImpl.con1( |
| 5140 new TestAnalysisContext_test_performAnalysisTask(invoked)); | 4478 new TestAnalysisContext_test_performAnalysisTask(invoked)); |
| 5141 context.performAnalysisTask(); | 4479 context.performAnalysisTask(); |
| 5142 JUnitTestCase.assertTrue(invoked[0]); | 4480 expect(invoked[0], isTrue); |
| 5143 } | 4481 } |
| 5144 | 4482 |
| 5145 void test_recordLibraryElements() { | 4483 void test_recordLibraryElements() { |
| 5146 List<bool> invoked = [false]; | 4484 List<bool> invoked = [false]; |
| 5147 InstrumentedAnalysisContextImpl context = | 4485 InstrumentedAnalysisContextImpl context = |
| 5148 new InstrumentedAnalysisContextImpl.con1( | 4486 new InstrumentedAnalysisContextImpl.con1( |
| 5149 new TestAnalysisContext_test_recordLibraryElements(invoked)); | 4487 new TestAnalysisContext_test_recordLibraryElements(invoked)); |
| 5150 context.recordLibraryElements(null); | 4488 context.recordLibraryElements(null); |
| 5151 JUnitTestCase.assertTrue(invoked[0]); | 4489 expect(invoked[0], isTrue); |
| 5152 } | 4490 } |
| 5153 | 4491 |
| 5154 void test_resolveCompilationUnit() { | 4492 void test_resolveCompilationUnit() { |
| 5155 List<bool> invoked = [false]; | 4493 List<bool> invoked = [false]; |
| 5156 InstrumentedAnalysisContextImpl context = | 4494 InstrumentedAnalysisContextImpl context = |
| 5157 new InstrumentedAnalysisContextImpl.con1( | 4495 new InstrumentedAnalysisContextImpl.con1( |
| 5158 new TestAnalysisContext_test_resolveCompilationUnit(invoked)); | 4496 new TestAnalysisContext_test_resolveCompilationUnit(invoked)); |
| 5159 context.resolveCompilationUnit2(null, null); | 4497 context.resolveCompilationUnit2(null, null); |
| 5160 JUnitTestCase.assertTrue(invoked[0]); | 4498 expect(invoked[0], isTrue); |
| 5161 } | 4499 } |
| 5162 | 4500 |
| 5163 void test_resolveCompilationUnit_element() { | 4501 void test_resolveCompilationUnit_element() { |
| 5164 List<bool> invoked = [false]; | 4502 List<bool> invoked = [false]; |
| 5165 InstrumentedAnalysisContextImpl context = | 4503 InstrumentedAnalysisContextImpl context = |
| 5166 new InstrumentedAnalysisContextImpl.con1( | 4504 new InstrumentedAnalysisContextImpl.con1( |
| 5167 new TestAnalysisContext_test_resolveCompilationUnit_element(invoked)
); | 4505 new TestAnalysisContext_test_resolveCompilationUnit_element(invoked)
); |
| 5168 context.resolveCompilationUnit(null, null); | 4506 context.resolveCompilationUnit(null, null); |
| 5169 JUnitTestCase.assertTrue(invoked[0]); | 4507 expect(invoked[0], isTrue); |
| 5170 } | 4508 } |
| 5171 | 4509 |
| 5172 void test_resolveHtmlUnit() { | 4510 void test_resolveHtmlUnit() { |
| 5173 List<bool> invoked = [false]; | 4511 List<bool> invoked = [false]; |
| 5174 InstrumentedAnalysisContextImpl context = | 4512 InstrumentedAnalysisContextImpl context = |
| 5175 new InstrumentedAnalysisContextImpl.con1( | 4513 new InstrumentedAnalysisContextImpl.con1( |
| 5176 new TestAnalysisContext_test_resolveHtmlUnit(invoked)); | 4514 new TestAnalysisContext_test_resolveHtmlUnit(invoked)); |
| 5177 context.resolveHtmlUnit(null); | 4515 context.resolveHtmlUnit(null); |
| 5178 JUnitTestCase.assertTrue(invoked[0]); | 4516 expect(invoked[0], isTrue); |
| 5179 } | 4517 } |
| 5180 | 4518 |
| 5181 void test_setAnalysisOptions() { | 4519 void test_setAnalysisOptions() { |
| 5182 List<bool> invoked = [false]; | 4520 List<bool> invoked = [false]; |
| 5183 InstrumentedAnalysisContextImpl context = | 4521 InstrumentedAnalysisContextImpl context = |
| 5184 new InstrumentedAnalysisContextImpl.con1( | 4522 new InstrumentedAnalysisContextImpl.con1( |
| 5185 new TestAnalysisContext_test_setAnalysisOptions(invoked)); | 4523 new TestAnalysisContext_test_setAnalysisOptions(invoked)); |
| 5186 context.analysisOptions = null; | 4524 context.analysisOptions = null; |
| 5187 JUnitTestCase.assertTrue(invoked[0]); | 4525 expect(invoked[0], isTrue); |
| 5188 } | 4526 } |
| 5189 | 4527 |
| 5190 void test_setAnalysisPriorityOrder() { | 4528 void test_setAnalysisPriorityOrder() { |
| 5191 List<bool> invoked = [false]; | 4529 List<bool> invoked = [false]; |
| 5192 InstrumentedAnalysisContextImpl context = | 4530 InstrumentedAnalysisContextImpl context = |
| 5193 new InstrumentedAnalysisContextImpl.con1( | 4531 new InstrumentedAnalysisContextImpl.con1( |
| 5194 new TestAnalysisContext_test_setAnalysisPriorityOrder(invoked)); | 4532 new TestAnalysisContext_test_setAnalysisPriorityOrder(invoked)); |
| 5195 context.analysisPriorityOrder = null; | 4533 context.analysisPriorityOrder = null; |
| 5196 JUnitTestCase.assertTrue(invoked[0]); | 4534 expect(invoked[0], isTrue); |
| 5197 } | 4535 } |
| 5198 | 4536 |
| 5199 void test_setChangedContents() { | 4537 void test_setChangedContents() { |
| 5200 List<bool> invoked = [false]; | 4538 List<bool> invoked = [false]; |
| 5201 InstrumentedAnalysisContextImpl context = | 4539 InstrumentedAnalysisContextImpl context = |
| 5202 new InstrumentedAnalysisContextImpl.con1( | 4540 new InstrumentedAnalysisContextImpl.con1( |
| 5203 new TestAnalysisContext_test_setChangedContents(invoked)); | 4541 new TestAnalysisContext_test_setChangedContents(invoked)); |
| 5204 context.setChangedContents(null, null, 0, 0, 0); | 4542 context.setChangedContents(null, null, 0, 0, 0); |
| 5205 JUnitTestCase.assertTrue(invoked[0]); | 4543 expect(invoked[0], isTrue); |
| 5206 } | 4544 } |
| 5207 | 4545 |
| 5208 void test_setContents() { | 4546 void test_setContents() { |
| 5209 List<bool> invoked = [false]; | 4547 List<bool> invoked = [false]; |
| 5210 InstrumentedAnalysisContextImpl context = | 4548 InstrumentedAnalysisContextImpl context = |
| 5211 new InstrumentedAnalysisContextImpl.con1( | 4549 new InstrumentedAnalysisContextImpl.con1( |
| 5212 new TestAnalysisContext_test_setContents(invoked)); | 4550 new TestAnalysisContext_test_setContents(invoked)); |
| 5213 context.setContents(null, null); | 4551 context.setContents(null, null); |
| 5214 JUnitTestCase.assertTrue(invoked[0]); | 4552 expect(invoked[0], isTrue); |
| 5215 } | 4553 } |
| 5216 | 4554 |
| 5217 void test_setSourceFactory() { | 4555 void test_setSourceFactory() { |
| 5218 List<bool> invoked = [false]; | 4556 List<bool> invoked = [false]; |
| 5219 InstrumentedAnalysisContextImpl context = | 4557 InstrumentedAnalysisContextImpl context = |
| 5220 new InstrumentedAnalysisContextImpl.con1( | 4558 new InstrumentedAnalysisContextImpl.con1( |
| 5221 new TestAnalysisContext_test_setSourceFactory(invoked)); | 4559 new TestAnalysisContext_test_setSourceFactory(invoked)); |
| 5222 context.sourceFactory = null; | 4560 context.sourceFactory = null; |
| 5223 JUnitTestCase.assertTrue(invoked[0]); | 4561 expect(invoked[0], isTrue); |
| 5224 } | 4562 } |
| 5225 } | 4563 } |
| 5226 | 4564 |
| 5227 | 4565 |
| 5228 class ParseDartTaskTest extends EngineTestCase { | 4566 class ParseDartTaskTest extends EngineTestCase { |
| 5229 void test_accept() { | 4567 void test_accept() { |
| 5230 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4568 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5231 JUnitTestCase.assertTrue(task.accept(new ParseDartTaskTestTV_accept())); | 4569 expect(task.accept(new ParseDartTaskTestTV_accept()), isTrue); |
| 5232 } | 4570 } |
| 5233 | 4571 |
| 5234 void test_getCompilationUnit() { | 4572 void test_getCompilationUnit() { |
| 5235 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4573 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5236 JUnitTestCase.assertNull(task.compilationUnit); | 4574 expect(task.compilationUnit, isNull); |
| 5237 } | 4575 } |
| 5238 | 4576 |
| 5239 void test_getErrors() { | 4577 void test_getErrors() { |
| 5240 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4578 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5241 EngineTestCase.assertLength(0, task.errors); | 4579 EngineTestCase.assertLength(0, task.errors); |
| 5242 } | 4580 } |
| 5243 | 4581 |
| 5244 void test_getException() { | 4582 void test_getException() { |
| 5245 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4583 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5246 JUnitTestCase.assertNull(task.exception); | 4584 expect(task.exception, isNull); |
| 5247 } | 4585 } |
| 5248 | 4586 |
| 5249 void test_getSource() { | 4587 void test_getSource() { |
| 5250 Source source = new TestSource('/test.dart'); | 4588 Source source = new TestSource('/test.dart'); |
| 5251 ParseDartTask task = new ParseDartTask(null, source, null, null); | 4589 ParseDartTask task = new ParseDartTask(null, source, null, null); |
| 5252 JUnitTestCase.assertSame(source, task.source); | 4590 expect(task.source, same(source)); |
| 5253 } | 4591 } |
| 5254 | 4592 |
| 5255 void test_hasNonPartOfDirective() { | 4593 void test_hasNonPartOfDirective() { |
| 5256 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4594 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5257 JUnitTestCase.assertFalse(task.hasNonPartOfDirective); | 4595 expect(task.hasNonPartOfDirective, isFalse); |
| 5258 } | 4596 } |
| 5259 | 4597 |
| 5260 void test_hasPartOfDirective() { | 4598 void test_hasPartOfDirective() { |
| 5261 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4599 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 5262 JUnitTestCase.assertFalse(task.hasPartOfDirective); | 4600 expect(task.hasPartOfDirective, isFalse); |
| 5263 } | 4601 } |
| 5264 | 4602 |
| 5265 void test_perform_exception() { | 4603 void test_perform_exception() { |
| 5266 TestSource source = new TestSource(); | 4604 TestSource source = new TestSource(); |
| 5267 source.generateExceptionOnRead = true; | 4605 source.generateExceptionOnRead = true; |
| 5268 InternalAnalysisContext context = new AnalysisContextImpl(); | 4606 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5269 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 4607 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5270 ParseDartTask task = new ParseDartTask(context, source, null, null); | 4608 ParseDartTask task = new ParseDartTask(context, source, null, null); |
| 5271 task.perform(new ParseDartTaskTestTV_perform_exception()); | 4609 task.perform(new ParseDartTaskTestTV_perform_exception()); |
| 5272 } | 4610 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5347 | 4685 |
| 5348 class ParseDartTaskTestTV_createParseTask extends TestTaskVisitor<Object> { | 4686 class ParseDartTaskTestTV_createParseTask extends TestTaskVisitor<Object> { |
| 5349 @override | 4687 @override |
| 5350 Object visitScanDartTask(ScanDartTask task) => null; | 4688 Object visitScanDartTask(ScanDartTask task) => null; |
| 5351 } | 4689 } |
| 5352 | 4690 |
| 5353 | 4691 |
| 5354 class ParseDartTaskTestTV_perform_exception extends TestTaskVisitor<bool> { | 4692 class ParseDartTaskTestTV_perform_exception extends TestTaskVisitor<bool> { |
| 5355 @override | 4693 @override |
| 5356 bool visitParseDartTask(ParseDartTask task) { | 4694 bool visitParseDartTask(ParseDartTask task) { |
| 5357 JUnitTestCase.assertNotNull(task.exception); | 4695 expect(task.exception, isNotNull); |
| 5358 return true; | 4696 return true; |
| 5359 } | 4697 } |
| 5360 } | 4698 } |
| 5361 | 4699 |
| 5362 | 4700 |
| 5363 class ParseDartTaskTestTV_perform_library extends TestTaskVisitor<Object> { | 4701 class ParseDartTaskTestTV_perform_library extends TestTaskVisitor<Object> { |
| 5364 InternalAnalysisContext context; | 4702 InternalAnalysisContext context; |
| 5365 Source source; | 4703 Source source; |
| 5366 ParseDartTaskTestTV_perform_library(this.context, this.source); | 4704 ParseDartTaskTestTV_perform_library(this.context, this.source); |
| 5367 @override | 4705 @override |
| 5368 Object visitParseDartTask(ParseDartTask task) { | 4706 Object visitParseDartTask(ParseDartTask task) { |
| 5369 CaughtException exception = task.exception; | 4707 CaughtException exception = task.exception; |
| 5370 if (exception != null) { | 4708 if (exception != null) { |
| 5371 throw exception; | 4709 throw exception; |
| 5372 } | 4710 } |
| 5373 JUnitTestCase.assertNotNull(task.compilationUnit); | 4711 expect(task.compilationUnit, isNotNull); |
| 5374 EngineTestCase.assertLength(1, task.errors); | 4712 EngineTestCase.assertLength(1, task.errors); |
| 5375 JUnitTestCase.assertSame(source, task.source); | 4713 expect(task.source, same(source)); |
| 5376 JUnitTestCase.assertTrue(task.hasNonPartOfDirective); | 4714 expect(task.hasNonPartOfDirective, isTrue); |
| 5377 JUnitTestCase.assertFalse(task.hasPartOfDirective); | 4715 expect(task.hasPartOfDirective, isFalse); |
| 5378 return null; | 4716 return null; |
| 5379 } | 4717 } |
| 5380 } | 4718 } |
| 5381 | 4719 |
| 5382 | 4720 |
| 5383 class ParseDartTaskTestTV_perform_part extends TestTaskVisitor<Object> { | 4721 class ParseDartTaskTestTV_perform_part extends TestTaskVisitor<Object> { |
| 5384 InternalAnalysisContext context; | 4722 InternalAnalysisContext context; |
| 5385 Source source; | 4723 Source source; |
| 5386 ParseDartTaskTestTV_perform_part(this.context, this.source); | 4724 ParseDartTaskTestTV_perform_part(this.context, this.source); |
| 5387 @override | 4725 @override |
| 5388 Object visitParseDartTask(ParseDartTask task) { | 4726 Object visitParseDartTask(ParseDartTask task) { |
| 5389 CaughtException exception = task.exception; | 4727 CaughtException exception = task.exception; |
| 5390 if (exception != null) { | 4728 if (exception != null) { |
| 5391 throw exception; | 4729 throw exception; |
| 5392 } | 4730 } |
| 5393 JUnitTestCase.assertNotNull(task.compilationUnit); | 4731 expect(task.compilationUnit, isNotNull); |
| 5394 EngineTestCase.assertLength(0, task.errors); | 4732 EngineTestCase.assertLength(0, task.errors); |
| 5395 JUnitTestCase.assertSame(source, task.source); | 4733 expect(task.source, same(source)); |
| 5396 JUnitTestCase.assertFalse(task.hasNonPartOfDirective); | 4734 expect(task.hasNonPartOfDirective, isFalse); |
| 5397 JUnitTestCase.assertTrue(task.hasPartOfDirective); | 4735 expect(task.hasPartOfDirective, isTrue); |
| 5398 return null; | 4736 return null; |
| 5399 } | 4737 } |
| 5400 } | 4738 } |
| 5401 | 4739 |
| 5402 | 4740 |
| 5403 class ParseDartTaskTestTV_perform_validateDirectives extends | 4741 class ParseDartTaskTestTV_perform_validateDirectives extends |
| 5404 TestTaskVisitor<Object> { | 4742 TestTaskVisitor<Object> { |
| 5405 InternalAnalysisContext context; | 4743 InternalAnalysisContext context; |
| 5406 Source source; | 4744 Source source; |
| 5407 ParseDartTaskTestTV_perform_validateDirectives(this.context, this.source); | 4745 ParseDartTaskTestTV_perform_validateDirectives(this.context, this.source); |
| 5408 @override | 4746 @override |
| 5409 Object visitParseDartTask(ParseDartTask task) { | 4747 Object visitParseDartTask(ParseDartTask task) { |
| 5410 CaughtException exception = task.exception; | 4748 CaughtException exception = task.exception; |
| 5411 if (exception != null) { | 4749 if (exception != null) { |
| 5412 throw exception; | 4750 throw exception; |
| 5413 } | 4751 } |
| 5414 JUnitTestCase.assertNotNull(task.compilationUnit); | 4752 expect(task.compilationUnit, isNotNull); |
| 5415 GatheringErrorListener errorListener = new GatheringErrorListener(); | 4753 GatheringErrorListener errorListener = new GatheringErrorListener(); |
| 5416 errorListener.addAll(task.errors); | 4754 errorListener.addAll(task.errors); |
| 5417 errorListener.assertErrorsWithCodes( | 4755 errorListener.assertErrorsWithCodes( |
| 5418 [ | 4756 [ |
| 5419 CompileTimeErrorCode.URI_WITH_INTERPOLATION, | 4757 CompileTimeErrorCode.URI_WITH_INTERPOLATION, |
| 5420 CompileTimeErrorCode.INVALID_URI]); | 4758 CompileTimeErrorCode.INVALID_URI]); |
| 5421 JUnitTestCase.assertSame(source, task.source); | 4759 expect(task.source, same(source)); |
| 5422 JUnitTestCase.assertTrue(task.hasNonPartOfDirective); | 4760 expect(task.hasNonPartOfDirective, isTrue); |
| 5423 JUnitTestCase.assertFalse(task.hasPartOfDirective); | 4761 expect(task.hasPartOfDirective, isFalse); |
| 5424 return null; | 4762 return null; |
| 5425 } | 4763 } |
| 5426 } | 4764 } |
| 5427 | 4765 |
| 5428 | 4766 |
| 5429 class ParseHtmlTaskTest extends EngineTestCase { | 4767 class ParseHtmlTaskTest extends EngineTestCase { |
| 5430 ParseHtmlTask parseContents(String contents, TestLogger testLogger) { | 4768 ParseHtmlTask parseContents(String contents, TestLogger testLogger) { |
| 5431 return parseSource( | 4769 return parseSource( |
| 5432 new TestSource('/test.dart', contents), | 4770 new TestSource('/test.dart', contents), |
| 5433 contents, | 4771 contents, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5448 AnalysisEngine.instance.logger = testLogger; | 4786 AnalysisEngine.instance.logger = testLogger; |
| 5449 task.perform(new ParseHtmlTaskTestTV_parseSource(context, source)); | 4787 task.perform(new ParseHtmlTaskTestTV_parseSource(context, source)); |
| 5450 } finally { | 4788 } finally { |
| 5451 AnalysisEngine.instance.logger = oldLogger; | 4789 AnalysisEngine.instance.logger = oldLogger; |
| 5452 } | 4790 } |
| 5453 return task; | 4791 return task; |
| 5454 } | 4792 } |
| 5455 | 4793 |
| 5456 void test_accept() { | 4794 void test_accept() { |
| 5457 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4795 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 5458 JUnitTestCase.assertTrue(task.accept(new ParseHtmlTaskTestTV_accept())); | 4796 expect(task.accept(new ParseHtmlTaskTestTV_accept()), isTrue); |
| 5459 } | 4797 } |
| 5460 | 4798 |
| 5461 void test_getException() { | 4799 void test_getException() { |
| 5462 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4800 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 5463 JUnitTestCase.assertNull(task.exception); | 4801 expect(task.exception, isNull); |
| 5464 } | 4802 } |
| 5465 | 4803 |
| 5466 void test_getHtmlUnit() { | 4804 void test_getHtmlUnit() { |
| 5467 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4805 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 5468 JUnitTestCase.assertNull(task.htmlUnit); | 4806 expect(task.htmlUnit, isNull); |
| 5469 } | 4807 } |
| 5470 | 4808 |
| 5471 void test_getLineInfo() { | 4809 void test_getLineInfo() { |
| 5472 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4810 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 5473 JUnitTestCase.assertNull(task.lineInfo); | 4811 expect(task.lineInfo, isNull); |
| 5474 } | 4812 } |
| 5475 | 4813 |
| 5476 void test_getReferencedLibraries() { | 4814 void test_getReferencedLibraries() { |
| 5477 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4815 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 5478 EngineTestCase.assertLength(0, task.referencedLibraries); | 4816 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5479 } | 4817 } |
| 5480 | 4818 |
| 5481 void test_getSource() { | 4819 void test_getSource() { |
| 5482 Source source = new TestSource('/test.dart'); | 4820 Source source = new TestSource('/test.dart'); |
| 5483 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); | 4821 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); |
| 5484 JUnitTestCase.assertSame(source, task.source); | 4822 expect(task.source, same(source)); |
| 5485 } | 4823 } |
| 5486 | 4824 |
| 5487 void test_perform_embedded_source() { | 4825 void test_perform_embedded_source() { |
| 5488 String contents = r''' | 4826 String contents = r''' |
| 5489 <html> | 4827 <html> |
| 5490 <head> | 4828 <head> |
| 5491 <script type='application/dart'> | 4829 <script type='application/dart'> |
| 5492 void buttonPressed() {} | 4830 void buttonPressed() {} |
| 5493 </script> | 4831 </script> |
| 5494 </head> | 4832 </head> |
| 5495 <body> | 4833 <body> |
| 5496 </body> | 4834 </body> |
| 5497 </html>'''; | 4835 </html>'''; |
| 5498 TestLogger testLogger = new TestLogger(); | 4836 TestLogger testLogger = new TestLogger(); |
| 5499 ParseHtmlTask task = parseContents(contents, testLogger); | 4837 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5500 EngineTestCase.assertLength(0, task.referencedLibraries); | 4838 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5501 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 4839 expect(testLogger.errorCount, 0); |
| 5502 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 4840 expect(testLogger.infoCount, 0); |
| 5503 } | 4841 } |
| 5504 | 4842 |
| 5505 void test_perform_empty_source_reference() { | 4843 void test_perform_empty_source_reference() { |
| 5506 String contents = r''' | 4844 String contents = r''' |
| 5507 <html> | 4845 <html> |
| 5508 <head> | 4846 <head> |
| 5509 <script type='application/dart' src=''/> | 4847 <script type='application/dart' src=''/> |
| 5510 </head> | 4848 </head> |
| 5511 <body> | 4849 <body> |
| 5512 </body> | 4850 </body> |
| 5513 </html>'''; | 4851 </html>'''; |
| 5514 TestLogger testLogger = new TestLogger(); | 4852 TestLogger testLogger = new TestLogger(); |
| 5515 ParseHtmlTask task = parseContents(contents, testLogger); | 4853 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5516 EngineTestCase.assertLength(0, task.referencedLibraries); | 4854 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5517 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 4855 expect(testLogger.errorCount, 0); |
| 5518 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 4856 expect(testLogger.infoCount, 0); |
| 5519 } | 4857 } |
| 5520 | 4858 |
| 5521 void test_perform_invalid_source_reference() { | 4859 void test_perform_invalid_source_reference() { |
| 5522 String contents = r''' | 4860 String contents = r''' |
| 5523 <html> | 4861 <html> |
| 5524 <head> | 4862 <head> |
| 5525 <script type='application/dart' src='an;invalid:[]uri'/> | 4863 <script type='application/dart' src='an;invalid:[]uri'/> |
| 5526 </head> | 4864 </head> |
| 5527 <body> | 4865 <body> |
| 5528 </body> | 4866 </body> |
| 5529 </html>'''; | 4867 </html>'''; |
| 5530 TestLogger testLogger = new TestLogger(); | 4868 TestLogger testLogger = new TestLogger(); |
| 5531 ParseHtmlTask task = parseContents(contents, testLogger); | 4869 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5532 EngineTestCase.assertLength(0, task.referencedLibraries); | 4870 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5533 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 4871 expect(testLogger.errorCount, 0); |
| 5534 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 4872 expect(testLogger.infoCount, 0); |
| 5535 } | 4873 } |
| 5536 | 4874 |
| 5537 void test_perform_non_existing_source_reference() { | 4875 void test_perform_non_existing_source_reference() { |
| 5538 String contents = r''' | 4876 String contents = r''' |
| 5539 <html> | 4877 <html> |
| 5540 <head> | 4878 <head> |
| 5541 <script type='application/dart' src='does/not/exist.dart'/> | 4879 <script type='application/dart' src='does/not/exist.dart'/> |
| 5542 </head> | 4880 </head> |
| 5543 <body> | 4881 <body> |
| 5544 </body> | 4882 </body> |
| 5545 </html>'''; | 4883 </html>'''; |
| 5546 TestLogger testLogger = new TestLogger(); | 4884 TestLogger testLogger = new TestLogger(); |
| 5547 ParseHtmlTask task = parseSource( | 4885 ParseHtmlTask task = parseSource( |
| 5548 new ParseHtmlTaskTest_non_existing_source(contents), | 4886 new ParseHtmlTaskTest_non_existing_source(contents), |
| 5549 contents, | 4887 contents, |
| 5550 testLogger); | 4888 testLogger); |
| 5551 EngineTestCase.assertLength(0, task.referencedLibraries); | 4889 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5552 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 4890 expect(testLogger.errorCount, 0); |
| 5553 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 4891 expect(testLogger.infoCount, 0); |
| 5554 } | 4892 } |
| 5555 | 4893 |
| 5556 void test_perform_referenced_source() { | 4894 void test_perform_referenced_source() { |
| 5557 // TODO(scheglov) this test fails because we put into cache TestSource | 4895 // TODO(scheglov) this test fails because we put into cache TestSource |
| 5558 // test.dart (and actually should test.html), but resolve | 4896 // test.dart (and actually should test.html), but resolve |
| 5559 // src='test.dart' as a FileBasedSource | 4897 // src='test.dart' as a FileBasedSource |
| 5560 // We need to switch to a virtual file system and use it everywhere. | 4898 // We need to switch to a virtual file system and use it everywhere. |
| 5561 // String contents = EngineTestCase.createSource([ | 4899 // String contents = EngineTestCase.createSource([ |
| 5562 // "<html>", | 4900 // "<html>", |
| 5563 // "<head>", | 4901 // "<head>", |
| (...skipping 20 matching lines...) Expand all Loading... |
| 5584 class ParseHtmlTaskTestTV_parseSource extends TestTaskVisitor<bool> { | 4922 class ParseHtmlTaskTestTV_parseSource extends TestTaskVisitor<bool> { |
| 5585 InternalAnalysisContext context; | 4923 InternalAnalysisContext context; |
| 5586 Source source; | 4924 Source source; |
| 5587 ParseHtmlTaskTestTV_parseSource(this.context, this.source); | 4925 ParseHtmlTaskTestTV_parseSource(this.context, this.source); |
| 5588 @override | 4926 @override |
| 5589 bool visitParseHtmlTask(ParseHtmlTask task) { | 4927 bool visitParseHtmlTask(ParseHtmlTask task) { |
| 5590 CaughtException exception = task.exception; | 4928 CaughtException exception = task.exception; |
| 5591 if (exception != null) { | 4929 if (exception != null) { |
| 5592 throw exception; | 4930 throw exception; |
| 5593 } | 4931 } |
| 5594 JUnitTestCase.assertNotNull(task.htmlUnit); | 4932 expect(task.htmlUnit, isNotNull); |
| 5595 JUnitTestCase.assertNotNull(task.lineInfo); | 4933 expect(task.lineInfo, isNotNull); |
| 5596 JUnitTestCase.assertSame(source, task.source); | 4934 expect(task.source, same(source)); |
| 5597 return true; | 4935 return true; |
| 5598 } | 4936 } |
| 5599 } | 4937 } |
| 5600 | 4938 |
| 5601 | 4939 |
| 5602 class ParseHtmlTaskTest_non_existing_source extends TestSource { | 4940 class ParseHtmlTaskTest_non_existing_source extends TestSource { |
| 5603 ParseHtmlTaskTest_non_existing_source(String arg0) : super(arg0); | 4941 ParseHtmlTaskTest_non_existing_source(String arg0) : super(arg0); |
| 5604 @override | 4942 @override |
| 5605 Uri resolveRelativeUri(Uri containedUri) { | 4943 Uri resolveRelativeUri(Uri containedUri) { |
| 5606 try { | 4944 try { |
| 5607 return parseUriWithException("file:/does/not/exist.dart"); | 4945 return parseUriWithException("file:/does/not/exist.dart"); |
| 5608 } on URISyntaxException catch (exception) { | 4946 } on URISyntaxException catch (exception) { |
| 5609 return null; | 4947 return null; |
| 5610 } | 4948 } |
| 5611 } | 4949 } |
| 5612 } | 4950 } |
| 5613 | 4951 |
| 5614 | 4952 |
| 5615 class PartitionManagerTest extends EngineTestCase { | 4953 class PartitionManagerTest extends EngineTestCase { |
| 5616 void test_clearCache() { | 4954 void test_clearCache() { |
| 5617 PartitionManager manager = new PartitionManager(); | 4955 PartitionManager manager = new PartitionManager(); |
| 5618 DartSdk sdk = new MockDartSdk(); | 4956 DartSdk sdk = new MockDartSdk(); |
| 5619 SdkCachePartition oldPartition = manager.forSdk(sdk); | 4957 SdkCachePartition oldPartition = manager.forSdk(sdk); |
| 5620 manager.clearCache(); | 4958 manager.clearCache(); |
| 5621 SdkCachePartition newPartition = manager.forSdk(sdk); | 4959 SdkCachePartition newPartition = manager.forSdk(sdk); |
| 5622 JUnitTestCase.assertNotSame(oldPartition, newPartition); | 4960 expect(newPartition, isNot(same(oldPartition))); |
| 5623 } | 4961 } |
| 5624 | 4962 |
| 5625 void test_creation() { | 4963 void test_creation() { |
| 5626 JUnitTestCase.assertNotNull(new PartitionManager()); | 4964 expect(new PartitionManager(), isNotNull); |
| 5627 } | 4965 } |
| 5628 | 4966 |
| 5629 void test_forSdk() { | 4967 void test_forSdk() { |
| 5630 PartitionManager manager = new PartitionManager(); | 4968 PartitionManager manager = new PartitionManager(); |
| 5631 DartSdk sdk1 = new MockDartSdk(); | 4969 DartSdk sdk1 = new MockDartSdk(); |
| 5632 SdkCachePartition partition1 = manager.forSdk(sdk1); | 4970 SdkCachePartition partition1 = manager.forSdk(sdk1); |
| 5633 JUnitTestCase.assertNotNull(partition1); | 4971 expect(partition1, isNotNull); |
| 5634 JUnitTestCase.assertSame(partition1, manager.forSdk(sdk1)); | 4972 expect(manager.forSdk(sdk1), same(partition1)); |
| 5635 DartSdk sdk2 = new MockDartSdk(); | 4973 DartSdk sdk2 = new MockDartSdk(); |
| 5636 SdkCachePartition partition2 = manager.forSdk(sdk2); | 4974 SdkCachePartition partition2 = manager.forSdk(sdk2); |
| 5637 JUnitTestCase.assertNotNull(partition2); | 4975 expect(partition2, isNotNull); |
| 5638 JUnitTestCase.assertSame(partition2, manager.forSdk(sdk2)); | 4976 expect(manager.forSdk(sdk2), same(partition2)); |
| 5639 JUnitTestCase.assertNotSame(partition1, partition2); | 4977 expect(partition2, isNot(same(partition1))); |
| 5640 } | 4978 } |
| 5641 } | 4979 } |
| 5642 | 4980 |
| 5643 | 4981 |
| 5644 class ResolveDartLibraryTaskTest extends EngineTestCase { | 4982 class ResolveDartLibraryTaskTest extends EngineTestCase { |
| 5645 void test_accept() { | 4983 void test_accept() { |
| 5646 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); | 4984 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); |
| 5647 JUnitTestCase.assertTrue( | 4985 expect(task.accept(new ResolveDartLibraryTaskTestTV_accept()), isTrue); |
| 5648 task.accept(new ResolveDartLibraryTaskTestTV_accept())); | |
| 5649 } | 4986 } |
| 5650 void test_getException() { | 4987 void test_getException() { |
| 5651 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); | 4988 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); |
| 5652 JUnitTestCase.assertNull(task.exception); | 4989 expect(task.exception, isNull); |
| 5653 } | 4990 } |
| 5654 void test_getLibraryResolver() { | 4991 void test_getLibraryResolver() { |
| 5655 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); | 4992 ResolveDartLibraryTask task = new ResolveDartLibraryTask(null, null, null); |
| 5656 JUnitTestCase.assertNull(task.libraryResolver); | 4993 expect(task.libraryResolver, isNull); |
| 5657 } | 4994 } |
| 5658 void test_getLibrarySource() { | 4995 void test_getLibrarySource() { |
| 5659 Source source = new TestSource('/test.dart'); | 4996 Source source = new TestSource('/test.dart'); |
| 5660 ResolveDartLibraryTask task = | 4997 ResolveDartLibraryTask task = |
| 5661 new ResolveDartLibraryTask(null, null, source); | 4998 new ResolveDartLibraryTask(null, null, source); |
| 5662 JUnitTestCase.assertSame(source, task.librarySource); | 4999 expect(task.librarySource, same(source)); |
| 5663 } | 5000 } |
| 5664 void test_getUnitSource() { | 5001 void test_getUnitSource() { |
| 5665 Source source = new TestSource('/test.dart'); | 5002 Source source = new TestSource('/test.dart'); |
| 5666 ResolveDartLibraryTask task = | 5003 ResolveDartLibraryTask task = |
| 5667 new ResolveDartLibraryTask(null, source, null); | 5004 new ResolveDartLibraryTask(null, source, null); |
| 5668 JUnitTestCase.assertSame(source, task.unitSource); | 5005 expect(task.unitSource, same(source)); |
| 5669 } | 5006 } |
| 5670 void test_perform_exception() { | 5007 void test_perform_exception() { |
| 5671 TestSource source = new TestSource(); | 5008 TestSource source = new TestSource(); |
| 5672 source.generateExceptionOnRead = true; | 5009 source.generateExceptionOnRead = true; |
| 5673 InternalAnalysisContext context = new AnalysisContextImpl(); | 5010 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5674 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5011 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5675 ResolveDartLibraryTask task = | 5012 ResolveDartLibraryTask task = |
| 5676 new ResolveDartLibraryTask(context, source, source); | 5013 new ResolveDartLibraryTask(context, source, source); |
| 5677 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); | 5014 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); |
| 5678 } | 5015 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 5693 class ResolveDartLibraryTaskTestTV_accept extends TestTaskVisitor<bool> { | 5030 class ResolveDartLibraryTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 5694 @override | 5031 @override |
| 5695 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) => true; | 5032 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) => true; |
| 5696 } | 5033 } |
| 5697 | 5034 |
| 5698 | 5035 |
| 5699 class ResolveDartLibraryTaskTestTV_perform_exception extends | 5036 class ResolveDartLibraryTaskTestTV_perform_exception extends |
| 5700 TestTaskVisitor<bool> { | 5037 TestTaskVisitor<bool> { |
| 5701 @override | 5038 @override |
| 5702 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) { | 5039 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) { |
| 5703 JUnitTestCase.assertNotNull(task.exception); | 5040 expect(task.exception, isNotNull); |
| 5704 return true; | 5041 return true; |
| 5705 } | 5042 } |
| 5706 } | 5043 } |
| 5707 | 5044 |
| 5708 | 5045 |
| 5709 class ResolveDartLibraryTaskTestTV_perform_library extends TestTaskVisitor<bool> | 5046 class ResolveDartLibraryTaskTestTV_perform_library extends TestTaskVisitor<bool> |
| 5710 { | 5047 { |
| 5711 Source source; | 5048 Source source; |
| 5712 ResolveDartLibraryTaskTestTV_perform_library(this.source); | 5049 ResolveDartLibraryTaskTestTV_perform_library(this.source); |
| 5713 @override | 5050 @override |
| 5714 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) { | 5051 bool visitResolveDartLibraryTask(ResolveDartLibraryTask task) { |
| 5715 CaughtException exception = task.exception; | 5052 CaughtException exception = task.exception; |
| 5716 if (exception != null) { | 5053 if (exception != null) { |
| 5717 throw exception; | 5054 throw exception; |
| 5718 } | 5055 } |
| 5719 JUnitTestCase.assertNotNull(task.libraryResolver); | 5056 expect(task.libraryResolver, isNotNull); |
| 5720 JUnitTestCase.assertSame(source, task.librarySource); | 5057 expect(task.librarySource, same(source)); |
| 5721 JUnitTestCase.assertSame(source, task.unitSource); | 5058 expect(task.unitSource, same(source)); |
| 5722 return true; | 5059 return true; |
| 5723 } | 5060 } |
| 5724 } | 5061 } |
| 5725 | 5062 |
| 5726 | 5063 |
| 5727 class ResolveDartUnitTaskTest extends EngineTestCase { | 5064 class ResolveDartUnitTaskTest extends EngineTestCase { |
| 5728 void test_accept() { | 5065 void test_accept() { |
| 5729 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); | 5066 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); |
| 5730 JUnitTestCase.assertTrue( | 5067 expect(task.accept(new ResolveDartUnitTaskTestTV_accept()), isTrue); |
| 5731 task.accept(new ResolveDartUnitTaskTestTV_accept())); | |
| 5732 } | 5068 } |
| 5733 | 5069 |
| 5734 void test_getException() { | 5070 void test_getException() { |
| 5735 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); | 5071 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); |
| 5736 JUnitTestCase.assertNull(task.exception); | 5072 expect(task.exception, isNull); |
| 5737 } | 5073 } |
| 5738 | 5074 |
| 5739 void test_getLibrarySource() { | 5075 void test_getLibrarySource() { |
| 5740 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 5076 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 5741 LibraryElementImpl element = ElementFactory.library(context, "lib"); | 5077 LibraryElementImpl element = ElementFactory.library(context, "lib"); |
| 5742 Source source = element.source; | 5078 Source source = element.source; |
| 5743 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, element); | 5079 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, element); |
| 5744 JUnitTestCase.assertSame(source, task.librarySource); | 5080 expect(task.librarySource, same(source)); |
| 5745 } | 5081 } |
| 5746 | 5082 |
| 5747 void test_getResolvedUnit() { | 5083 void test_getResolvedUnit() { |
| 5748 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); | 5084 ResolveDartUnitTask task = new ResolveDartUnitTask(null, null, null); |
| 5749 JUnitTestCase.assertNull(task.resolvedUnit); | 5085 expect(task.resolvedUnit, isNull); |
| 5750 } | 5086 } |
| 5751 | 5087 |
| 5752 void test_getSource() { | 5088 void test_getSource() { |
| 5753 Source source = new TestSource('/test.dart'); | 5089 Source source = new TestSource('/test.dart'); |
| 5754 ResolveDartUnitTask task = new ResolveDartUnitTask(null, source, null); | 5090 ResolveDartUnitTask task = new ResolveDartUnitTask(null, source, null); |
| 5755 JUnitTestCase.assertSame(source, task.source); | 5091 expect(task.source, same(source)); |
| 5756 } | 5092 } |
| 5757 | 5093 |
| 5758 void test_perform_exception() { | 5094 void test_perform_exception() { |
| 5759 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 5095 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 5760 LibraryElementImpl element = ElementFactory.library(context, "lib"); | 5096 LibraryElementImpl element = ElementFactory.library(context, "lib"); |
| 5761 TestSource source = new TestSource(); | 5097 TestSource source = new TestSource(); |
| 5762 source.generateExceptionOnRead = true; | 5098 source.generateExceptionOnRead = true; |
| 5763 (element.definingCompilationUnit as CompilationUnitElementImpl).source = | 5099 (element.definingCompilationUnit as CompilationUnitElementImpl).source = |
| 5764 source; | 5100 source; |
| 5765 ResolveDartUnitTask task = | 5101 ResolveDartUnitTask task = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 5796 class ResolveDartUnitTaskTestTV_accept extends TestTaskVisitor<bool> { | 5132 class ResolveDartUnitTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 5797 @override | 5133 @override |
| 5798 bool visitResolveDartUnitTask(ResolveDartUnitTask task) => true; | 5134 bool visitResolveDartUnitTask(ResolveDartUnitTask task) => true; |
| 5799 } | 5135 } |
| 5800 | 5136 |
| 5801 | 5137 |
| 5802 class ResolveDartUnitTaskTestTV_perform_exception extends TestTaskVisitor<bool> | 5138 class ResolveDartUnitTaskTestTV_perform_exception extends TestTaskVisitor<bool> |
| 5803 { | 5139 { |
| 5804 @override | 5140 @override |
| 5805 bool visitResolveDartUnitTask(ResolveDartUnitTask task) { | 5141 bool visitResolveDartUnitTask(ResolveDartUnitTask task) { |
| 5806 JUnitTestCase.assertNotNull(task.exception); | 5142 expect(task.exception, isNotNull); |
| 5807 return true; | 5143 return true; |
| 5808 } | 5144 } |
| 5809 } | 5145 } |
| 5810 | 5146 |
| 5811 | 5147 |
| 5812 class ResolveDartUnitTaskTestTV_perform_library extends TestTaskVisitor<bool> { | 5148 class ResolveDartUnitTaskTestTV_perform_library extends TestTaskVisitor<bool> { |
| 5813 Source source; | 5149 Source source; |
| 5814 InternalAnalysisContext context; | 5150 InternalAnalysisContext context; |
| 5815 ResolveDartUnitTaskTestTV_perform_library(this.source, this.context); | 5151 ResolveDartUnitTaskTestTV_perform_library(this.source, this.context); |
| 5816 @override | 5152 @override |
| 5817 bool visitResolveDartUnitTask(ResolveDartUnitTask task) { | 5153 bool visitResolveDartUnitTask(ResolveDartUnitTask task) { |
| 5818 CaughtException exception = task.exception; | 5154 CaughtException exception = task.exception; |
| 5819 if (exception != null) { | 5155 if (exception != null) { |
| 5820 throw exception; | 5156 throw exception; |
| 5821 } | 5157 } |
| 5822 JUnitTestCase.assertSame(source, task.librarySource); | 5158 expect(task.librarySource, same(source)); |
| 5823 JUnitTestCase.assertNotNull(task.resolvedUnit); | 5159 expect(task.resolvedUnit, isNotNull); |
| 5824 JUnitTestCase.assertSame(source, task.source); | 5160 expect(task.source, same(source)); |
| 5825 return true; | 5161 return true; |
| 5826 } | 5162 } |
| 5827 } | 5163 } |
| 5828 | 5164 |
| 5829 | 5165 |
| 5830 class ResolveHtmlTaskTest extends EngineTestCase { | 5166 class ResolveHtmlTaskTest extends EngineTestCase { |
| 5831 void test_accept() { | 5167 void test_accept() { |
| 5832 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5168 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5833 JUnitTestCase.assertTrue(task.accept(new ResolveHtmlTaskTestTV_accept())); | 5169 expect(task.accept(new ResolveHtmlTaskTestTV_accept()), isTrue); |
| 5834 } | 5170 } |
| 5835 | 5171 |
| 5836 void test_getElement() { | 5172 void test_getElement() { |
| 5837 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5173 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5838 JUnitTestCase.assertNull(task.element); | 5174 expect(task.element, isNull); |
| 5839 } | 5175 } |
| 5840 | 5176 |
| 5841 void test_getException() { | 5177 void test_getException() { |
| 5842 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5178 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5843 JUnitTestCase.assertNull(task.exception); | 5179 expect(task.exception, isNull); |
| 5844 } | 5180 } |
| 5845 | 5181 |
| 5846 void test_getResolutionErrors() { | 5182 void test_getResolutionErrors() { |
| 5847 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5183 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5848 EngineTestCase.assertLength(0, task.resolutionErrors); | 5184 EngineTestCase.assertLength(0, task.resolutionErrors); |
| 5849 } | 5185 } |
| 5850 | 5186 |
| 5851 void test_getSource() { | 5187 void test_getSource() { |
| 5852 Source source = new TestSource('test.dart', ''); | 5188 Source source = new TestSource('test.dart', ''); |
| 5853 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); | 5189 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); |
| 5854 JUnitTestCase.assertSame(source, task.source); | 5190 expect(task.source, same(source)); |
| 5855 } | 5191 } |
| 5856 | 5192 |
| 5857 void test_perform_exception() { | 5193 void test_perform_exception() { |
| 5858 Source source = new TestSource(); | 5194 Source source = new TestSource(); |
| 5859 InternalAnalysisContext context = new AnalysisContextImpl(); | 5195 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5860 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5196 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5861 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); | 5197 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); |
| 5862 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); | 5198 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); |
| 5863 } | 5199 } |
| 5864 | 5200 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5892 | 5228 |
| 5893 class ResolveHtmlTaskTestTV_accept extends TestTaskVisitor<bool> { | 5229 class ResolveHtmlTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 5894 @override | 5230 @override |
| 5895 bool visitResolveHtmlTask(ResolveHtmlTask task) => true; | 5231 bool visitResolveHtmlTask(ResolveHtmlTask task) => true; |
| 5896 } | 5232 } |
| 5897 | 5233 |
| 5898 | 5234 |
| 5899 class ResolveHtmlTaskTestTV_perform_exception extends TestTaskVisitor<bool> { | 5235 class ResolveHtmlTaskTestTV_perform_exception extends TestTaskVisitor<bool> { |
| 5900 @override | 5236 @override |
| 5901 bool visitResolveHtmlTask(ResolveHtmlTask task) { | 5237 bool visitResolveHtmlTask(ResolveHtmlTask task) { |
| 5902 JUnitTestCase.assertNotNull(task.exception); | 5238 expect(task.exception, isNotNull); |
| 5903 return true; | 5239 return true; |
| 5904 } | 5240 } |
| 5905 } | 5241 } |
| 5906 | 5242 |
| 5907 | 5243 |
| 5908 class ResolveHtmlTaskTestTV_perform_valid extends TestTaskVisitor<Object> { | 5244 class ResolveHtmlTaskTestTV_perform_valid extends TestTaskVisitor<Object> { |
| 5909 int modificationStamp; | 5245 int modificationStamp; |
| 5910 Source source; | 5246 Source source; |
| 5911 ResolveHtmlTaskTestTV_perform_valid(this.modificationStamp, this.source); | 5247 ResolveHtmlTaskTestTV_perform_valid(this.modificationStamp, this.source); |
| 5912 @override | 5248 @override |
| 5913 Object visitResolveHtmlTask(ResolveHtmlTask task) { | 5249 Object visitResolveHtmlTask(ResolveHtmlTask task) { |
| 5914 CaughtException exception = task.exception; | 5250 CaughtException exception = task.exception; |
| 5915 if (exception != null) { | 5251 if (exception != null) { |
| 5916 throw exception; | 5252 throw exception; |
| 5917 } | 5253 } |
| 5918 JUnitTestCase.assertNotNull(task.element); | 5254 expect(task.element, isNotNull); |
| 5919 EngineTestCase.assertLength(1, task.resolutionErrors); | 5255 EngineTestCase.assertLength(1, task.resolutionErrors); |
| 5920 JUnitTestCase.assertSame(source, task.source); | 5256 expect(task.source, same(source)); |
| 5921 return null; | 5257 return null; |
| 5922 } | 5258 } |
| 5923 } | 5259 } |
| 5924 | 5260 |
| 5925 | 5261 |
| 5926 class ResolveHtmlTaskTestTV_perform_valid_2 extends TestTaskVisitor<Object> { | 5262 class ResolveHtmlTaskTestTV_perform_valid_2 extends TestTaskVisitor<Object> { |
| 5927 @override | 5263 @override |
| 5928 Object visitParseHtmlTask(ParseHtmlTask task) => null; | 5264 Object visitParseHtmlTask(ParseHtmlTask task) => null; |
| 5929 } | 5265 } |
| 5930 | 5266 |
| 5931 | 5267 |
| 5932 class ScanDartTaskTest extends EngineTestCase { | 5268 class ScanDartTaskTest extends EngineTestCase { |
| 5933 void test_accept() { | 5269 void test_accept() { |
| 5934 ScanDartTask task = new ScanDartTask(null, null, null); | 5270 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5935 JUnitTestCase.assertTrue(task.accept(new ScanDartTaskTestTV_accept())); | 5271 expect(task.accept(new ScanDartTaskTestTV_accept()), isTrue); |
| 5936 } | 5272 } |
| 5937 | 5273 |
| 5938 void test_getErrors() { | 5274 void test_getErrors() { |
| 5939 ScanDartTask task = new ScanDartTask(null, null, null); | 5275 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5940 EngineTestCase.assertLength(0, task.errors); | 5276 EngineTestCase.assertLength(0, task.errors); |
| 5941 } | 5277 } |
| 5942 | 5278 |
| 5943 void test_getException() { | 5279 void test_getException() { |
| 5944 ScanDartTask task = new ScanDartTask(null, null, null); | 5280 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5945 JUnitTestCase.assertNull(task.exception); | 5281 expect(task.exception, isNull); |
| 5946 } | 5282 } |
| 5947 | 5283 |
| 5948 void test_getLineInfo() { | 5284 void test_getLineInfo() { |
| 5949 ScanDartTask task = new ScanDartTask(null, null, null); | 5285 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5950 JUnitTestCase.assertNull(task.lineInfo); | 5286 expect(task.lineInfo, isNull); |
| 5951 } | 5287 } |
| 5952 | 5288 |
| 5953 void test_getSource() { | 5289 void test_getSource() { |
| 5954 Source source = new TestSource('test.dart', ''); | 5290 Source source = new TestSource('test.dart', ''); |
| 5955 ScanDartTask task = new ScanDartTask(null, source, null); | 5291 ScanDartTask task = new ScanDartTask(null, source, null); |
| 5956 JUnitTestCase.assertSame(source, task.source); | 5292 expect(task.source, same(source)); |
| 5957 } | 5293 } |
| 5958 | 5294 |
| 5959 void test_perform_valid() { | 5295 void test_perform_valid() { |
| 5960 String content = 'class A {}'; | 5296 String content = 'class A {}'; |
| 5961 Source source = new TestSource('test.dart', content); | 5297 Source source = new TestSource('test.dart', content); |
| 5962 InternalAnalysisContext context = new AnalysisContextImpl(); | 5298 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5963 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5299 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5964 ScanDartTask task = | 5300 ScanDartTask task = |
| 5965 new ScanDartTask(context, source, content); | 5301 new ScanDartTask(context, source, content); |
| 5966 task.perform(new ScanDartTaskTestTV_perform_valid(context, source)); | 5302 task.perform(new ScanDartTaskTestTV_perform_valid(context, source)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 5977 class ScanDartTaskTestTV_perform_valid extends TestTaskVisitor<bool> { | 5313 class ScanDartTaskTestTV_perform_valid extends TestTaskVisitor<bool> { |
| 5978 InternalAnalysisContext context; | 5314 InternalAnalysisContext context; |
| 5979 Source source; | 5315 Source source; |
| 5980 ScanDartTaskTestTV_perform_valid(this.context, this.source); | 5316 ScanDartTaskTestTV_perform_valid(this.context, this.source); |
| 5981 @override | 5317 @override |
| 5982 bool visitScanDartTask(ScanDartTask task) { | 5318 bool visitScanDartTask(ScanDartTask task) { |
| 5983 CaughtException exception = task.exception; | 5319 CaughtException exception = task.exception; |
| 5984 if (exception != null) { | 5320 if (exception != null) { |
| 5985 throw exception; | 5321 throw exception; |
| 5986 } | 5322 } |
| 5987 JUnitTestCase.assertNotNull(task.tokenStream); | 5323 expect(task.tokenStream, isNotNull); |
| 5988 EngineTestCase.assertLength(0, task.errors); | 5324 EngineTestCase.assertLength(0, task.errors); |
| 5989 JUnitTestCase.assertNotNull(task.lineInfo); | 5325 expect(task.lineInfo, isNotNull); |
| 5990 JUnitTestCase.assertSame(source, task.source); | 5326 expect(task.source, same(source)); |
| 5991 return true; | 5327 return true; |
| 5992 } | 5328 } |
| 5993 } | 5329 } |
| 5994 | 5330 |
| 5995 | 5331 |
| 5996 class SdkCachePartitionTest extends EngineTestCase { | 5332 class SdkCachePartitionTest extends EngineTestCase { |
| 5997 void test_contains_false() { | 5333 void test_contains_false() { |
| 5998 SdkCachePartition partition = new SdkCachePartition(null, 8); | 5334 SdkCachePartition partition = new SdkCachePartition(null, 8); |
| 5999 Source source = new TestSource(); | 5335 Source source = new TestSource(); |
| 6000 JUnitTestCase.assertFalse(partition.contains(source)); | 5336 expect(partition.contains(source), isFalse); |
| 6001 } | 5337 } |
| 6002 | 5338 |
| 6003 void test_contains_true() { | 5339 void test_contains_true() { |
| 6004 SdkCachePartition partition = new SdkCachePartition(null, 8); | 5340 SdkCachePartition partition = new SdkCachePartition(null, 8); |
| 6005 SourceFactory factory = | 5341 SourceFactory factory = |
| 6006 new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)
]); | 5342 new SourceFactory([new DartUriResolver(DirectoryBasedDartSdk.defaultSdk)
]); |
| 6007 Source source = factory.forUri("dart:core"); | 5343 Source source = factory.forUri("dart:core"); |
| 6008 JUnitTestCase.assertTrue(partition.contains(source)); | 5344 expect(partition.contains(source), isTrue); |
| 6009 } | 5345 } |
| 6010 | 5346 |
| 6011 void test_creation() { | 5347 void test_creation() { |
| 6012 JUnitTestCase.assertNotNull(new SdkCachePartition(null, 8)); | 5348 expect(new SdkCachePartition(null, 8), isNotNull); |
| 6013 } | 5349 } |
| 6014 } | 5350 } |
| 6015 | 5351 |
| 6016 | 5352 |
| 6017 /** | 5353 /** |
| 6018 * Instances of the class `TestAnalysisContext` implement an analysis context in
which every | 5354 * Instances of the class `TestAnalysisContext` implement an analysis context in
which every |
| 6019 * method will cause a test to fail when invoked. | 5355 * method will cause a test to fail when invoked. |
| 6020 */ | 5356 */ |
| 6021 class TestAnalysisContext implements InternalAnalysisContext { | 5357 class TestAnalysisContext implements InternalAnalysisContext { |
| 6022 @override | 5358 @override |
| 6023 AnalysisOptions get analysisOptions { | 5359 AnalysisOptions get analysisOptions { |
| 6024 JUnitTestCase.fail("Unexpected invocation of getAnalysisOptions"); | 5360 fail("Unexpected invocation of getAnalysisOptions"); |
| 6025 return null; | 5361 return null; |
| 6026 } | 5362 } |
| 6027 @override | 5363 @override |
| 6028 void set analysisOptions(AnalysisOptions options) { | 5364 void set analysisOptions(AnalysisOptions options) { |
| 6029 JUnitTestCase.fail("Unexpected invocation of setAnalysisOptions"); | 5365 fail("Unexpected invocation of setAnalysisOptions"); |
| 6030 } | 5366 } |
| 6031 @override | 5367 @override |
| 6032 void set analysisPriorityOrder(List<Source> sources) { | 5368 void set analysisPriorityOrder(List<Source> sources) { |
| 6033 JUnitTestCase.fail("Unexpected invocation of setAnalysisPriorityOrder"); | 5369 fail("Unexpected invocation of setAnalysisPriorityOrder"); |
| 6034 } | 5370 } |
| 6035 @override | 5371 @override |
| 6036 DeclaredVariables get declaredVariables { | 5372 DeclaredVariables get declaredVariables { |
| 6037 JUnitTestCase.fail("Unexpected invocation of getDeclaredVariables"); | 5373 fail("Unexpected invocation of getDeclaredVariables"); |
| 6038 return null; | 5374 return null; |
| 6039 } | 5375 } |
| 6040 @override | 5376 @override |
| 6041 List<Source> get htmlSources { | 5377 List<Source> get htmlSources { |
| 6042 JUnitTestCase.fail("Unexpected invocation of getHtmlSources"); | 5378 fail("Unexpected invocation of getHtmlSources"); |
| 6043 return null; | 5379 return null; |
| 6044 } | 5380 } |
| 6045 @override | 5381 @override |
| 6046 bool get isDisposed { | 5382 bool get isDisposed { |
| 6047 JUnitTestCase.fail("Unexpected invocation of isDisposed"); | 5383 fail("Unexpected invocation of isDisposed"); |
| 6048 return false; | 5384 return false; |
| 6049 } | 5385 } |
| 6050 @override | 5386 @override |
| 6051 List<Source> get launchableClientLibrarySources { | 5387 List<Source> get launchableClientLibrarySources { |
| 6052 JUnitTestCase.fail( | 5388 fail("Unexpected invocation of getLaunchableClientLibrarySources"); |
| 6053 "Unexpected invocation of getLaunchableClientLibrarySources"); | |
| 6054 return null; | 5389 return null; |
| 6055 } | 5390 } |
| 6056 @override | 5391 @override |
| 6057 List<Source> get launchableServerLibrarySources { | 5392 List<Source> get launchableServerLibrarySources { |
| 6058 JUnitTestCase.fail( | 5393 fail("Unexpected invocation of getLaunchableServerLibrarySources"); |
| 6059 "Unexpected invocation of getLaunchableServerLibrarySources"); | |
| 6060 return null; | 5394 return null; |
| 6061 } | 5395 } |
| 6062 @override | 5396 @override |
| 6063 List<Source> get librarySources { | 5397 List<Source> get librarySources { |
| 6064 JUnitTestCase.fail("Unexpected invocation of getLibrarySources"); | 5398 fail("Unexpected invocation of getLibrarySources"); |
| 6065 return null; | 5399 return null; |
| 6066 } | 5400 } |
| 6067 @override | 5401 @override |
| 6068 List<Source> get prioritySources { | 5402 List<Source> get prioritySources { |
| 6069 JUnitTestCase.fail("Unexpected invocation of getPrioritySources"); | 5403 fail("Unexpected invocation of getPrioritySources"); |
| 6070 return null; | 5404 return null; |
| 6071 } | 5405 } |
| 6072 @override | 5406 @override |
| 6073 List<Source> get refactoringUnsafeSources { | 5407 List<Source> get refactoringUnsafeSources { |
| 6074 JUnitTestCase.fail("Unexpected invocation of getRefactoringUnsafeSources"); | 5408 fail("Unexpected invocation of getRefactoringUnsafeSources"); |
| 6075 return null; | 5409 return null; |
| 6076 } | 5410 } |
| 6077 @override | 5411 @override |
| 6078 SourceFactory get sourceFactory { | 5412 SourceFactory get sourceFactory { |
| 6079 JUnitTestCase.fail("Unexpected invocation of getSourceFactory"); | 5413 fail("Unexpected invocation of getSourceFactory"); |
| 6080 return null; | 5414 return null; |
| 6081 } | 5415 } |
| 6082 @override | 5416 @override |
| 6083 void set sourceFactory(SourceFactory factory) { | 5417 void set sourceFactory(SourceFactory factory) { |
| 6084 JUnitTestCase.fail("Unexpected invocation of setSourceFactory"); | 5418 fail("Unexpected invocation of setSourceFactory"); |
| 6085 } | 5419 } |
| 6086 @override | 5420 @override |
| 6087 AnalysisContextStatistics get statistics { | 5421 AnalysisContextStatistics get statistics { |
| 6088 JUnitTestCase.fail("Unexpected invocation of getStatistics"); | 5422 fail("Unexpected invocation of getStatistics"); |
| 6089 return null; | 5423 return null; |
| 6090 } | 5424 } |
| 6091 @override | 5425 @override |
| 6092 TypeProvider get typeProvider { | 5426 TypeProvider get typeProvider { |
| 6093 JUnitTestCase.fail("Unexpected invocation of getTypeProvider"); | 5427 fail("Unexpected invocation of getTypeProvider"); |
| 6094 return null; | 5428 return null; |
| 6095 } | 5429 } |
| 6096 @override | 5430 @override |
| 6097 void addListener(AnalysisListener listener) { | 5431 void addListener(AnalysisListener listener) { |
| 6098 JUnitTestCase.fail("Unexpected invocation of addListener"); | 5432 fail("Unexpected invocation of addListener"); |
| 6099 } | 5433 } |
| 6100 @override | 5434 @override |
| 6101 void addSourceInfo(Source source, SourceEntry info) { | 5435 void addSourceInfo(Source source, SourceEntry info) { |
| 6102 JUnitTestCase.fail("Unexpected invocation of addSourceInfo"); | 5436 fail("Unexpected invocation of addSourceInfo"); |
| 6103 } | 5437 } |
| 6104 @override | 5438 @override |
| 6105 void applyAnalysisDelta(AnalysisDelta delta) { | 5439 void applyAnalysisDelta(AnalysisDelta delta) { |
| 6106 JUnitTestCase.fail("Unexpected invocation of applyAnalysisDelta"); | 5440 fail("Unexpected invocation of applyAnalysisDelta"); |
| 6107 } | 5441 } |
| 6108 @override | 5442 @override |
| 6109 void applyChanges(ChangeSet changeSet) { | 5443 void applyChanges(ChangeSet changeSet) { |
| 6110 JUnitTestCase.fail("Unexpected invocation of applyChanges"); | 5444 fail("Unexpected invocation of applyChanges"); |
| 6111 } | 5445 } |
| 6112 @override | 5446 @override |
| 6113 String computeDocumentationComment(Element element) { | 5447 String computeDocumentationComment(Element element) { |
| 6114 JUnitTestCase.fail("Unexpected invocation of computeDocumentationComment"); | 5448 fail("Unexpected invocation of computeDocumentationComment"); |
| 6115 return null; | 5449 return null; |
| 6116 } | 5450 } |
| 6117 @override | 5451 @override |
| 6118 List<AnalysisError> computeErrors(Source source) { | 5452 List<AnalysisError> computeErrors(Source source) { |
| 6119 JUnitTestCase.fail("Unexpected invocation of computeErrors"); | 5453 fail("Unexpected invocation of computeErrors"); |
| 6120 return null; | 5454 return null; |
| 6121 } | 5455 } |
| 6122 @override | 5456 @override |
| 6123 List<Source> computeExportedLibraries(Source source) { | 5457 List<Source> computeExportedLibraries(Source source) { |
| 6124 JUnitTestCase.fail("Unexpected invocation of computeExportedLibraries"); | 5458 fail("Unexpected invocation of computeExportedLibraries"); |
| 6125 return null; | 5459 return null; |
| 6126 } | 5460 } |
| 6127 @override | 5461 @override |
| 6128 HtmlElement computeHtmlElement(Source source) { | 5462 HtmlElement computeHtmlElement(Source source) { |
| 6129 JUnitTestCase.fail("Unexpected invocation of computeHtmlElement"); | 5463 fail("Unexpected invocation of computeHtmlElement"); |
| 6130 return null; | 5464 return null; |
| 6131 } | 5465 } |
| 6132 @override | 5466 @override |
| 6133 List<Source> computeImportedLibraries(Source source) { | 5467 List<Source> computeImportedLibraries(Source source) { |
| 6134 JUnitTestCase.fail("Unexpected invocation of computeImportedLibraries"); | 5468 fail("Unexpected invocation of computeImportedLibraries"); |
| 6135 return null; | 5469 return null; |
| 6136 } | 5470 } |
| 6137 @override | 5471 @override |
| 6138 SourceKind computeKindOf(Source source) { | 5472 SourceKind computeKindOf(Source source) { |
| 6139 JUnitTestCase.fail("Unexpected invocation of computeKindOf"); | 5473 fail("Unexpected invocation of computeKindOf"); |
| 6140 return null; | 5474 return null; |
| 6141 } | 5475 } |
| 6142 @override | 5476 @override |
| 6143 LibraryElement computeLibraryElement(Source source) { | 5477 LibraryElement computeLibraryElement(Source source) { |
| 6144 JUnitTestCase.fail("Unexpected invocation of computeLibraryElement"); | 5478 fail("Unexpected invocation of computeLibraryElement"); |
| 6145 return null; | 5479 return null; |
| 6146 } | 5480 } |
| 6147 @override | 5481 @override |
| 6148 LineInfo computeLineInfo(Source source) { | 5482 LineInfo computeLineInfo(Source source) { |
| 6149 JUnitTestCase.fail("Unexpected invocation of computeLineInfo"); | 5483 fail("Unexpected invocation of computeLineInfo"); |
| 6150 return null; | 5484 return null; |
| 6151 } | 5485 } |
| 6152 @override | 5486 @override |
| 6153 CompilationUnit computeResolvableCompilationUnit(Source source) { | 5487 CompilationUnit computeResolvableCompilationUnit(Source source) { |
| 6154 JUnitTestCase.fail( | 5488 fail("Unexpected invocation of computeResolvableCompilationUnit"); |
| 6155 "Unexpected invocation of computeResolvableCompilationUnit"); | |
| 6156 return null; | 5489 return null; |
| 6157 } | 5490 } |
| 6158 @override | 5491 @override |
| 6159 void dispose() { | 5492 void dispose() { |
| 6160 JUnitTestCase.fail("Unexpected invocation of dispose"); | 5493 fail("Unexpected invocation of dispose"); |
| 6161 } | 5494 } |
| 6162 @override | 5495 @override |
| 6163 bool exists(Source source) { | 5496 bool exists(Source source) { |
| 6164 JUnitTestCase.fail("Unexpected invocation of exists"); | 5497 fail("Unexpected invocation of exists"); |
| 6165 return false; | 5498 return false; |
| 6166 } | 5499 } |
| 6167 @override | 5500 @override |
| 6168 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { | 5501 AngularApplication getAngularApplicationWithHtml(Source htmlSource) { |
| 6169 JUnitTestCase.fail( | 5502 fail("Unexpected invocation of getAngularApplicationWithHtml"); |
| 6170 "Unexpected invocation of getAngularApplicationWithHtml"); | |
| 6171 return null; | 5503 return null; |
| 6172 } | 5504 } |
| 6173 @override | 5505 @override |
| 6174 CompilationUnitElement getCompilationUnitElement(Source unitSource, | 5506 CompilationUnitElement getCompilationUnitElement(Source unitSource, |
| 6175 Source librarySource) { | 5507 Source librarySource) { |
| 6176 JUnitTestCase.fail("Unexpected invocation of getCompilationUnitElement"); | 5508 fail("Unexpected invocation of getCompilationUnitElement"); |
| 6177 return null; | 5509 return null; |
| 6178 } | 5510 } |
| 6179 @override | 5511 @override |
| 6180 TimestampedData<String> getContents(Source source) { | 5512 TimestampedData<String> getContents(Source source) { |
| 6181 JUnitTestCase.fail("Unexpected invocation of getContents"); | 5513 fail("Unexpected invocation of getContents"); |
| 6182 return null; | 5514 return null; |
| 6183 } | 5515 } |
| 6184 @override | 5516 @override |
| 6185 InternalAnalysisContext getContextFor(Source source) { | 5517 InternalAnalysisContext getContextFor(Source source) { |
| 6186 JUnitTestCase.fail("Unexpected invocation of getContextFor"); | 5518 fail("Unexpected invocation of getContextFor"); |
| 6187 return null; | 5519 return null; |
| 6188 } | 5520 } |
| 6189 @override | 5521 @override |
| 6190 Element getElement(ElementLocation location) { | 5522 Element getElement(ElementLocation location) { |
| 6191 JUnitTestCase.fail("Unexpected invocation of getElement"); | 5523 fail("Unexpected invocation of getElement"); |
| 6192 return null; | 5524 return null; |
| 6193 } | 5525 } |
| 6194 @override | 5526 @override |
| 6195 AnalysisErrorInfo getErrors(Source source) { | 5527 AnalysisErrorInfo getErrors(Source source) { |
| 6196 JUnitTestCase.fail("Unexpected invocation of getErrors"); | 5528 fail("Unexpected invocation of getErrors"); |
| 6197 return null; | 5529 return null; |
| 6198 } | 5530 } |
| 6199 @override | 5531 @override |
| 6200 HtmlElement getHtmlElement(Source source) { | 5532 HtmlElement getHtmlElement(Source source) { |
| 6201 JUnitTestCase.fail("Unexpected invocation of getHtmlElement"); | 5533 fail("Unexpected invocation of getHtmlElement"); |
| 6202 return null; | 5534 return null; |
| 6203 } | 5535 } |
| 6204 @override | 5536 @override |
| 6205 List<Source> getHtmlFilesReferencing(Source source) { | 5537 List<Source> getHtmlFilesReferencing(Source source) { |
| 6206 JUnitTestCase.fail("Unexpected invocation of getHtmlFilesReferencing"); | 5538 fail("Unexpected invocation of getHtmlFilesReferencing"); |
| 6207 return null; | 5539 return null; |
| 6208 } | 5540 } |
| 6209 @override | 5541 @override |
| 6210 SourceKind getKindOf(Source source) { | 5542 SourceKind getKindOf(Source source) { |
| 6211 JUnitTestCase.fail("Unexpected invocation of getKindOf"); | 5543 fail("Unexpected invocation of getKindOf"); |
| 6212 return null; | 5544 return null; |
| 6213 } | 5545 } |
| 6214 @override | 5546 @override |
| 6215 List<Source> getLibrariesContaining(Source source) { | 5547 List<Source> getLibrariesContaining(Source source) { |
| 6216 JUnitTestCase.fail("Unexpected invocation of getLibrariesContaining"); | 5548 fail("Unexpected invocation of getLibrariesContaining"); |
| 6217 return null; | 5549 return null; |
| 6218 } | 5550 } |
| 6219 @override | 5551 @override |
| 6220 List<Source> getLibrariesDependingOn(Source librarySource) { | 5552 List<Source> getLibrariesDependingOn(Source librarySource) { |
| 6221 JUnitTestCase.fail("Unexpected invocation of getLibrariesDependingOn"); | 5553 fail("Unexpected invocation of getLibrariesDependingOn"); |
| 6222 return null; | 5554 return null; |
| 6223 } | 5555 } |
| 6224 @override | 5556 @override |
| 6225 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { | 5557 List<Source> getLibrariesReferencedFromHtml(Source htmlSource) { |
| 6226 JUnitTestCase.fail( | 5558 fail("Unexpected invocation of getLibrariesReferencedFromHtml"); |
| 6227 "Unexpected invocation of getLibrariesReferencedFromHtml"); | |
| 6228 return null; | 5559 return null; |
| 6229 } | 5560 } |
| 6230 @override | 5561 @override |
| 6231 LibraryElement getLibraryElement(Source source) { | 5562 LibraryElement getLibraryElement(Source source) { |
| 6232 JUnitTestCase.fail("Unexpected invocation of getLibraryElement"); | 5563 fail("Unexpected invocation of getLibraryElement"); |
| 6233 return null; | 5564 return null; |
| 6234 } | 5565 } |
| 6235 @override | 5566 @override |
| 6236 LineInfo getLineInfo(Source source) { | 5567 LineInfo getLineInfo(Source source) { |
| 6237 JUnitTestCase.fail("Unexpected invocation of getLineInfo"); | 5568 fail("Unexpected invocation of getLineInfo"); |
| 6238 return null; | 5569 return null; |
| 6239 } | 5570 } |
| 6240 @override | 5571 @override |
| 6241 int getModificationStamp(Source source) { | 5572 int getModificationStamp(Source source) { |
| 6242 JUnitTestCase.fail("Unexpected invocation of getModificationStamp"); | 5573 fail("Unexpected invocation of getModificationStamp"); |
| 6243 return 0; | 5574 return 0; |
| 6244 } | 5575 } |
| 6245 @override | 5576 @override |
| 6246 Namespace getPublicNamespace(LibraryElement library) { | 5577 Namespace getPublicNamespace(LibraryElement library) { |
| 6247 JUnitTestCase.fail("Unexpected invocation of getPublicNamespace"); | 5578 fail("Unexpected invocation of getPublicNamespace"); |
| 6248 return null; | 5579 return null; |
| 6249 } | 5580 } |
| 6250 @override | 5581 @override |
| 6251 CompilationUnit getResolvedCompilationUnit(Source unitSource, | 5582 CompilationUnit getResolvedCompilationUnit(Source unitSource, |
| 6252 LibraryElement library) { | 5583 LibraryElement library) { |
| 6253 JUnitTestCase.fail("Unexpected invocation of getResolvedCompilationUnit"); | 5584 fail("Unexpected invocation of getResolvedCompilationUnit"); |
| 6254 return null; | 5585 return null; |
| 6255 } | 5586 } |
| 6256 @override | 5587 @override |
| 6257 CompilationUnit getResolvedCompilationUnit2(Source unitSource, | 5588 CompilationUnit getResolvedCompilationUnit2(Source unitSource, |
| 6258 Source librarySource) { | 5589 Source librarySource) { |
| 6259 JUnitTestCase.fail("Unexpected invocation of getResolvedCompilationUnit"); | 5590 fail("Unexpected invocation of getResolvedCompilationUnit"); |
| 6260 return null; | 5591 return null; |
| 6261 } | 5592 } |
| 6262 @override | 5593 @override |
| 6263 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { | 5594 ht.HtmlUnit getResolvedHtmlUnit(Source htmlSource) { |
| 6264 JUnitTestCase.fail("Unexpected invocation of getResolvedHtmlUnit"); | 5595 fail("Unexpected invocation of getResolvedHtmlUnit"); |
| 6265 return null; | 5596 return null; |
| 6266 } | 5597 } |
| 6267 @override | 5598 @override |
| 6268 bool isClientLibrary(Source librarySource) { | 5599 bool isClientLibrary(Source librarySource) { |
| 6269 JUnitTestCase.fail("Unexpected invocation of isClientLibrary"); | 5600 fail("Unexpected invocation of isClientLibrary"); |
| 6270 return false; | 5601 return false; |
| 6271 } | 5602 } |
| 6272 @override | 5603 @override |
| 6273 bool isServerLibrary(Source librarySource) { | 5604 bool isServerLibrary(Source librarySource) { |
| 6274 JUnitTestCase.fail("Unexpected invocation of isServerLibrary"); | 5605 fail("Unexpected invocation of isServerLibrary"); |
| 6275 return false; | 5606 return false; |
| 6276 } | 5607 } |
| 6277 @override | 5608 @override |
| 6278 CompilationUnit parseCompilationUnit(Source source) { | 5609 CompilationUnit parseCompilationUnit(Source source) { |
| 6279 JUnitTestCase.fail("Unexpected invocation of parseCompilationUnit"); | 5610 fail("Unexpected invocation of parseCompilationUnit"); |
| 6280 return null; | 5611 return null; |
| 6281 } | 5612 } |
| 6282 @override | 5613 @override |
| 6283 ht.HtmlUnit parseHtmlUnit(Source source) { | 5614 ht.HtmlUnit parseHtmlUnit(Source source) { |
| 6284 JUnitTestCase.fail("Unexpected invocation of parseHtmlUnit"); | 5615 fail("Unexpected invocation of parseHtmlUnit"); |
| 6285 return null; | 5616 return null; |
| 6286 } | 5617 } |
| 6287 @override | 5618 @override |
| 6288 AnalysisResult performAnalysisTask() { | 5619 AnalysisResult performAnalysisTask() { |
| 6289 JUnitTestCase.fail("Unexpected invocation of performAnalysisTask"); | 5620 fail("Unexpected invocation of performAnalysisTask"); |
| 6290 return null; | 5621 return null; |
| 6291 } | 5622 } |
| 6292 @override | 5623 @override |
| 6293 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 5624 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 6294 JUnitTestCase.fail("Unexpected invocation of recordLibraryElements"); | 5625 fail("Unexpected invocation of recordLibraryElements"); |
| 6295 } | 5626 } |
| 6296 @override | 5627 @override |
| 6297 void removeListener(AnalysisListener listener) { | 5628 void removeListener(AnalysisListener listener) { |
| 6298 JUnitTestCase.fail("Unexpected invocation of removeListener"); | 5629 fail("Unexpected invocation of removeListener"); |
| 6299 } | 5630 } |
| 6300 @override | 5631 @override |
| 6301 CompilationUnit resolveCompilationUnit(Source unitSource, | 5632 CompilationUnit resolveCompilationUnit(Source unitSource, |
| 6302 LibraryElement library) { | 5633 LibraryElement library) { |
| 6303 JUnitTestCase.fail("Unexpected invocation of resolveCompilationUnit"); | 5634 fail("Unexpected invocation of resolveCompilationUnit"); |
| 6304 return null; | 5635 return null; |
| 6305 } | 5636 } |
| 6306 @override | 5637 @override |
| 6307 CompilationUnit resolveCompilationUnit2(Source unitSource, | 5638 CompilationUnit resolveCompilationUnit2(Source unitSource, |
| 6308 Source librarySource) { | 5639 Source librarySource) { |
| 6309 JUnitTestCase.fail("Unexpected invocation of resolveCompilationUnit"); | 5640 fail("Unexpected invocation of resolveCompilationUnit"); |
| 6310 return null; | 5641 return null; |
| 6311 } | 5642 } |
| 6312 @override | 5643 @override |
| 6313 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { | 5644 ht.HtmlUnit resolveHtmlUnit(Source htmlSource) { |
| 6314 JUnitTestCase.fail("Unexpected invocation of resolveHtmlUnit"); | 5645 fail("Unexpected invocation of resolveHtmlUnit"); |
| 6315 return null; | 5646 return null; |
| 6316 } | 5647 } |
| 6317 @override | 5648 @override |
| 6318 void setChangedContents(Source source, String contents, int offset, | 5649 void setChangedContents(Source source, String contents, int offset, |
| 6319 int oldLength, int newLength) { | 5650 int oldLength, int newLength) { |
| 6320 JUnitTestCase.fail("Unexpected invocation of setChangedContents"); | 5651 fail("Unexpected invocation of setChangedContents"); |
| 6321 } | 5652 } |
| 6322 @override | 5653 @override |
| 6323 void setContents(Source source, String contents) { | 5654 void setContents(Source source, String contents) { |
| 6324 JUnitTestCase.fail("Unexpected invocation of setContents"); | 5655 fail("Unexpected invocation of setContents"); |
| 6325 } | 5656 } |
| 6326 } | 5657 } |
| 6327 | 5658 |
| 6328 | 5659 |
| 6329 class TestAnalysisContext_test_addSourceInfo extends TestAnalysisContext { | 5660 class TestAnalysisContext_test_addSourceInfo extends TestAnalysisContext { |
| 6330 List<bool> invoked; | 5661 List<bool> invoked; |
| 6331 TestAnalysisContext_test_addSourceInfo(this.invoked); | 5662 TestAnalysisContext_test_addSourceInfo(this.invoked); |
| 6332 @override | 5663 @override |
| 6333 void addSourceInfo(Source source, SourceEntry info) { | 5664 void addSourceInfo(Source source, SourceEntry info) { |
| 6334 invoked[0] = true; | 5665 invoked[0] = true; |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6951 | 6282 |
| 6952 | 6283 |
| 6953 /** | 6284 /** |
| 6954 * Instances of the class `TestTaskVisitor` implement a task visitor that fails
if any of its | 6285 * Instances of the class `TestTaskVisitor` implement a task visitor that fails
if any of its |
| 6955 * methods are invoked. Subclasses typically override the expected methods to no
t cause a test | 6286 * methods are invoked. Subclasses typically override the expected methods to no
t cause a test |
| 6956 * failure. | 6287 * failure. |
| 6957 */ | 6288 */ |
| 6958 class TestTaskVisitor<E> implements AnalysisTaskVisitor<E> { | 6289 class TestTaskVisitor<E> implements AnalysisTaskVisitor<E> { |
| 6959 @override | 6290 @override |
| 6960 E visitBuildUnitElementTask(BuildUnitElementTask task) { | 6291 E visitBuildUnitElementTask(BuildUnitElementTask task) { |
| 6961 JUnitTestCase.fail("Unexpectedly invoked visitGenerateDartErrorsTask"); | 6292 fail("Unexpectedly invoked visitGenerateDartErrorsTask"); |
| 6962 return null; | 6293 return null; |
| 6963 } | 6294 } |
| 6964 | 6295 |
| 6965 @override | 6296 @override |
| 6966 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 6297 E visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 6967 JUnitTestCase.fail("Unexpectedly invoked visitGenerateDartErrorsTask"); | 6298 fail("Unexpectedly invoked visitGenerateDartErrorsTask"); |
| 6968 return null; | 6299 return null; |
| 6969 } | 6300 } |
| 6970 @override | 6301 @override |
| 6971 E visitGenerateDartHintsTask(GenerateDartHintsTask task) { | 6302 E visitGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 6972 JUnitTestCase.fail("Unexpectedly invoked visitGenerateDartHintsTask"); | 6303 fail("Unexpectedly invoked visitGenerateDartHintsTask"); |
| 6973 return null; | 6304 return null; |
| 6974 } | 6305 } |
| 6975 @override | 6306 @override |
| 6976 E visitGetContentTask(GetContentTask task) { | 6307 E visitGetContentTask(GetContentTask task) { |
| 6977 JUnitTestCase.fail("Unexpectedly invoked visitGetContentsTask"); | 6308 fail("Unexpectedly invoked visitGetContentsTask"); |
| 6978 return null; | 6309 return null; |
| 6979 } | 6310 } |
| 6980 @override | 6311 @override |
| 6981 E | 6312 E |
| 6982 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) { | 6313 visitIncrementalAnalysisTask(IncrementalAnalysisTask incrementalAnalysisTa
sk) { |
| 6983 JUnitTestCase.fail("Unexpectedly invoked visitIncrementalAnalysisTask"); | 6314 fail("Unexpectedly invoked visitIncrementalAnalysisTask"); |
| 6984 return null; | 6315 return null; |
| 6985 } | 6316 } |
| 6986 @override | 6317 @override |
| 6987 E visitParseDartTask(ParseDartTask task) { | 6318 E visitParseDartTask(ParseDartTask task) { |
| 6988 JUnitTestCase.fail("Unexpectedly invoked visitParseDartTask"); | 6319 fail("Unexpectedly invoked visitParseDartTask"); |
| 6989 return null; | 6320 return null; |
| 6990 } | 6321 } |
| 6991 @override | 6322 @override |
| 6992 E visitParseHtmlTask(ParseHtmlTask task) { | 6323 E visitParseHtmlTask(ParseHtmlTask task) { |
| 6993 JUnitTestCase.fail("Unexpectedly invoked visitParseHtmlTask"); | 6324 fail("Unexpectedly invoked visitParseHtmlTask"); |
| 6994 return null; | 6325 return null; |
| 6995 } | 6326 } |
| 6996 @override | 6327 @override |
| 6997 E visitPolymerBuildHtmlTask(PolymerBuildHtmlTask task) { | 6328 E visitPolymerBuildHtmlTask(PolymerBuildHtmlTask task) { |
| 6998 JUnitTestCase.fail("Unexpectedly invoked visitPolymerBuildHtmlTask"); | 6329 fail("Unexpectedly invoked visitPolymerBuildHtmlTask"); |
| 6999 return null; | 6330 return null; |
| 7000 } | 6331 } |
| 7001 @override | 6332 @override |
| 7002 E visitPolymerResolveHtmlTask(PolymerResolveHtmlTask task) { | 6333 E visitPolymerResolveHtmlTask(PolymerResolveHtmlTask task) { |
| 7003 JUnitTestCase.fail("Unexpectedly invoked visitPolymerResolveHtmlTask"); | 6334 fail("Unexpectedly invoked visitPolymerResolveHtmlTask"); |
| 7004 return null; | 6335 return null; |
| 7005 } | 6336 } |
| 7006 @override | 6337 @override |
| 7007 E | 6338 E |
| 7008 visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTa
sk task) { | 6339 visitResolveAngularComponentTemplateTask(ResolveAngularComponentTemplateTa
sk task) { |
| 7009 JUnitTestCase.fail( | 6340 fail("Unexpectedly invoked visitResolveAngularComponentTemplateTask"); |
| 7010 "Unexpectedly invoked visitResolveAngularComponentTemplateTask"); | |
| 7011 return null; | 6341 return null; |
| 7012 } | 6342 } |
| 7013 @override | 6343 @override |
| 7014 E visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) { | 6344 E visitResolveAngularEntryHtmlTask(ResolveAngularEntryHtmlTask task) { |
| 7015 JUnitTestCase.fail("Unexpectedly invoked visitResolveAngularEntryHtmlTask"); | 6345 fail("Unexpectedly invoked visitResolveAngularEntryHtmlTask"); |
| 7016 return null; | 6346 return null; |
| 7017 } | 6347 } |
| 7018 @override | 6348 @override |
| 7019 E visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) { | 6349 E visitResolveDartLibraryCycleTask(ResolveDartLibraryCycleTask task) { |
| 7020 JUnitTestCase.fail("Unexpectedly invoked visitResolveDartLibraryCycleTask"); | 6350 fail("Unexpectedly invoked visitResolveDartLibraryCycleTask"); |
| 7021 return null; | 6351 return null; |
| 7022 } | 6352 } |
| 7023 @override | 6353 @override |
| 7024 E visitResolveDartLibraryTask(ResolveDartLibraryTask task) { | 6354 E visitResolveDartLibraryTask(ResolveDartLibraryTask task) { |
| 7025 JUnitTestCase.fail("Unexpectedly invoked visitResolveDartLibraryTask"); | 6355 fail("Unexpectedly invoked visitResolveDartLibraryTask"); |
| 7026 return null; | 6356 return null; |
| 7027 } | 6357 } |
| 7028 @override | 6358 @override |
| 7029 E visitResolveDartUnitTask(ResolveDartUnitTask task) { | 6359 E visitResolveDartUnitTask(ResolveDartUnitTask task) { |
| 7030 JUnitTestCase.fail("Unexpectedly invoked visitResolveDartUnitTask"); | 6360 fail("Unexpectedly invoked visitResolveDartUnitTask"); |
| 7031 return null; | 6361 return null; |
| 7032 } | 6362 } |
| 7033 @override | 6363 @override |
| 7034 E visitResolveHtmlTask(ResolveHtmlTask task) { | 6364 E visitResolveHtmlTask(ResolveHtmlTask task) { |
| 7035 JUnitTestCase.fail("Unexpectedly invoked visitResolveHtmlTask"); | 6365 fail("Unexpectedly invoked visitResolveHtmlTask"); |
| 7036 return null; | 6366 return null; |
| 7037 } | 6367 } |
| 7038 @override | 6368 @override |
| 7039 E visitScanDartTask(ScanDartTask task) { | 6369 E visitScanDartTask(ScanDartTask task) { |
| 7040 JUnitTestCase.fail("Unexpectedly invoked visitScanDartTask"); | 6370 fail("Unexpectedly invoked visitScanDartTask"); |
| 7041 return null; | 6371 return null; |
| 7042 } | 6372 } |
| 7043 } | 6373 } |
| 7044 | 6374 |
| 7045 | 6375 |
| 7046 class UniversalCachePartitionTest extends EngineTestCase { | 6376 class UniversalCachePartitionTest extends EngineTestCase { |
| 7047 void test_contains() { | 6377 void test_contains() { |
| 7048 UniversalCachePartition partition = | 6378 UniversalCachePartition partition = |
| 7049 new UniversalCachePartition(null, 8, null); | 6379 new UniversalCachePartition(null, 8, null); |
| 7050 TestSource source = new TestSource(); | 6380 TestSource source = new TestSource(); |
| 7051 JUnitTestCase.assertTrue(partition.contains(source)); | 6381 expect(partition.contains(source), isTrue); |
| 7052 } | 6382 } |
| 7053 void test_creation() { | 6383 void test_creation() { |
| 7054 JUnitTestCase.assertNotNull(new UniversalCachePartition(null, 8, null)); | 6384 expect(new UniversalCachePartition(null, 8, null), isNotNull); |
| 7055 } | 6385 } |
| 7056 void test_entrySet() { | 6386 void test_entrySet() { |
| 7057 UniversalCachePartition partition = | 6387 UniversalCachePartition partition = |
| 7058 new UniversalCachePartition(null, 8, null); | 6388 new UniversalCachePartition(null, 8, null); |
| 7059 TestSource source = new TestSource(); | 6389 TestSource source = new TestSource(); |
| 7060 DartEntry entry = new DartEntry(); | 6390 DartEntry entry = new DartEntry(); |
| 7061 partition.put(source, entry); | 6391 partition.put(source, entry); |
| 7062 Map<Source, SourceEntry> entryMap = partition.map; | 6392 Map<Source, SourceEntry> entryMap = partition.map; |
| 7063 JUnitTestCase.assertEquals(1, entryMap.length); | 6393 expect(entryMap.length, 1); |
| 7064 Source entryKey = entryMap.keys.first; | 6394 Source entryKey = entryMap.keys.first; |
| 7065 JUnitTestCase.assertSame(source, entryKey); | 6395 expect(entryKey, same(source)); |
| 7066 JUnitTestCase.assertSame(entry, entryMap[entryKey]); | 6396 expect(entryMap[entryKey], same(entry)); |
| 7067 } | 6397 } |
| 7068 void test_get() { | 6398 void test_get() { |
| 7069 UniversalCachePartition partition = | 6399 UniversalCachePartition partition = |
| 7070 new UniversalCachePartition(null, 8, null); | 6400 new UniversalCachePartition(null, 8, null); |
| 7071 TestSource source = new TestSource(); | 6401 TestSource source = new TestSource(); |
| 7072 JUnitTestCase.assertNull(partition.get(source)); | 6402 expect(partition.get(source), isNull); |
| 7073 } | 6403 } |
| 7074 void test_put_noFlush() { | 6404 void test_put_noFlush() { |
| 7075 UniversalCachePartition partition = | 6405 UniversalCachePartition partition = |
| 7076 new UniversalCachePartition(null, 8, null); | 6406 new UniversalCachePartition(null, 8, null); |
| 7077 TestSource source = new TestSource(); | 6407 TestSource source = new TestSource(); |
| 7078 DartEntry entry = new DartEntry(); | 6408 DartEntry entry = new DartEntry(); |
| 7079 partition.put(source, entry); | 6409 partition.put(source, entry); |
| 7080 JUnitTestCase.assertSame(entry, partition.get(source)); | 6410 expect(partition.get(source), same(entry)); |
| 7081 } | 6411 } |
| 7082 void test_remove() { | 6412 void test_remove() { |
| 7083 UniversalCachePartition partition = | 6413 UniversalCachePartition partition = |
| 7084 new UniversalCachePartition(null, 8, null); | 6414 new UniversalCachePartition(null, 8, null); |
| 7085 TestSource source = new TestSource(); | 6415 TestSource source = new TestSource(); |
| 7086 DartEntry entry = new DartEntry(); | 6416 DartEntry entry = new DartEntry(); |
| 7087 partition.put(source, entry); | 6417 partition.put(source, entry); |
| 7088 JUnitTestCase.assertSame(entry, partition.get(source)); | 6418 expect(partition.get(source), same(entry)); |
| 7089 partition.remove(source); | 6419 partition.remove(source); |
| 7090 JUnitTestCase.assertNull(partition.get(source)); | 6420 expect(partition.get(source), isNull); |
| 7091 } | 6421 } |
| 7092 void test_setMaxCacheSize() { | 6422 void test_setMaxCacheSize() { |
| 7093 UniversalCachePartition partition = new UniversalCachePartition( | 6423 UniversalCachePartition partition = new UniversalCachePartition( |
| 7094 null, | 6424 null, |
| 7095 8, | 6425 8, |
| 7096 new _UniversalCachePartitionTest_test_setMaxCacheSize()); | 6426 new _UniversalCachePartitionTest_test_setMaxCacheSize()); |
| 7097 int size = 6; | 6427 int size = 6; |
| 7098 for (int i = 0; i < size; i++) { | 6428 for (int i = 0; i < size; i++) { |
| 7099 Source source = new TestSource("/test$i.dart"); | 6429 Source source = new TestSource("/test$i.dart"); |
| 7100 DartEntry entry = new DartEntry(); | 6430 DartEntry entry = new DartEntry(); |
| 7101 entry.setValue(DartEntry.PARSED_UNIT, null); | 6431 entry.setValue(DartEntry.PARSED_UNIT, null); |
| 7102 partition.put(source, entry); | 6432 partition.put(source, entry); |
| 7103 partition.accessedAst(source); | 6433 partition.accessedAst(source); |
| 7104 } | 6434 } |
| 7105 _assertNonFlushedCount(size, partition); | 6435 _assertNonFlushedCount(size, partition); |
| 7106 int newSize = size - 2; | 6436 int newSize = size - 2; |
| 7107 partition.maxCacheSize = newSize; | 6437 partition.maxCacheSize = newSize; |
| 7108 _assertNonFlushedCount(newSize, partition); | 6438 _assertNonFlushedCount(newSize, partition); |
| 7109 } | 6439 } |
| 7110 void test_size() { | 6440 void test_size() { |
| 7111 UniversalCachePartition partition = | 6441 UniversalCachePartition partition = |
| 7112 new UniversalCachePartition(null, 8, null); | 6442 new UniversalCachePartition(null, 8, null); |
| 7113 int size = 4; | 6443 int size = 4; |
| 7114 for (int i = 0; i < size; i++) { | 6444 for (int i = 0; i < size; i++) { |
| 7115 Source source = new TestSource("/test$i.dart"); | 6445 Source source = new TestSource("/test$i.dart"); |
| 7116 partition.put(source, new DartEntry()); | 6446 partition.put(source, new DartEntry()); |
| 7117 partition.accessedAst(source); | 6447 partition.accessedAst(source); |
| 7118 } | 6448 } |
| 7119 JUnitTestCase.assertEquals(size, partition.size()); | 6449 expect(partition.size(), size); |
| 7120 } | 6450 } |
| 7121 void _assertNonFlushedCount(int expectedCount, | 6451 void _assertNonFlushedCount(int expectedCount, |
| 7122 UniversalCachePartition partition) { | 6452 UniversalCachePartition partition) { |
| 7123 int nonFlushedCount = 0; | 6453 int nonFlushedCount = 0; |
| 7124 Map<Source, SourceEntry> entryMap = partition.map; | 6454 Map<Source, SourceEntry> entryMap = partition.map; |
| 7125 entryMap.values.forEach((SourceEntry value) { | 6455 entryMap.values.forEach((SourceEntry value) { |
| 7126 if (value.getState(DartEntry.PARSED_UNIT) != CacheState.FLUSHED) { | 6456 if (value.getState(DartEntry.PARSED_UNIT) != CacheState.FLUSHED) { |
| 7127 nonFlushedCount++; | 6457 nonFlushedCount++; |
| 7128 } | 6458 } |
| 7129 }); | 6459 }); |
| 7130 JUnitTestCase.assertEquals(expectedCount, nonFlushedCount); | 6460 expect(nonFlushedCount, expectedCount); |
| 7131 } | 6461 } |
| 7132 } | 6462 } |
| 7133 | 6463 |
| 7134 | 6464 |
| 7135 class WorkManagerTest extends EngineTestCase { | 6465 class WorkManagerTest extends EngineTestCase { |
| 7136 void test_addFirst() { | 6466 void test_addFirst() { |
| 7137 TestSource source1 = new TestSource("/f1.dart"); | 6467 TestSource source1 = new TestSource("/f1.dart"); |
| 7138 TestSource source2 = new TestSource("/f2.dart"); | 6468 TestSource source2 = new TestSource("/f2.dart"); |
| 7139 WorkManager manager = new WorkManager(); | 6469 WorkManager manager = new WorkManager(); |
| 7140 manager.add(source1, SourcePriority.UNKNOWN); | 6470 manager.add(source1, SourcePriority.UNKNOWN); |
| 7141 manager.addFirst(source2, SourcePriority.UNKNOWN); | 6471 manager.addFirst(source2, SourcePriority.UNKNOWN); |
| 7142 WorkManager_WorkIterator iterator = manager.iterator(); | 6472 WorkManager_WorkIterator iterator = manager.iterator(); |
| 7143 JUnitTestCase.assertSame(source2, iterator.next()); | 6473 expect(iterator.next(), same(source2)); |
| 7144 JUnitTestCase.assertSame(source1, iterator.next()); | 6474 expect(iterator.next(), same(source1)); |
| 7145 } | 6475 } |
| 7146 void test_creation() { | 6476 void test_creation() { |
| 7147 JUnitTestCase.assertNotNull(new WorkManager()); | 6477 expect(new WorkManager(), isNotNull); |
| 7148 } | 6478 } |
| 7149 void test_iterator_empty() { | 6479 void test_iterator_empty() { |
| 7150 WorkManager manager = new WorkManager(); | 6480 WorkManager manager = new WorkManager(); |
| 7151 WorkManager_WorkIterator iterator = manager.iterator(); | 6481 WorkManager_WorkIterator iterator = manager.iterator(); |
| 7152 JUnitTestCase.assertFalse(iterator.hasNext); | 6482 expect(iterator.hasNext, isFalse); |
| 7153 try { | 6483 try { |
| 7154 iterator.next(); | 6484 iterator.next(); |
| 7155 JUnitTestCase.fail("Expected NoSuchElementException"); | 6485 fail("Expected NoSuchElementException"); |
| 7156 } on NoSuchElementException catch (exception) { | 6486 } on NoSuchElementException catch (exception) { |
| 7157 } | 6487 } |
| 7158 } | 6488 } |
| 7159 void test_iterator_nonEmpty() { | 6489 void test_iterator_nonEmpty() { |
| 7160 TestSource source = new TestSource(); | 6490 TestSource source = new TestSource(); |
| 7161 WorkManager manager = new WorkManager(); | 6491 WorkManager manager = new WorkManager(); |
| 7162 manager.add(source, SourcePriority.UNKNOWN); | 6492 manager.add(source, SourcePriority.UNKNOWN); |
| 7163 WorkManager_WorkIterator iterator = manager.iterator(); | 6493 WorkManager_WorkIterator iterator = manager.iterator(); |
| 7164 JUnitTestCase.assertTrue(iterator.hasNext); | 6494 expect(iterator.hasNext, isTrue); |
| 7165 JUnitTestCase.assertSame(source, iterator.next()); | 6495 expect(iterator.next(), same(source)); |
| 7166 } | 6496 } |
| 7167 void test_remove() { | 6497 void test_remove() { |
| 7168 TestSource source1 = new TestSource("/f1.dart"); | 6498 TestSource source1 = new TestSource("/f1.dart"); |
| 7169 TestSource source2 = new TestSource("/f2.dart"); | 6499 TestSource source2 = new TestSource("/f2.dart"); |
| 7170 TestSource source3 = new TestSource("/f3.dart"); | 6500 TestSource source3 = new TestSource("/f3.dart"); |
| 7171 WorkManager manager = new WorkManager(); | 6501 WorkManager manager = new WorkManager(); |
| 7172 manager.add(source1, SourcePriority.UNKNOWN); | 6502 manager.add(source1, SourcePriority.UNKNOWN); |
| 7173 manager.add(source2, SourcePriority.UNKNOWN); | 6503 manager.add(source2, SourcePriority.UNKNOWN); |
| 7174 manager.add(source3, SourcePriority.UNKNOWN); | 6504 manager.add(source3, SourcePriority.UNKNOWN); |
| 7175 manager.remove(source2); | 6505 manager.remove(source2); |
| 7176 WorkManager_WorkIterator iterator = manager.iterator(); | 6506 WorkManager_WorkIterator iterator = manager.iterator(); |
| 7177 JUnitTestCase.assertSame(source1, iterator.next()); | 6507 expect(iterator.next(), same(source1)); |
| 7178 JUnitTestCase.assertSame(source3, iterator.next()); | 6508 expect(iterator.next(), same(source3)); |
| 7179 } | 6509 } |
| 7180 void test_toString_empty() { | 6510 void test_toString_empty() { |
| 7181 WorkManager manager = new WorkManager(); | 6511 WorkManager manager = new WorkManager(); |
| 7182 JUnitTestCase.assertNotNull(manager.toString()); | 6512 expect(manager.toString(), isNotNull); |
| 7183 } | 6513 } |
| 7184 void test_toString_nonEmpty() { | 6514 void test_toString_nonEmpty() { |
| 7185 WorkManager manager = new WorkManager(); | 6515 WorkManager manager = new WorkManager(); |
| 7186 manager.add(new TestSource(), SourcePriority.HTML); | 6516 manager.add(new TestSource(), SourcePriority.HTML); |
| 7187 manager.add(new TestSource(), SourcePriority.LIBRARY); | 6517 manager.add(new TestSource(), SourcePriority.LIBRARY); |
| 7188 manager.add(new TestSource(), SourcePriority.NORMAL_PART); | 6518 manager.add(new TestSource(), SourcePriority.NORMAL_PART); |
| 7189 manager.add(new TestSource(), SourcePriority.PRIORITY_PART); | 6519 manager.add(new TestSource(), SourcePriority.PRIORITY_PART); |
| 7190 manager.add(new TestSource(), SourcePriority.UNKNOWN); | 6520 manager.add(new TestSource(), SourcePriority.UNKNOWN); |
| 7191 JUnitTestCase.assertNotNull(manager.toString()); | 6521 expect(manager.toString(), isNotNull); |
| 7192 } | 6522 } |
| 7193 } | 6523 } |
| 7194 | 6524 |
| 7195 | 6525 |
| 7196 class _AnalysisCacheTest_test_setMaxCacheSize implements CacheRetentionPolicy { | 6526 class _AnalysisCacheTest_test_setMaxCacheSize implements CacheRetentionPolicy { |
| 7197 @override | 6527 @override |
| 7198 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 6528 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7199 RetentionPriority.LOW; | 6529 RetentionPriority.LOW; |
| 7200 } | 6530 } |
| 7201 | 6531 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 7220 } | 6550 } |
| 7221 } | 6551 } |
| 7222 | 6552 |
| 7223 | 6553 |
| 7224 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 6554 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 7225 CacheRetentionPolicy { | 6555 CacheRetentionPolicy { |
| 7226 @override | 6556 @override |
| 7227 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 6557 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7228 RetentionPriority.LOW; | 6558 RetentionPriority.LOW; |
| 7229 } | 6559 } |
| OLD | NEW |