| 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'; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 JUnitTestCase.fail("Implement this"); | 162 JUnitTestCase.fail("Implement this"); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void fail_mergeContext() { | 165 void fail_mergeContext() { |
| 166 JUnitTestCase.fail("Implement this"); | 166 JUnitTestCase.fail("Implement this"); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void fail_performAnalysisTask_importedLibraryDelete_html() { | 169 void fail_performAnalysisTask_importedLibraryDelete_html() { |
| 170 Source htmlSource = _addSource( | 170 Source htmlSource = _addSource( |
| 171 "/page.html", | 171 "/page.html", |
| 172 EngineTestCase.createSource( | 172 r''' |
| 173 [ | 173 <html><body><script type="application/dart"> |
| 174 "<html><body><script type=\"application/dart\">", | 174 import 'libB.dart'; |
| 175 " import 'libB.dart';", | 175 main() {print('hello dart');} |
| 176 " main() {print('hello dart');}", | 176 </script></body></html>'''); |
| 177 "</script></body></html>"])); | |
| 178 Source libBSource = _addSource("/libB.dart", "library libB;"); | 177 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 179 _analyzeAll_assertFinished(); | 178 _analyzeAll_assertFinished(); |
| 180 JUnitTestCase.assertNotNullMsg( | 179 JUnitTestCase.assertNotNullMsg( |
| 181 "htmlUnit resolved 1", | 180 "htmlUnit resolved 1", |
| 182 _context.getResolvedHtmlUnit(htmlSource)); | 181 _context.getResolvedHtmlUnit(htmlSource)); |
| 183 JUnitTestCase.assertNotNullMsg( | 182 JUnitTestCase.assertNotNullMsg( |
| 184 "libB resolved 1", | 183 "libB resolved 1", |
| 185 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | 184 _context.getResolvedCompilationUnit2(libBSource, libBSource)); |
| 186 JUnitTestCase.assertTrueMsg( | 185 JUnitTestCase.assertTrueMsg( |
| 187 "htmlSource doesn't have errors", | 186 "htmlSource doesn't have errors", |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 Source source = _addSource("/test.dart", "main() {}"); | 225 Source source = _addSource("/test.dart", "main() {}"); |
| 227 JUnitTestCase.assertTrue( | 226 JUnitTestCase.assertTrue( |
| 228 _context.sourcesNeedingProcessing.contains(source)); | 227 _context.sourcesNeedingProcessing.contains(source)); |
| 229 } | 228 } |
| 230 | 229 |
| 231 void test_applyChanges_change_flush_element() { | 230 void test_applyChanges_change_flush_element() { |
| 232 _context = AnalysisContextFactory.contextWithCore(); | 231 _context = AnalysisContextFactory.contextWithCore(); |
| 233 _sourceFactory = _context.sourceFactory; | 232 _sourceFactory = _context.sourceFactory; |
| 234 Source librarySource = _addSource( | 233 Source librarySource = _addSource( |
| 235 "/lib.dart", | 234 "/lib.dart", |
| 236 EngineTestCase.createSource(["library lib;", "int a = 0;"])); | 235 r''' |
| 236 library lib; |
| 237 int a = 0;'''); |
| 237 JUnitTestCase.assertNotNull(_context.computeLibraryElement(librarySource)); | 238 JUnitTestCase.assertNotNull(_context.computeLibraryElement(librarySource)); |
| 238 _context.setContents( | 239 _context.setContents( |
| 239 librarySource, | 240 librarySource, |
| 240 EngineTestCase.createSource(["library lib;", "int aa = 0;"])); | 241 r''' |
| 242 library lib; |
| 243 int aa = 0;'''); |
| 241 JUnitTestCase.assertNull(_context.getLibraryElement(librarySource)); | 244 JUnitTestCase.assertNull(_context.getLibraryElement(librarySource)); |
| 242 } | 245 } |
| 243 | 246 |
| 244 void test_applyChanges_change_multiple() { | 247 void test_applyChanges_change_multiple() { |
| 245 _context = AnalysisContextFactory.contextWithCore(); | 248 _context = AnalysisContextFactory.contextWithCore(); |
| 246 _sourceFactory = _context.sourceFactory; | 249 _sourceFactory = _context.sourceFactory; |
| 247 Source librarySource = _addSource( | 250 Source librarySource = _addSource( |
| 248 "/lib.dart", | 251 "/lib.dart", |
| 249 EngineTestCase.createSource( | 252 r''' |
| 250 ["library lib;", "part 'part.dart';", "int a = 0;"])); | 253 library lib; |
| 254 part 'part.dart'; |
| 255 int a = 0;'''); |
| 251 Source partSource = _addSource( | 256 Source partSource = _addSource( |
| 252 "/part.dart", | 257 "/part.dart", |
| 253 EngineTestCase.createSource(["part of lib;", "int b = a;"])); | 258 r''' |
| 259 part of lib; |
| 260 int b = a;'''); |
| 254 _context.computeLibraryElement(librarySource); | 261 _context.computeLibraryElement(librarySource); |
| 255 _context.setContents( | 262 _context.setContents( |
| 256 librarySource, | 263 librarySource, |
| 257 EngineTestCase.createSource( | 264 r''' |
| 258 ["library lib;", "part 'part.dart';", "int aa = 0;"])); | 265 library lib; |
| 266 part 'part.dart'; |
| 267 int aa = 0;'''); |
| 259 _context.setContents( | 268 _context.setContents( |
| 260 partSource, | 269 partSource, |
| 261 EngineTestCase.createSource(["part of lib;", "int b = aa;"])); | 270 r''' |
| 271 part of lib; |
| 272 int b = aa;'''); |
| 262 _context.computeLibraryElement(librarySource); | 273 _context.computeLibraryElement(librarySource); |
| 263 CompilationUnit libraryUnit = | 274 CompilationUnit libraryUnit = |
| 264 _context.resolveCompilationUnit2(librarySource, librarySource); | 275 _context.resolveCompilationUnit2(librarySource, librarySource); |
| 265 CompilationUnit partUnit = | 276 CompilationUnit partUnit = |
| 266 _context.resolveCompilationUnit2(partSource, librarySource); | 277 _context.resolveCompilationUnit2(partSource, librarySource); |
| 267 TopLevelVariableDeclaration declaration = | 278 TopLevelVariableDeclaration declaration = |
| 268 libraryUnit.declarations[0] as TopLevelVariableDeclaration; | 279 libraryUnit.declarations[0] as TopLevelVariableDeclaration; |
| 269 Element declarationElement = declaration.variables.variables[0].element; | 280 Element declarationElement = declaration.variables.variables[0].element; |
| 270 TopLevelVariableDeclaration use = | 281 TopLevelVariableDeclaration use = |
| 271 partUnit.declarations[0] as TopLevelVariableDeclaration; | 282 partUnit.declarations[0] as TopLevelVariableDeclaration; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 294 changeSet.changedSource(source); | 305 changeSet.changedSource(source); |
| 295 _context.applyChanges(changeSet); | 306 _context.applyChanges(changeSet); |
| 296 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 307 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); |
| 297 } | 308 } |
| 298 | 309 |
| 299 void test_applyChanges_remove() { | 310 void test_applyChanges_remove() { |
| 300 _context = AnalysisContextFactory.contextWithCore(); | 311 _context = AnalysisContextFactory.contextWithCore(); |
| 301 _sourceFactory = _context.sourceFactory; | 312 _sourceFactory = _context.sourceFactory; |
| 302 Source libA = _addSource( | 313 Source libA = _addSource( |
| 303 "/libA.dart", | 314 "/libA.dart", |
| 304 EngineTestCase.createSource(["library libA;", "import 'libB.dart';"])); | 315 r''' |
| 316 library libA; |
| 317 import 'libB.dart';'''); |
| 305 Source libB = | 318 Source libB = |
| 306 _addSource("/libB.dart", EngineTestCase.createSource(["library libB;"]))
; | 319 _addSource("/libB.dart", "library libB;"); |
| 307 LibraryElement libAElement = _context.computeLibraryElement(libA); | 320 LibraryElement libAElement = _context.computeLibraryElement(libA); |
| 308 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | 321 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
| 309 EngineTestCase.assertLength(2, importedLibraries); | 322 EngineTestCase.assertLength(2, importedLibraries); |
| 310 _context.computeErrors(libA); | 323 _context.computeErrors(libA); |
| 311 _context.computeErrors(libB); | 324 _context.computeErrors(libB); |
| 312 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 325 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); |
| 313 _context.setContents(libB, null); | 326 _context.setContents(libB, null); |
| 314 _removeSource(libB); | 327 _removeSource(libB); |
| 315 List<Source> sources = _context.sourcesNeedingProcessing; | 328 List<Source> sources = _context.sourcesNeedingProcessing; |
| 316 EngineTestCase.assertSizeOfList(1, sources); | 329 EngineTestCase.assertSizeOfList(1, sources); |
| 317 JUnitTestCase.assertSame(libA, sources[0]); | 330 JUnitTestCase.assertSame(libA, sources[0]); |
| 318 libAElement = _context.computeLibraryElement(libA); | 331 libAElement = _context.computeLibraryElement(libA); |
| 319 importedLibraries = libAElement.importedLibraries; | 332 importedLibraries = libAElement.importedLibraries; |
| 320 EngineTestCase.assertLength(1, importedLibraries); | 333 EngineTestCase.assertLength(1, importedLibraries); |
| 321 } | 334 } |
| 322 | 335 |
| 323 void test_applyChanges_removeContainer() { | 336 void test_applyChanges_removeContainer() { |
| 324 _context = AnalysisContextFactory.contextWithCore(); | 337 _context = AnalysisContextFactory.contextWithCore(); |
| 325 _sourceFactory = _context.sourceFactory; | 338 _sourceFactory = _context.sourceFactory; |
| 326 Source libA = _addSource( | 339 Source libA = _addSource( |
| 327 "/libA.dart", | 340 "/libA.dart", |
| 328 EngineTestCase.createSource(["library libA;", "import 'libB.dart';"])); | 341 r''' |
| 342 library libA; |
| 343 import 'libB.dart';'''); |
| 329 Source libB = | 344 Source libB = |
| 330 _addSource("/libB.dart", EngineTestCase.createSource(["library libB;"]))
; | 345 _addSource("/libB.dart", "library libB;"); |
| 331 _context.computeLibraryElement(libA); | 346 _context.computeLibraryElement(libA); |
| 332 _context.computeErrors(libA); | 347 _context.computeErrors(libA); |
| 333 _context.computeErrors(libB); | 348 _context.computeErrors(libB); |
| 334 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 349 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); |
| 335 ChangeSet changeSet = new ChangeSet(); | 350 ChangeSet changeSet = new ChangeSet(); |
| 336 changeSet.removedContainer( | 351 changeSet.removedContainer( |
| 337 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); | 352 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); |
| 338 _context.applyChanges(changeSet); | 353 _context.applyChanges(changeSet); |
| 339 List<Source> sources = _context.sourcesNeedingProcessing; | 354 List<Source> sources = _context.sourcesNeedingProcessing; |
| 340 EngineTestCase.assertSizeOfList(1, sources); | 355 EngineTestCase.assertSizeOfList(1, sources); |
| 341 JUnitTestCase.assertSame(libA, sources[0]); | 356 JUnitTestCase.assertSame(libA, sources[0]); |
| 342 } | 357 } |
| 343 | 358 |
| 344 void test_computeDocumentationComment_block() { | 359 void test_computeDocumentationComment_block() { |
| 345 _context = AnalysisContextFactory.contextWithCore(); | 360 _context = AnalysisContextFactory.contextWithCore(); |
| 346 _sourceFactory = _context.sourceFactory; | 361 _sourceFactory = _context.sourceFactory; |
| 347 String comment = "/** Comment */"; | 362 String comment = "/** Comment */"; |
| 348 Source source = | 363 Source source = |
| 349 _addSource("/test.dart", EngineTestCase.createSource([comment, "class A
{}"])); | 364 _addSource("/test.dart", """ |
| 365 $comment |
| 366 class A {}"""); |
| 350 LibraryElement libraryElement = _context.computeLibraryElement(source); | 367 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 351 JUnitTestCase.assertNotNull(libraryElement); | 368 JUnitTestCase.assertNotNull(libraryElement); |
| 352 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 369 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 353 JUnitTestCase.assertNotNull(libraryElement); | 370 JUnitTestCase.assertNotNull(libraryElement); |
| 354 JUnitTestCase.assertEquals( | 371 JUnitTestCase.assertEquals( |
| 355 comment, | 372 comment, |
| 356 _context.computeDocumentationComment(classElement)); | 373 _context.computeDocumentationComment(classElement)); |
| 357 } | 374 } |
| 358 | 375 |
| 359 void test_computeDocumentationComment_none() { | 376 void test_computeDocumentationComment_none() { |
| 360 _context = AnalysisContextFactory.contextWithCore(); | 377 _context = AnalysisContextFactory.contextWithCore(); |
| 361 _sourceFactory = _context.sourceFactory; | 378 _sourceFactory = _context.sourceFactory; |
| 362 Source source = | 379 Source source = |
| 363 _addSource("/test.dart", EngineTestCase.createSource(["class A {}"])); | 380 _addSource("/test.dart", "class A {}"); |
| 364 LibraryElement libraryElement = _context.computeLibraryElement(source); | 381 LibraryElement libraryElement = _context.computeLibraryElement(source); |
| 365 JUnitTestCase.assertNotNull(libraryElement); | 382 JUnitTestCase.assertNotNull(libraryElement); |
| 366 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 383 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 367 JUnitTestCase.assertNotNull(libraryElement); | 384 JUnitTestCase.assertNotNull(libraryElement); |
| 368 JUnitTestCase.assertNull( | 385 JUnitTestCase.assertNull( |
| 369 _context.computeDocumentationComment(classElement)); | 386 _context.computeDocumentationComment(classElement)); |
| 370 } | 387 } |
| 371 | 388 |
| 372 void test_computeDocumentationComment_null() { | 389 void test_computeDocumentationComment_null() { |
| 373 JUnitTestCase.assertNull(_context.computeDocumentationComment(null)); | 390 JUnitTestCase.assertNull(_context.computeDocumentationComment(null)); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 _context = AnalysisContextFactory.contextWithCore(); | 513 _context = AnalysisContextFactory.contextWithCore(); |
| 497 _sourceFactory = _context.sourceFactory; | 514 _sourceFactory = _context.sourceFactory; |
| 498 Source source = _addSource("/test.dart", "library lib;"); | 515 Source source = _addSource("/test.dart", "library lib;"); |
| 499 LibraryElement element = _context.computeLibraryElement(source); | 516 LibraryElement element = _context.computeLibraryElement(source); |
| 500 JUnitTestCase.assertNotNull(element); | 517 JUnitTestCase.assertNotNull(element); |
| 501 } | 518 } |
| 502 | 519 |
| 503 void test_computeLineInfo_dart() { | 520 void test_computeLineInfo_dart() { |
| 504 Source source = _addSource( | 521 Source source = _addSource( |
| 505 "/test.dart", | 522 "/test.dart", |
| 506 EngineTestCase.createSource(["library lib;", "", "main() {}"])); | 523 r''' |
| 524 library lib; |
| 525 |
| 526 main() {}'''); |
| 507 LineInfo info = _context.computeLineInfo(source); | 527 LineInfo info = _context.computeLineInfo(source); |
| 508 JUnitTestCase.assertNotNull(info); | 528 JUnitTestCase.assertNotNull(info); |
| 509 } | 529 } |
| 510 | 530 |
| 511 void test_computeLineInfo_html() { | 531 void test_computeLineInfo_html() { |
| 512 Source source = _addSource( | 532 Source source = _addSource( |
| 513 "/test.html", | 533 "/test.html", |
| 514 EngineTestCase.createSource( | 534 r''' |
| 515 ["<html>", " <body>", " <h1>A</h1>", " </body>", "</html>"])); | 535 <html> |
| 536 <body> |
| 537 <h1>A</h1> |
| 538 </body> |
| 539 </html>'''); |
| 516 LineInfo info = _context.computeLineInfo(source); | 540 LineInfo info = _context.computeLineInfo(source); |
| 517 JUnitTestCase.assertNotNull(info); | 541 JUnitTestCase.assertNotNull(info); |
| 518 } | 542 } |
| 519 | 543 |
| 520 void test_computeResolvableCompilationUnit_dart_exception() { | 544 void test_computeResolvableCompilationUnit_dart_exception() { |
| 521 TestSource source = _addSourceWithException("/test.dart"); | 545 TestSource source = _addSourceWithException("/test.dart"); |
| 522 try { | 546 try { |
| 523 _context.computeResolvableCompilationUnit(source); | 547 _context.computeResolvableCompilationUnit(source); |
| 524 JUnitTestCase.fail("Expected AnalysisException"); | 548 JUnitTestCase.fail("Expected AnalysisException"); |
| 525 } on AnalysisException catch (exception) { | 549 } on AnalysisException catch (exception) { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 _findClass(core.definingCompilationUnit, "Object"); | 641 _findClass(core.definingCompilationUnit, "Object"); |
| 618 JUnitTestCase.assertNotNull(classObject); | 642 JUnitTestCase.assertNotNull(classObject); |
| 619 ElementLocation location = classObject.location; | 643 ElementLocation location = classObject.location; |
| 620 Element element = _context.getElement(location); | 644 Element element = _context.getElement(location); |
| 621 JUnitTestCase.assertSame(classObject, element); | 645 JUnitTestCase.assertSame(classObject, element); |
| 622 } | 646 } |
| 623 | 647 |
| 624 void test_getElement_constructor_named() { | 648 void test_getElement_constructor_named() { |
| 625 Source source = _addSource( | 649 Source source = _addSource( |
| 626 "/lib.dart", | 650 "/lib.dart", |
| 627 EngineTestCase.createSource(["class A {", " A.named() {}", "}"])); | 651 r''' |
| 652 class A { |
| 653 A.named() {} |
| 654 }'''); |
| 628 _analyzeAll_assertFinished(); | 655 _analyzeAll_assertFinished(); |
| 629 LibraryElement library = _context.computeLibraryElement(source); | 656 LibraryElement library = _context.computeLibraryElement(source); |
| 630 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | 657 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 631 ConstructorElement constructor = classA.constructors[0]; | 658 ConstructorElement constructor = classA.constructors[0]; |
| 632 ElementLocation location = constructor.location; | 659 ElementLocation location = constructor.location; |
| 633 Element element = _context.getElement(location); | 660 Element element = _context.getElement(location); |
| 634 JUnitTestCase.assertSame(constructor, element); | 661 JUnitTestCase.assertSame(constructor, element); |
| 635 } | 662 } |
| 636 | 663 |
| 637 void test_getElement_constructor_unnamed() { | 664 void test_getElement_constructor_unnamed() { |
| 638 Source source = _addSource( | 665 Source source = _addSource( |
| 639 "/lib.dart", | 666 "/lib.dart", |
| 640 EngineTestCase.createSource(["class A {", " A() {}", "}"])); | 667 r''' |
| 668 class A { |
| 669 A() {} |
| 670 }'''); |
| 641 _analyzeAll_assertFinished(); | 671 _analyzeAll_assertFinished(); |
| 642 LibraryElement library = _context.computeLibraryElement(source); | 672 LibraryElement library = _context.computeLibraryElement(source); |
| 643 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); | 673 ClassElement classA = _findClass(library.definingCompilationUnit, "A"); |
| 644 ConstructorElement constructor = classA.constructors[0]; | 674 ConstructorElement constructor = classA.constructors[0]; |
| 645 ElementLocation location = constructor.location; | 675 ElementLocation location = constructor.location; |
| 646 Element element = _context.getElement(location); | 676 Element element = _context.getElement(location); |
| 647 JUnitTestCase.assertSame(constructor, element); | 677 JUnitTestCase.assertSame(constructor, element); |
| 648 } | 678 } |
| 649 | 679 |
| 650 void test_getErrors_dart_none() { | 680 void test_getErrors_dart_none() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 670 List<AnalysisError> errors = _context.getErrors(source).errors; | 700 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 671 EngineTestCase.assertLength(0, errors); | 701 EngineTestCase.assertLength(0, errors); |
| 672 _context.computeErrors(source); | 702 _context.computeErrors(source); |
| 673 errors = _context.getErrors(source).errors; | 703 errors = _context.getErrors(source).errors; |
| 674 EngineTestCase.assertLength(0, errors); | 704 EngineTestCase.assertLength(0, errors); |
| 675 } | 705 } |
| 676 | 706 |
| 677 void test_getErrors_html_some() { | 707 void test_getErrors_html_some() { |
| 678 Source source = _addSource( | 708 Source source = _addSource( |
| 679 "/test.html", | 709 "/test.html", |
| 680 EngineTestCase.createSource( | 710 r''' |
| 681 [ | 711 <html><head> |
| 682 "<html><head>", | 712 <script type='application/dart' src='test.dart'/> |
| 683 "<script type='application/dart' src='test.dart'/>", | 713 </head></html>'''); |
| 684 "</head></html>"])); | |
| 685 List<AnalysisError> errors = _context.getErrors(source).errors; | 714 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 686 EngineTestCase.assertLength(0, errors); | 715 EngineTestCase.assertLength(0, errors); |
| 687 _context.computeErrors(source); | 716 _context.computeErrors(source); |
| 688 errors = _context.getErrors(source).errors; | 717 errors = _context.getErrors(source).errors; |
| 689 EngineTestCase.assertLength(1, errors); | 718 EngineTestCase.assertLength(1, errors); |
| 690 } | 719 } |
| 691 | 720 |
| 692 void test_getHtmlElement_dart() { | 721 void test_getHtmlElement_dart() { |
| 693 Source source = _addSource("/test.dart", ""); | 722 Source source = _addSource("/test.dart", ""); |
| 694 JUnitTestCase.assertNull(_context.getHtmlElement(source)); | 723 JUnitTestCase.assertNull(_context.getHtmlElement(source)); |
| 695 JUnitTestCase.assertNull(_context.computeHtmlElement(source)); | 724 JUnitTestCase.assertNull(_context.computeHtmlElement(source)); |
| 696 JUnitTestCase.assertNull(_context.getHtmlElement(source)); | 725 JUnitTestCase.assertNull(_context.getHtmlElement(source)); |
| 697 } | 726 } |
| 698 | 727 |
| 699 void test_getHtmlElement_html() { | 728 void test_getHtmlElement_html() { |
| 700 Source source = _addSource("/test.html", "<html></html>"); | 729 Source source = _addSource("/test.html", "<html></html>"); |
| 701 HtmlElement element = _context.getHtmlElement(source); | 730 HtmlElement element = _context.getHtmlElement(source); |
| 702 JUnitTestCase.assertNull(element); | 731 JUnitTestCase.assertNull(element); |
| 703 _context.computeHtmlElement(source); | 732 _context.computeHtmlElement(source); |
| 704 element = _context.getHtmlElement(source); | 733 element = _context.getHtmlElement(source); |
| 705 JUnitTestCase.assertNotNull(element); | 734 JUnitTestCase.assertNotNull(element); |
| 706 } | 735 } |
| 707 | 736 |
| 708 void test_getHtmlFilesReferencing_html() { | 737 void test_getHtmlFilesReferencing_html() { |
| 709 _context = AnalysisContextFactory.contextWithCore(); | 738 _context = AnalysisContextFactory.contextWithCore(); |
| 710 _sourceFactory = _context.sourceFactory; | 739 _sourceFactory = _context.sourceFactory; |
| 711 Source htmlSource = _addSource( | 740 Source htmlSource = _addSource( |
| 712 "/test.html", | 741 "/test.html", |
| 713 EngineTestCase.createSource( | 742 r''' |
| 714 [ | 743 <html><head> |
| 715 "<html><head>", | 744 <script type='application/dart' src='test.dart'/> |
| 716 "<script type='application/dart' src='test.dart'/>", | 745 <script type='application/dart' src='test.js'/> |
| 717 "<script type='application/dart' src='test.js'/>", | 746 </head></html>'''); |
| 718 "</head></html>"])); | |
| 719 Source librarySource = _addSource("/test.dart", "library lib;"); | 747 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 720 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); | 748 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); |
| 721 _context.computeLibraryElement(librarySource); | 749 _context.computeLibraryElement(librarySource); |
| 722 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); | 750 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); |
| 723 EngineTestCase.assertLength(0, result); | 751 EngineTestCase.assertLength(0, result); |
| 724 _context.parseHtmlUnit(htmlSource); | 752 _context.parseHtmlUnit(htmlSource); |
| 725 result = _context.getHtmlFilesReferencing(secondHtmlSource); | 753 result = _context.getHtmlFilesReferencing(secondHtmlSource); |
| 726 EngineTestCase.assertLength(0, result); | 754 EngineTestCase.assertLength(0, result); |
| 727 } | 755 } |
| 728 | 756 |
| 729 void test_getHtmlFilesReferencing_library() { | 757 void test_getHtmlFilesReferencing_library() { |
| 730 Source htmlSource = _addSource( | 758 Source htmlSource = _addSource( |
| 731 "/test.html", | 759 "/test.html", |
| 732 EngineTestCase.createSource( | 760 r''' |
| 733 [ | 761 <html><head> |
| 734 "<html><head>", | 762 <script type='application/dart' src='test.dart'/> |
| 735 "<script type='application/dart' src='test.dart'/>", | 763 <script type='application/dart' src='test.js'/> |
| 736 "<script type='application/dart' src='test.js'/>", | 764 </head></html>'''); |
| 737 "</head></html>"])); | |
| 738 Source librarySource = _addSource("/test.dart", "library lib;"); | 765 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 739 List<Source> result = _context.getHtmlFilesReferencing(librarySource); | 766 List<Source> result = _context.getHtmlFilesReferencing(librarySource); |
| 740 EngineTestCase.assertLength(0, result); | 767 EngineTestCase.assertLength(0, result); |
| 741 _context.parseHtmlUnit(htmlSource); | 768 _context.parseHtmlUnit(htmlSource); |
| 742 result = _context.getHtmlFilesReferencing(librarySource); | 769 result = _context.getHtmlFilesReferencing(librarySource); |
| 743 EngineTestCase.assertLength(1, result); | 770 EngineTestCase.assertLength(1, result); |
| 744 JUnitTestCase.assertEquals(htmlSource, result[0]); | 771 JUnitTestCase.assertEquals(htmlSource, result[0]); |
| 745 } | 772 } |
| 746 | 773 |
| 747 void test_getHtmlFilesReferencing_part() { | 774 void test_getHtmlFilesReferencing_part() { |
| 748 _context = AnalysisContextFactory.contextWithCore(); | 775 _context = AnalysisContextFactory.contextWithCore(); |
| 749 _sourceFactory = _context.sourceFactory; | 776 _sourceFactory = _context.sourceFactory; |
| 750 Source htmlSource = _addSource( | 777 Source htmlSource = _addSource( |
| 751 "/test.html", | 778 "/test.html", |
| 752 EngineTestCase.createSource( | 779 r''' |
| 753 [ | 780 <html><head> |
| 754 "<html><head>", | 781 <script type='application/dart' src='test.dart'/> |
| 755 "<script type='application/dart' src='test.dart'/>", | 782 <script type='application/dart' src='test.js'/> |
| 756 "<script type='application/dart' src='test.js'/>", | 783 </head></html>'''); |
| 757 "</head></html>"])); | |
| 758 Source librarySource = | 784 Source librarySource = |
| 759 _addSource("/test.dart", "library lib; part 'part.dart';"); | 785 _addSource("/test.dart", "library lib; part 'part.dart';"); |
| 760 Source partSource = _addSource("/part.dart", "part of lib;"); | 786 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 761 _context.computeLibraryElement(librarySource); | 787 _context.computeLibraryElement(librarySource); |
| 762 List<Source> result = _context.getHtmlFilesReferencing(partSource); | 788 List<Source> result = _context.getHtmlFilesReferencing(partSource); |
| 763 EngineTestCase.assertLength(0, result); | 789 EngineTestCase.assertLength(0, result); |
| 764 _context.parseHtmlUnit(htmlSource); | 790 _context.parseHtmlUnit(htmlSource); |
| 765 result = _context.getHtmlFilesReferencing(partSource); | 791 result = _context.getHtmlFilesReferencing(partSource); |
| 766 EngineTestCase.assertLength(1, result); | 792 EngineTestCase.assertLength(1, result); |
| 767 JUnitTestCase.assertEquals(htmlSource, result[0]); | 793 JUnitTestCase.assertEquals(htmlSource, result[0]); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 801 JUnitTestCase.assertSame(SourceKind.UNKNOWN, _context.getKindOf(source)); | 827 JUnitTestCase.assertSame(SourceKind.UNKNOWN, _context.getKindOf(source)); |
| 802 } | 828 } |
| 803 | 829 |
| 804 void test_getLaunchableClientLibrarySources() { | 830 void test_getLaunchableClientLibrarySources() { |
| 805 _context = AnalysisContextFactory.contextWithCore(); | 831 _context = AnalysisContextFactory.contextWithCore(); |
| 806 _sourceFactory = _context.sourceFactory; | 832 _sourceFactory = _context.sourceFactory; |
| 807 List<Source> sources = _context.launchableClientLibrarySources; | 833 List<Source> sources = _context.launchableClientLibrarySources; |
| 808 EngineTestCase.assertLength(0, sources); | 834 EngineTestCase.assertLength(0, sources); |
| 809 Source source = _addSource( | 835 Source source = _addSource( |
| 810 "/test.dart", | 836 "/test.dart", |
| 811 EngineTestCase.createSource(["import 'dart:html';", "main() {}"])); | 837 r''' |
| 838 import 'dart:html'; |
| 839 main() {}'''); |
| 812 _context.computeLibraryElement(source); | 840 _context.computeLibraryElement(source); |
| 813 sources = _context.launchableClientLibrarySources; | 841 sources = _context.launchableClientLibrarySources; |
| 814 EngineTestCase.assertLength(1, sources); | 842 EngineTestCase.assertLength(1, sources); |
| 815 } | 843 } |
| 816 | 844 |
| 817 void test_getLaunchableServerLibrarySources() { | 845 void test_getLaunchableServerLibrarySources() { |
| 818 _context = AnalysisContextFactory.contextWithCore(); | 846 _context = AnalysisContextFactory.contextWithCore(); |
| 819 _sourceFactory = _context.sourceFactory; | 847 _sourceFactory = _context.sourceFactory; |
| 820 List<Source> sources = _context.launchableServerLibrarySources; | 848 List<Source> sources = _context.launchableServerLibrarySources; |
| 821 EngineTestCase.assertLength(0, sources); | 849 EngineTestCase.assertLength(0, sources); |
| 822 Source source = _addSource("/test.dart", "main() {}"); | 850 Source source = _addSource("/test.dart", "main() {}"); |
| 823 _context.computeLibraryElement(source); | 851 _context.computeLibraryElement(source); |
| 824 sources = _context.launchableServerLibrarySources; | 852 sources = _context.launchableServerLibrarySources; |
| 825 EngineTestCase.assertLength(1, sources); | 853 EngineTestCase.assertLength(1, sources); |
| 826 } | 854 } |
| 827 | 855 |
| 828 void test_getLibrariesContaining() { | 856 void test_getLibrariesContaining() { |
| 829 _context = AnalysisContextFactory.contextWithCore(); | 857 _context = AnalysisContextFactory.contextWithCore(); |
| 830 _sourceFactory = _context.sourceFactory; | 858 _sourceFactory = _context.sourceFactory; |
| 831 Source librarySource = _addSource( | 859 Source librarySource = _addSource( |
| 832 "/lib.dart", | 860 "/lib.dart", |
| 833 EngineTestCase.createSource(["library lib;", "part 'part.dart';"])); | 861 r''' |
| 862 library lib; |
| 863 part 'part.dart';'''); |
| 834 Source partSource = _addSource("/part.dart", "part of lib;"); | 864 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 835 _context.computeLibraryElement(librarySource); | 865 _context.computeLibraryElement(librarySource); |
| 836 List<Source> result = _context.getLibrariesContaining(librarySource); | 866 List<Source> result = _context.getLibrariesContaining(librarySource); |
| 837 EngineTestCase.assertLength(1, result); | 867 EngineTestCase.assertLength(1, result); |
| 838 JUnitTestCase.assertEquals(librarySource, result[0]); | 868 JUnitTestCase.assertEquals(librarySource, result[0]); |
| 839 result = _context.getLibrariesContaining(partSource); | 869 result = _context.getLibrariesContaining(partSource); |
| 840 EngineTestCase.assertLength(1, result); | 870 EngineTestCase.assertLength(1, result); |
| 841 JUnitTestCase.assertEquals(librarySource, result[0]); | 871 JUnitTestCase.assertEquals(librarySource, result[0]); |
| 842 } | 872 } |
| 843 | 873 |
| 844 void test_getLibrariesDependingOn() { | 874 void test_getLibrariesDependingOn() { |
| 845 _context = AnalysisContextFactory.contextWithCore(); | 875 _context = AnalysisContextFactory.contextWithCore(); |
| 846 _sourceFactory = _context.sourceFactory; | 876 _sourceFactory = _context.sourceFactory; |
| 847 Source libASource = _addSource("/libA.dart", "library libA;"); | 877 Source libASource = _addSource("/libA.dart", "library libA;"); |
| 848 _addSource("/libB.dart", "library libB;"); | 878 _addSource("/libB.dart", "library libB;"); |
| 849 Source lib1Source = _addSource( | 879 Source lib1Source = _addSource( |
| 850 "/lib1.dart", | 880 "/lib1.dart", |
| 851 EngineTestCase.createSource( | 881 r''' |
| 852 ["library lib1;", "import 'libA.dart';", "export 'libB.dart';"])); | 882 library lib1; |
| 883 import 'libA.dart'; |
| 884 export 'libB.dart';'''); |
| 853 Source lib2Source = _addSource( | 885 Source lib2Source = _addSource( |
| 854 "/lib2.dart", | 886 "/lib2.dart", |
| 855 EngineTestCase.createSource( | 887 r''' |
| 856 ["library lib2;", "import 'libB.dart';", "export 'libA.dart';"])); | 888 library lib2; |
| 889 import 'libB.dart'; |
| 890 export 'libA.dart';'''); |
| 857 _context.computeLibraryElement(lib1Source); | 891 _context.computeLibraryElement(lib1Source); |
| 858 _context.computeLibraryElement(lib2Source); | 892 _context.computeLibraryElement(lib2Source); |
| 859 List<Source> result = _context.getLibrariesDependingOn(libASource); | 893 List<Source> result = _context.getLibrariesDependingOn(libASource); |
| 860 EngineTestCase.assertContains(result, [lib1Source, lib2Source]); | 894 EngineTestCase.assertContains(result, [lib1Source, lib2Source]); |
| 861 } | 895 } |
| 862 | 896 |
| 863 void test_getLibrariesReferencedFromHtml() { | 897 void test_getLibrariesReferencedFromHtml() { |
| 864 _context = AnalysisContextFactory.contextWithCore(); | 898 _context = AnalysisContextFactory.contextWithCore(); |
| 865 _sourceFactory = _context.sourceFactory; | 899 _sourceFactory = _context.sourceFactory; |
| 866 Source htmlSource = _addSource( | 900 Source htmlSource = _addSource( |
| 867 "/test.html", | 901 "/test.html", |
| 868 EngineTestCase.createSource( | 902 r''' |
| 869 [ | 903 <html><head> |
| 870 "<html><head>", | 904 <script type='application/dart' src='test.dart'/> |
| 871 "<script type='application/dart' src='test.dart'/>", | 905 <script type='application/dart' src='test.js'/> |
| 872 "<script type='application/dart' src='test.js'/>", | 906 </head></html>'''); |
| 873 "</head></html>"])); | |
| 874 Source librarySource = _addSource("/test.dart", "library lib;"); | 907 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 875 _context.computeLibraryElement(librarySource); | 908 _context.computeLibraryElement(librarySource); |
| 876 _context.parseHtmlUnit(htmlSource); | 909 _context.parseHtmlUnit(htmlSource); |
| 877 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 910 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 878 EngineTestCase.assertLength(1, result); | 911 EngineTestCase.assertLength(1, result); |
| 879 JUnitTestCase.assertEquals(librarySource, result[0]); | 912 JUnitTestCase.assertEquals(librarySource, result[0]); |
| 880 } | 913 } |
| 881 | 914 |
| 882 void test_getLibrariesReferencedFromHtml_no() { | 915 void test_getLibrariesReferencedFromHtml_no() { |
| 883 _context = AnalysisContextFactory.contextWithCore(); | 916 _context = AnalysisContextFactory.contextWithCore(); |
| 884 _sourceFactory = _context.sourceFactory; | 917 _sourceFactory = _context.sourceFactory; |
| 885 Source htmlSource = _addSource( | 918 Source htmlSource = _addSource( |
| 886 "/test.html", | 919 "/test.html", |
| 887 EngineTestCase.createSource( | 920 r''' |
| 888 [ | 921 <html><head> |
| 889 "<html><head>", | 922 <script type='application/dart' src='test.js'/> |
| 890 "<script type='application/dart' src='test.js'/>", | 923 </head></html>'''); |
| 891 "</head></html>"])); | |
| 892 _addSource("/test.dart", "library lib;"); | 924 _addSource("/test.dart", "library lib;"); |
| 893 _context.parseHtmlUnit(htmlSource); | 925 _context.parseHtmlUnit(htmlSource); |
| 894 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 926 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 895 EngineTestCase.assertLength(0, result); | 927 EngineTestCase.assertLength(0, result); |
| 896 } | 928 } |
| 897 | 929 |
| 898 void test_getLibraryElement() { | 930 void test_getLibraryElement() { |
| 899 _context = AnalysisContextFactory.contextWithCore(); | 931 _context = AnalysisContextFactory.contextWithCore(); |
| 900 _sourceFactory = _context.sourceFactory; | 932 _sourceFactory = _context.sourceFactory; |
| 901 Source source = _addSource("/test.dart", "library lib;"); | 933 Source source = _addSource("/test.dart", "library lib;"); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 918 return; | 950 return; |
| 919 } | 951 } |
| 920 } | 952 } |
| 921 JUnitTestCase.fail( | 953 JUnitTestCase.fail( |
| 922 "The added source was not in the list of library sources"); | 954 "The added source was not in the list of library sources"); |
| 923 } | 955 } |
| 924 | 956 |
| 925 void test_getLineInfo() { | 957 void test_getLineInfo() { |
| 926 Source source = _addSource( | 958 Source source = _addSource( |
| 927 "/test.dart", | 959 "/test.dart", |
| 928 EngineTestCase.createSource(["library lib;", "", "main() {}"])); | 960 r''' |
| 961 library lib; |
| 962 |
| 963 main() {}'''); |
| 929 LineInfo info = _context.getLineInfo(source); | 964 LineInfo info = _context.getLineInfo(source); |
| 930 JUnitTestCase.assertNull(info); | 965 JUnitTestCase.assertNull(info); |
| 931 _context.parseCompilationUnit(source); | 966 _context.parseCompilationUnit(source); |
| 932 info = _context.getLineInfo(source); | 967 info = _context.getLineInfo(source); |
| 933 JUnitTestCase.assertNotNull(info); | 968 JUnitTestCase.assertNotNull(info); |
| 934 } | 969 } |
| 935 | 970 |
| 936 void test_getModificationStamp_fromSource() { | 971 void test_getModificationStamp_fromSource() { |
| 937 int stamp = 42; | 972 int stamp = 42; |
| 938 JUnitTestCase.assertEquals( | 973 JUnitTestCase.assertEquals( |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1039 // assertLength(0, statistics.getCacheRows()); | 1074 // assertLength(0, statistics.getCacheRows()); |
| 1040 // assertLength(0, statistics.getExceptions()); | 1075 // assertLength(0, statistics.getExceptions()); |
| 1041 // assertLength(0, statistics.getSources()); | 1076 // assertLength(0, statistics.getSources()); |
| 1042 } | 1077 } |
| 1043 | 1078 |
| 1044 void test_isClientLibrary_dart() { | 1079 void test_isClientLibrary_dart() { |
| 1045 _context = AnalysisContextFactory.contextWithCore(); | 1080 _context = AnalysisContextFactory.contextWithCore(); |
| 1046 _sourceFactory = _context.sourceFactory; | 1081 _sourceFactory = _context.sourceFactory; |
| 1047 Source source = _addSource( | 1082 Source source = _addSource( |
| 1048 "/test.dart", | 1083 "/test.dart", |
| 1049 EngineTestCase.createSource(["import 'dart:html';", "", "main() {}"])); | 1084 r''' |
| 1085 import 'dart:html'; |
| 1086 |
| 1087 main() {}'''); |
| 1050 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1088 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); |
| 1051 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1089 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); |
| 1052 _context.computeLibraryElement(source); | 1090 _context.computeLibraryElement(source); |
| 1053 JUnitTestCase.assertTrue(_context.isClientLibrary(source)); | 1091 JUnitTestCase.assertTrue(_context.isClientLibrary(source)); |
| 1054 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1092 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); |
| 1055 } | 1093 } |
| 1056 | 1094 |
| 1057 void test_isClientLibrary_html() { | 1095 void test_isClientLibrary_html() { |
| 1058 Source source = _addSource("/test.html", "<html></html>"); | 1096 Source source = _addSource("/test.html", "<html></html>"); |
| 1059 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1097 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); |
| 1060 } | 1098 } |
| 1061 | 1099 |
| 1062 void test_isServerLibrary_dart() { | 1100 void test_isServerLibrary_dart() { |
| 1063 _context = AnalysisContextFactory.contextWithCore(); | 1101 _context = AnalysisContextFactory.contextWithCore(); |
| 1064 _sourceFactory = _context.sourceFactory; | 1102 _sourceFactory = _context.sourceFactory; |
| 1065 Source source = _addSource( | 1103 Source source = _addSource( |
| 1066 "/test.dart", | 1104 "/test.dart", |
| 1067 EngineTestCase.createSource(["library lib;", "", "main() {}"])); | 1105 r''' |
| 1106 library lib; |
| 1107 |
| 1108 main() {}'''); |
| 1068 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1109 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); |
| 1069 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1110 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); |
| 1070 _context.computeLibraryElement(source); | 1111 _context.computeLibraryElement(source); |
| 1071 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); | 1112 JUnitTestCase.assertFalse(_context.isClientLibrary(source)); |
| 1072 JUnitTestCase.assertTrue(_context.isServerLibrary(source)); | 1113 JUnitTestCase.assertTrue(_context.isServerLibrary(source)); |
| 1073 } | 1114 } |
| 1074 | 1115 |
| 1075 void test_isServerLibrary_html() { | 1116 void test_isServerLibrary_html() { |
| 1076 Source source = _addSource("/test.html", "<html></html>"); | 1117 Source source = _addSource("/test.html", "<html></html>"); |
| 1077 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); | 1118 JUnitTestCase.assertFalse(_context.isServerLibrary(source)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 | 1163 |
| 1123 void test_parseHtmlUnit_noErrors() { | 1164 void test_parseHtmlUnit_noErrors() { |
| 1124 Source source = _addSource("/lib.html", "<html></html>"); | 1165 Source source = _addSource("/lib.html", "<html></html>"); |
| 1125 ht.HtmlUnit unit = _context.parseHtmlUnit(source); | 1166 ht.HtmlUnit unit = _context.parseHtmlUnit(source); |
| 1126 JUnitTestCase.assertNotNull(unit); | 1167 JUnitTestCase.assertNotNull(unit); |
| 1127 } | 1168 } |
| 1128 | 1169 |
| 1129 void test_parseHtmlUnit_resolveDirectives() { | 1170 void test_parseHtmlUnit_resolveDirectives() { |
| 1130 Source libSource = _addSource( | 1171 Source libSource = _addSource( |
| 1131 "/lib.dart", | 1172 "/lib.dart", |
| 1132 EngineTestCase.createSource(["library lib;", "class ClassA {}"])); | 1173 r''' |
| 1174 library lib; |
| 1175 class ClassA {}'''); |
| 1133 Source source = _addSource( | 1176 Source source = _addSource( |
| 1134 "/lib.html", | 1177 "/lib.html", |
| 1135 EngineTestCase.createSource( | 1178 r''' |
| 1136 [ | 1179 <html> |
| 1137 "<html>", | 1180 <head> |
| 1138 "<head>", | 1181 <script type='application/dart'> |
| 1139 " <script type='application/dart'>", | 1182 import 'lib.dart'; |
| 1140 " import 'lib.dart';", | 1183 ClassA v = null; |
| 1141 " ClassA v = null;", | 1184 </script> |
| 1142 " </script>", | 1185 </head> |
| 1143 "</head>", | 1186 <body> |
| 1144 "<body>", | 1187 </body> |
| 1145 "</body>", | 1188 </html>'''); |
| 1146 "</html>"])); | |
| 1147 ht.HtmlUnit unit = _context.parseHtmlUnit(source); | 1189 ht.HtmlUnit unit = _context.parseHtmlUnit(source); |
| 1148 // import directive should be resolved | 1190 // import directive should be resolved |
| 1149 ht.XmlTagNode htmlNode = unit.tagNodes[0]; | 1191 ht.XmlTagNode htmlNode = unit.tagNodes[0]; |
| 1150 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; | 1192 ht.XmlTagNode headNode = htmlNode.tagNodes[0]; |
| 1151 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; | 1193 ht.HtmlScriptTagNode scriptNode = headNode.tagNodes[0]; |
| 1152 CompilationUnit script = scriptNode.script; | 1194 CompilationUnit script = scriptNode.script; |
| 1153 ImportDirective importNode = script.directives[0] as ImportDirective; | 1195 ImportDirective importNode = script.directives[0] as ImportDirective; |
| 1154 JUnitTestCase.assertNotNull(importNode.uriContent); | 1196 JUnitTestCase.assertNotNull(importNode.uriContent); |
| 1155 JUnitTestCase.assertEquals(libSource, importNode.source); | 1197 JUnitTestCase.assertEquals(libSource, importNode.source); |
| 1156 } | 1198 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1167 // Ensure that the timestamp differs, | 1209 // Ensure that the timestamp differs, |
| 1168 // so that analysis engine notices the change | 1210 // so that analysis engine notices the change |
| 1169 } while (oldTimestamp == _context.getModificationStamp(source)); | 1211 } while (oldTimestamp == _context.getModificationStamp(source)); |
| 1170 _analyzeAll_assertFinished(); | 1212 _analyzeAll_assertFinished(); |
| 1171 JUnitTestCase.assertEquals(2, source.readCount); | 1213 JUnitTestCase.assertEquals(2, source.readCount); |
| 1172 } | 1214 } |
| 1173 | 1215 |
| 1174 void test_performAnalysisTask_addPart() { | 1216 void test_performAnalysisTask_addPart() { |
| 1175 Source libSource = _addSource( | 1217 Source libSource = _addSource( |
| 1176 "/lib.dart", | 1218 "/lib.dart", |
| 1177 EngineTestCase.createSource(["library lib;", "part 'part.dart';"])); | 1219 r''' |
| 1220 library lib; |
| 1221 part 'part.dart';'''); |
| 1178 // run all tasks without part | 1222 // run all tasks without part |
| 1179 _analyzeAll_assertFinished(); | 1223 _analyzeAll_assertFinished(); |
| 1180 // add part and run all tasks | 1224 // add part and run all tasks |
| 1181 Source partSource = | 1225 Source partSource = |
| 1182 _addSource("/part.dart", EngineTestCase.createSource(["part of lib;", ""
])); | 1226 _addSource("/part.dart", r''' |
| 1227 part of lib; |
| 1228 '''); |
| 1183 _analyzeAll_assertFinished(); | 1229 _analyzeAll_assertFinished(); |
| 1184 // "libSource" should be here | 1230 // "libSource" should be here |
| 1185 List<Source> librariesWithPart = | 1231 List<Source> librariesWithPart = |
| 1186 _context.getLibrariesContaining(partSource); | 1232 _context.getLibrariesContaining(partSource); |
| 1187 EngineTestCase.assertContains(librariesWithPart, [libSource]); | 1233 EngineTestCase.assertContains(librariesWithPart, [libSource]); |
| 1188 } | 1234 } |
| 1189 | 1235 |
| 1190 void test_performAnalysisTask_changeLibraryContents() { | 1236 void test_performAnalysisTask_changeLibraryContents() { |
| 1191 Source libSource = | 1237 Source libSource = |
| 1192 _addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1238 _addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1271 "library resolved 3", | 1317 "library resolved 3", |
| 1272 _context.getResolvedCompilationUnit2(libSource, libSource)); | 1318 _context.getResolvedCompilationUnit2(libSource, libSource)); |
| 1273 JUnitTestCase.assertNullMsg( | 1319 JUnitTestCase.assertNullMsg( |
| 1274 "part resolved 3", | 1320 "part resolved 3", |
| 1275 _context.getResolvedCompilationUnit2(partSource, libSource)); | 1321 _context.getResolvedCompilationUnit2(partSource, libSource)); |
| 1276 } | 1322 } |
| 1277 | 1323 |
| 1278 void test_performAnalysisTask_changePartContents_makeItAPart() { | 1324 void test_performAnalysisTask_changePartContents_makeItAPart() { |
| 1279 Source libSource = _addSource( | 1325 Source libSource = _addSource( |
| 1280 "/lib.dart", | 1326 "/lib.dart", |
| 1281 EngineTestCase.createSource( | 1327 r''' |
| 1282 ["library lib;", "part 'part.dart';", "void f(x) {}"])); | 1328 library lib; |
| 1329 part 'part.dart'; |
| 1330 void f(x) {}'''); |
| 1283 Source partSource = _addSource( | 1331 Source partSource = _addSource( |
| 1284 "/part.dart", | 1332 "/part.dart", |
| 1285 EngineTestCase.createSource(["void g() { f(null); }"])); | 1333 "void g() { f(null); }"); |
| 1286 _analyzeAll_assertFinished(); | 1334 _analyzeAll_assertFinished(); |
| 1287 JUnitTestCase.assertNotNullMsg( | 1335 JUnitTestCase.assertNotNullMsg( |
| 1288 "library resolved 1", | 1336 "library resolved 1", |
| 1289 _context.getResolvedCompilationUnit2(libSource, libSource)); | 1337 _context.getResolvedCompilationUnit2(libSource, libSource)); |
| 1290 JUnitTestCase.assertNotNullMsg( | 1338 JUnitTestCase.assertNotNullMsg( |
| 1291 "part resolved 1", | 1339 "part resolved 1", |
| 1292 _context.getResolvedCompilationUnit2(partSource, libSource)); | 1340 _context.getResolvedCompilationUnit2(partSource, libSource)); |
| 1293 // update and analyze | 1341 // update and analyze |
| 1294 _context.setContents( | 1342 _context.setContents( |
| 1295 partSource, | 1343 partSource, |
| 1296 EngineTestCase.createSource(["part of lib;", "void g() { f(null); }"])); | 1344 r''' |
| 1345 part of lib; |
| 1346 void g() { f(null); }'''); |
| 1297 JUnitTestCase.assertNullMsg( | 1347 JUnitTestCase.assertNullMsg( |
| 1298 "library changed 2", | 1348 "library changed 2", |
| 1299 _context.getResolvedCompilationUnit2(libSource, libSource)); | 1349 _context.getResolvedCompilationUnit2(libSource, libSource)); |
| 1300 JUnitTestCase.assertNullMsg( | 1350 JUnitTestCase.assertNullMsg( |
| 1301 "part changed 2", | 1351 "part changed 2", |
| 1302 _context.getResolvedCompilationUnit2(partSource, libSource)); | 1352 _context.getResolvedCompilationUnit2(partSource, libSource)); |
| 1303 _analyzeAll_assertFinished(); | 1353 _analyzeAll_assertFinished(); |
| 1304 JUnitTestCase.assertNotNullMsg( | 1354 JUnitTestCase.assertNotNullMsg( |
| 1305 "library resolved 2", | 1355 "library resolved 2", |
| 1306 _context.getResolvedCompilationUnit2(libSource, libSource)); | 1356 _context.getResolvedCompilationUnit2(libSource, libSource)); |
| 1307 JUnitTestCase.assertNotNullMsg( | 1357 JUnitTestCase.assertNotNullMsg( |
| 1308 "part resolved 2", | 1358 "part resolved 2", |
| 1309 _context.getResolvedCompilationUnit2(partSource, libSource)); | 1359 _context.getResolvedCompilationUnit2(partSource, libSource)); |
| 1310 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1360 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); |
| 1311 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1361 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); |
| 1312 } | 1362 } |
| 1313 | 1363 |
| 1314 /** | 1364 /** |
| 1315 * https://code.google.com/p/dart/issues/detail?id=12424 | 1365 * https://code.google.com/p/dart/issues/detail?id=12424 |
| 1316 */ | 1366 */ |
| 1317 void test_performAnalysisTask_changePartContents_makeItNotPart() { | 1367 void test_performAnalysisTask_changePartContents_makeItNotPart() { |
| 1318 Source libSource = _addSource( | 1368 Source libSource = _addSource( |
| 1319 "/lib.dart", | 1369 "/lib.dart", |
| 1320 EngineTestCase.createSource( | 1370 r''' |
| 1321 ["library lib;", "part 'part.dart';", "void f(x) {}"])); | 1371 library lib; |
| 1372 part 'part.dart'; |
| 1373 void f(x) {}'''); |
| 1322 Source partSource = _addSource( | 1374 Source partSource = _addSource( |
| 1323 "/part.dart", | 1375 "/part.dart", |
| 1324 EngineTestCase.createSource(["part of lib;", "void g() { f(null); }"])); | 1376 r''' |
| 1377 part of lib; |
| 1378 void g() { f(null); }'''); |
| 1325 _analyzeAll_assertFinished(); | 1379 _analyzeAll_assertFinished(); |
| 1326 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1380 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); |
| 1327 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1381 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); |
| 1328 // Remove 'part' directive, which should make "f(null)" an error. | 1382 // Remove 'part' directive, which should make "f(null)" an error. |
| 1329 _context.setContents( | 1383 _context.setContents( |
| 1330 partSource, | 1384 partSource, |
| 1331 EngineTestCase.createSource(["//part of lib;", "void g() { f(null); }"])
); | 1385 r''' |
| 1386 //part of lib; |
| 1387 void g() { f(null); }'''); |
| 1332 _analyzeAll_assertFinished(); | 1388 _analyzeAll_assertFinished(); |
| 1333 JUnitTestCase.assertTrue(_context.getErrors(libSource).errors.length != 0); | 1389 JUnitTestCase.assertTrue(_context.getErrors(libSource).errors.length != 0); |
| 1334 } | 1390 } |
| 1335 | 1391 |
| 1336 void test_performAnalysisTask_changePartContents_noSemanticChanges() { | 1392 void test_performAnalysisTask_changePartContents_noSemanticChanges() { |
| 1337 Source libSource = | 1393 Source libSource = |
| 1338 _addSource("/test.dart", "library lib; part 'test-part.dart';"); | 1394 _addSource("/test.dart", "library lib; part 'test-part.dart';"); |
| 1339 Source partSource = _addSource("/test-part.dart", "part of lib;"); | 1395 Source partSource = _addSource("/test-part.dart", "part of lib;"); |
| 1340 _analyzeAll_assertFinished(); | 1396 _analyzeAll_assertFinished(); |
| 1341 JUnitTestCase.assertNotNullMsg( | 1397 JUnitTestCase.assertNotNullMsg( |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1396 "libB resolved 2", | 1452 "libB resolved 2", |
| 1397 _context.getResolvedCompilationUnit2(libBSource, libBSource)); | 1453 _context.getResolvedCompilationUnit2(libBSource, libBSource)); |
| 1398 JUnitTestCase.assertTrueMsg( | 1454 JUnitTestCase.assertTrueMsg( |
| 1399 "libA doesn't have errors", | 1455 "libA doesn't have errors", |
| 1400 !_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); | 1456 !_hasAnalysisErrorWithErrorSeverity(_context.getErrors(libASource))); |
| 1401 } | 1457 } |
| 1402 | 1458 |
| 1403 void test_performAnalysisTask_importedLibraryAdd_html() { | 1459 void test_performAnalysisTask_importedLibraryAdd_html() { |
| 1404 Source htmlSource = _addSource( | 1460 Source htmlSource = _addSource( |
| 1405 "/page.html", | 1461 "/page.html", |
| 1406 EngineTestCase.createSource( | 1462 r''' |
| 1407 [ | 1463 <html><body><script type="application/dart"> |
| 1408 "<html><body><script type=\"application/dart\">", | 1464 import '/libB.dart'; |
| 1409 " import '/libB.dart';", | 1465 main() {print('hello dart');} |
| 1410 " main() {print('hello dart');}", | 1466 </script></body></html>'''); |
| 1411 "</script></body></html>"])); | |
| 1412 _analyzeAll_assertFinished(); | 1467 _analyzeAll_assertFinished(); |
| 1413 JUnitTestCase.assertNotNullMsg( | 1468 JUnitTestCase.assertNotNullMsg( |
| 1414 "htmlUnit resolved 1", | 1469 "htmlUnit resolved 1", |
| 1415 _context.getResolvedHtmlUnit(htmlSource)); | 1470 _context.getResolvedHtmlUnit(htmlSource)); |
| 1416 JUnitTestCase.assertTrueMsg( | 1471 JUnitTestCase.assertTrueMsg( |
| 1417 "htmlSource has an error", | 1472 "htmlSource has an error", |
| 1418 _hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource))); | 1473 _hasAnalysisErrorWithErrorSeverity(_context.getErrors(htmlSource))); |
| 1419 // add libB.dart and analyze | 1474 // add libB.dart and analyze |
| 1420 Source libBSource = _addSource("/libB.dart", "library libB;"); | 1475 Source libBSource = _addSource("/libB.dart", "library libB;"); |
| 1421 _analyzeAll_assertFinished(); | 1476 _analyzeAll_assertFinished(); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1594 List<Source> sources = new List<Source>(); | 1649 List<Source> sources = new List<Source>(); |
| 1595 sources.add(_addSource("/lib.dart", "library lib;")); | 1650 sources.add(_addSource("/lib.dart", "library lib;")); |
| 1596 _context.analysisPriorityOrder = sources; | 1651 _context.analysisPriorityOrder = sources; |
| 1597 } | 1652 } |
| 1598 | 1653 |
| 1599 void test_setChangedContents_libraryWithPart() { | 1654 void test_setChangedContents_libraryWithPart() { |
| 1600 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | 1655 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); |
| 1601 options.incremental = true; | 1656 options.incremental = true; |
| 1602 _context = AnalysisContextFactory.contextWithCoreAndOptions(options); | 1657 _context = AnalysisContextFactory.contextWithCoreAndOptions(options); |
| 1603 _sourceFactory = _context.sourceFactory; | 1658 _sourceFactory = _context.sourceFactory; |
| 1604 String oldCode = EngineTestCase.createSource( | 1659 String oldCode = r''' |
| 1605 ["library lib;", "part 'part.dart';", "int a = 0;"]); | 1660 library lib; |
| 1661 part 'part.dart'; |
| 1662 int a = 0;'''; |
| 1606 Source librarySource = _addSource("/lib.dart", oldCode); | 1663 Source librarySource = _addSource("/lib.dart", oldCode); |
| 1607 Source partSource = _addSource( | 1664 Source partSource = _addSource( |
| 1608 "/part.dart", | 1665 "/part.dart", |
| 1609 EngineTestCase.createSource(["part of lib;", "int b = a;"])); | 1666 r''' |
| 1667 part of lib; |
| 1668 int b = a;'''); |
| 1610 LibraryElement element = _context.computeLibraryElement(librarySource); | 1669 LibraryElement element = _context.computeLibraryElement(librarySource); |
| 1611 CompilationUnit unit = | 1670 CompilationUnit unit = |
| 1612 _context.getResolvedCompilationUnit(librarySource, element); | 1671 _context.getResolvedCompilationUnit(librarySource, element); |
| 1613 JUnitTestCase.assertNotNull(unit); | 1672 JUnitTestCase.assertNotNull(unit); |
| 1614 int offset = oldCode.indexOf("int a") + 4; | 1673 int offset = oldCode.indexOf("int a") + 4; |
| 1615 String newCode = EngineTestCase.createSource( | 1674 String newCode = r''' |
| 1616 ["library lib;", "part 'part.dart';", "int ya = 0;"]); | 1675 library lib; |
| 1676 part 'part.dart'; |
| 1677 int ya = 0;'''; |
| 1617 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | 1678 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); |
| 1618 _context.setChangedContents(librarySource, newCode, offset, 0, 1); | 1679 _context.setChangedContents(librarySource, newCode, offset, 0, 1); |
| 1619 JUnitTestCase.assertEquals( | 1680 JUnitTestCase.assertEquals( |
| 1620 newCode, | 1681 newCode, |
| 1621 _context.getContents(librarySource).data); | 1682 _context.getContents(librarySource).data); |
| 1622 IncrementalAnalysisCache incrementalCache = | 1683 IncrementalAnalysisCache incrementalCache = |
| 1623 _getIncrementalAnalysisCache(_context); | 1684 _getIncrementalAnalysisCache(_context); |
| 1624 JUnitTestCase.assertEquals(librarySource, incrementalCache.librarySource); | 1685 JUnitTestCase.assertEquals(librarySource, incrementalCache.librarySource); |
| 1625 JUnitTestCase.assertSame(unit, incrementalCache.resolvedUnit); | 1686 JUnitTestCase.assertSame(unit, incrementalCache.resolvedUnit); |
| 1626 JUnitTestCase.assertNull( | 1687 JUnitTestCase.assertNull( |
| 1627 _context.getResolvedCompilationUnit2(partSource, librarySource)); | 1688 _context.getResolvedCompilationUnit2(partSource, librarySource)); |
| 1628 JUnitTestCase.assertEquals(newCode, incrementalCache.newContents); | 1689 JUnitTestCase.assertEquals(newCode, incrementalCache.newContents); |
| 1629 } | 1690 } |
| 1630 | 1691 |
| 1631 void test_setChangedContents_notResolved() { | 1692 void test_setChangedContents_notResolved() { |
| 1632 _context = AnalysisContextFactory.contextWithCore(); | 1693 _context = AnalysisContextFactory.contextWithCore(); |
| 1633 AnalysisOptionsImpl options = | 1694 AnalysisOptionsImpl options = |
| 1634 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1695 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1635 options.incremental = true; | 1696 options.incremental = true; |
| 1636 _context.analysisOptions = options; | 1697 _context.analysisOptions = options; |
| 1637 _sourceFactory = _context.sourceFactory; | 1698 _sourceFactory = _context.sourceFactory; |
| 1638 String oldCode = | 1699 String oldCode = |
| 1639 EngineTestCase.createSource(["library lib;", "int a = 0;"]); | 1700 r''' |
| 1701 library lib; |
| 1702 int a = 0;'''; |
| 1640 Source librarySource = _addSource("/lib.dart", oldCode); | 1703 Source librarySource = _addSource("/lib.dart", oldCode); |
| 1641 int offset = oldCode.indexOf("int a") + 4; | 1704 int offset = oldCode.indexOf("int a") + 4; |
| 1642 String newCode = | 1705 String newCode = |
| 1643 EngineTestCase.createSource(["library lib;", "int ya = 0;"]); | 1706 r''' |
| 1707 library lib; |
| 1708 int ya = 0;'''; |
| 1644 _context.setChangedContents(librarySource, newCode, offset, 0, 1); | 1709 _context.setChangedContents(librarySource, newCode, offset, 0, 1); |
| 1645 JUnitTestCase.assertEquals( | 1710 JUnitTestCase.assertEquals( |
| 1646 newCode, | 1711 newCode, |
| 1647 _context.getContents(librarySource).data); | 1712 _context.getContents(librarySource).data); |
| 1648 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | 1713 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); |
| 1649 } | 1714 } |
| 1650 | 1715 |
| 1651 void test_setContents_libraryWithPart() { | 1716 void test_setContents_libraryWithPart() { |
| 1652 _context = AnalysisContextFactory.contextWithCore(); | 1717 _context = AnalysisContextFactory.contextWithCore(); |
| 1653 _sourceFactory = _context.sourceFactory; | 1718 _sourceFactory = _context.sourceFactory; |
| 1654 Source librarySource = _addSource( | 1719 Source librarySource = _addSource( |
| 1655 "/lib.dart", | 1720 "/lib.dart", |
| 1656 EngineTestCase.createSource( | 1721 r''' |
| 1657 ["library lib;", "part 'part.dart';", "int a = 0;"])); | 1722 library lib; |
| 1723 part 'part.dart'; |
| 1724 int a = 0;'''); |
| 1658 Source partSource = _addSource( | 1725 Source partSource = _addSource( |
| 1659 "/part.dart", | 1726 "/part.dart", |
| 1660 EngineTestCase.createSource(["part of lib;", "int b = a;"])); | 1727 r''' |
| 1728 part of lib; |
| 1729 int b = a;'''); |
| 1661 _context.computeLibraryElement(librarySource); | 1730 _context.computeLibraryElement(librarySource); |
| 1662 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1731 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
| 1663 librarySource, | 1732 librarySource, |
| 1664 librarySource, | 1733 librarySource, |
| 1665 null, | 1734 null, |
| 1666 null, | 1735 null, |
| 1667 null, | 1736 null, |
| 1668 0, | 1737 0, |
| 1669 0, | 1738 0, |
| 1670 0); | 1739 0); |
| 1671 _setIncrementalAnalysisCache(_context, incrementalCache); | 1740 _setIncrementalAnalysisCache(_context, incrementalCache); |
| 1672 JUnitTestCase.assertSame( | 1741 JUnitTestCase.assertSame( |
| 1673 incrementalCache, | 1742 incrementalCache, |
| 1674 _getIncrementalAnalysisCache(_context)); | 1743 _getIncrementalAnalysisCache(_context)); |
| 1675 _context.setContents( | 1744 _context.setContents( |
| 1676 librarySource, | 1745 librarySource, |
| 1677 EngineTestCase.createSource( | 1746 r''' |
| 1678 ["library lib;", "part 'part.dart';", "int aa = 0;"])); | 1747 library lib; |
| 1748 part 'part.dart'; |
| 1749 int aa = 0;'''); |
| 1679 JUnitTestCase.assertNull( | 1750 JUnitTestCase.assertNull( |
| 1680 _context.getResolvedCompilationUnit2(partSource, librarySource)); | 1751 _context.getResolvedCompilationUnit2(partSource, librarySource)); |
| 1681 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); | 1752 JUnitTestCase.assertNull(_getIncrementalAnalysisCache(_context)); |
| 1682 } | 1753 } |
| 1683 | 1754 |
| 1684 void test_setContents_null() { | 1755 void test_setContents_null() { |
| 1685 _context = AnalysisContextFactory.contextWithCore(); | 1756 _context = AnalysisContextFactory.contextWithCore(); |
| 1686 _sourceFactory = _context.sourceFactory; | 1757 _sourceFactory = _context.sourceFactory; |
| 1687 Source librarySource = _addSource( | 1758 Source librarySource = _addSource( |
| 1688 "/lib.dart", | 1759 "/lib.dart", |
| 1689 EngineTestCase.createSource(["library lib;", "int a = 0;"])); | 1760 r''' |
| 1761 library lib; |
| 1762 int a = 0;'''); |
| 1690 _context.computeLibraryElement(librarySource); | 1763 _context.computeLibraryElement(librarySource); |
| 1691 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( | 1764 IncrementalAnalysisCache incrementalCache = new IncrementalAnalysisCache( |
| 1692 librarySource, | 1765 librarySource, |
| 1693 librarySource, | 1766 librarySource, |
| 1694 null, | 1767 null, |
| 1695 null, | 1768 null, |
| 1696 null, | 1769 null, |
| 1697 0, | 1770 0, |
| 1698 0, | 1771 0, |
| 1699 0); | 1772 0); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1712 SourceFactory factory = new SourceFactory([]); | 1785 SourceFactory factory = new SourceFactory([]); |
| 1713 _context.sourceFactory = factory; | 1786 _context.sourceFactory = factory; |
| 1714 JUnitTestCase.assertEquals(factory, _context.sourceFactory); | 1787 JUnitTestCase.assertEquals(factory, _context.sourceFactory); |
| 1715 } | 1788 } |
| 1716 | 1789 |
| 1717 void test_unreadableSource() { | 1790 void test_unreadableSource() { |
| 1718 _context = AnalysisContextFactory.contextWithCore(); | 1791 _context = AnalysisContextFactory.contextWithCore(); |
| 1719 _sourceFactory = _context.sourceFactory; | 1792 _sourceFactory = _context.sourceFactory; |
| 1720 Source test1 = _addSource( | 1793 Source test1 = _addSource( |
| 1721 "/test1.dart", | 1794 "/test1.dart", |
| 1722 EngineTestCase.createSource(["import 'test2.dart';", "library test1;"]))
; | 1795 r''' |
| 1796 import 'test2.dart'; |
| 1797 library test1;'''); |
| 1723 Source test2 = _addSource( | 1798 Source test2 = _addSource( |
| 1724 "/test2.dart", | 1799 "/test2.dart", |
| 1725 EngineTestCase.createSource( | 1800 r''' |
| 1726 ["import 'test1.dart';", "import 'test3.dart';", "library test2;"]))
; | 1801 import 'test1.dart'; |
| 1802 import 'test3.dart'; |
| 1803 library test2;'''); |
| 1727 Source test3 = _addSourceWithException("/test3.dart"); | 1804 Source test3 = _addSourceWithException("/test3.dart"); |
| 1728 _analyzeAll_assertFinished(); | 1805 _analyzeAll_assertFinished(); |
| 1729 // test1 and test2 should have been successfully analyzed | 1806 // test1 and test2 should have been successfully analyzed |
| 1730 // despite the fact that test3 couldn't be read. | 1807 // despite the fact that test3 couldn't be read. |
| 1731 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test1)); | 1808 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test1)); |
| 1732 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test2)); | 1809 JUnitTestCase.assertNotNull(_context.computeLibraryElement(test2)); |
| 1733 JUnitTestCase.assertNull(_context.computeLibraryElement(test3)); | 1810 JUnitTestCase.assertNull(_context.computeLibraryElement(test3)); |
| 1734 } | 1811 } |
| 1735 | 1812 |
| 1736 void test_updateAnalysis() { | 1813 void test_updateAnalysis() { |
| (...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3456 | 3533 |
| 3457 void test_perform() { | 3534 void test_perform() { |
| 3458 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3535 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3459 Source source = | 3536 Source source = |
| 3460 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3537 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 3461 ChangeSet changeSet = new ChangeSet(); | 3538 ChangeSet changeSet = new ChangeSet(); |
| 3462 changeSet.addedSource(source); | 3539 changeSet.addedSource(source); |
| 3463 context.applyChanges(changeSet); | 3540 context.applyChanges(changeSet); |
| 3464 context.setContents( | 3541 context.setContents( |
| 3465 source, | 3542 source, |
| 3466 EngineTestCase.createSource( | 3543 r''' |
| 3467 ["library lib;", "class A {", " int f = new A();", "}"])); | 3544 library lib; |
| 3545 class A { |
| 3546 int f = new A(); |
| 3547 }'''); |
| 3468 LibraryElement libraryElement = context.computeLibraryElement(source); | 3548 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3469 CompilationUnit unit = | 3549 CompilationUnit unit = |
| 3470 context.getResolvedCompilationUnit(source, libraryElement); | 3550 context.getResolvedCompilationUnit(source, libraryElement); |
| 3471 GenerateDartErrorsTask task = new GenerateDartErrorsTask( | 3551 GenerateDartErrorsTask task = new GenerateDartErrorsTask( |
| 3472 context, | 3552 context, |
| 3473 source, | 3553 source, |
| 3474 unit, | 3554 unit, |
| 3475 libraryElement); | 3555 libraryElement); |
| 3476 task.perform( | 3556 task.perform( |
| 3477 new GenerateDartErrorsTaskTestTV_perform(libraryElement, source)); | 3557 new GenerateDartErrorsTaskTestTV_perform(libraryElement, source)); |
| 3478 } | 3558 } |
| 3479 | 3559 |
| 3480 void test_perform_validateDirectives() { | 3560 void test_perform_validateDirectives() { |
| 3481 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 3561 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 3482 Source source = | 3562 Source source = |
| 3483 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 3563 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 3484 ChangeSet changeSet = new ChangeSet(); | 3564 ChangeSet changeSet = new ChangeSet(); |
| 3485 changeSet.addedSource(source); | 3565 changeSet.addedSource(source); |
| 3486 context.applyChanges(changeSet); | 3566 context.applyChanges(changeSet); |
| 3487 // TODO(scheglov) "import" causes second error reported | 3567 // TODO(scheglov) "import" causes second error reported |
| 3488 // context.setContents(source, EngineTestCase.createSource([ | 3568 // context.setContents(source, EngineTestCase.createSource([ |
| 3489 // "library lib;", | 3569 // "library lib;", |
| 3490 // "import 'invaliduri^.dart';", | 3570 // "import 'invaliduri^.dart';", |
| 3491 // "export '\${a}lib3.dart';", | 3571 // "export '\${a}lib3.dart';", |
| 3492 // "part '/does/not/exist.dart';", | 3572 // "part '/does/not/exist.dart';", |
| 3493 // "class A {}"])); | 3573 // "class A {}"])); |
| 3494 context.setContents( | 3574 context.setContents( |
| 3495 source, | 3575 source, |
| 3496 EngineTestCase.createSource( | 3576 r''' |
| 3497 ["library lib;", "part '/does/not/exist.dart';", "class A {}"])); | 3577 library lib; |
| 3578 part '/does/not/exist.dart'; |
| 3579 class A {}'''); |
| 3498 LibraryElement libraryElement = context.computeLibraryElement(source); | 3580 LibraryElement libraryElement = context.computeLibraryElement(source); |
| 3499 CompilationUnit unit = | 3581 CompilationUnit unit = |
| 3500 context.getResolvedCompilationUnit(source, libraryElement); | 3582 context.getResolvedCompilationUnit(source, libraryElement); |
| 3501 GenerateDartErrorsTask task = new GenerateDartErrorsTask( | 3583 GenerateDartErrorsTask task = new GenerateDartErrorsTask( |
| 3502 context, | 3584 context, |
| 3503 source, | 3585 source, |
| 3504 unit, | 3586 unit, |
| 3505 libraryElement); | 3587 libraryElement); |
| 3506 task.perform( | 3588 task.perform( |
| 3507 new GenerateDartErrorsTaskTestTV_perform_validateDirectives( | 3589 new GenerateDartErrorsTaskTestTV_perform_validateDirectives( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3588 changeSet.addedSource(librarySource); | 3670 changeSet.addedSource(librarySource); |
| 3589 Source unusedSource = | 3671 Source unusedSource = |
| 3590 new FileBasedSource.con1(FileUtilities2.createFile("/unused.dart")); | 3672 new FileBasedSource.con1(FileUtilities2.createFile("/unused.dart")); |
| 3591 changeSet.addedSource(unusedSource); | 3673 changeSet.addedSource(unusedSource); |
| 3592 Source partSource = | 3674 Source partSource = |
| 3593 new FileBasedSource.con1(FileUtilities2.createFile("/part.dart")); | 3675 new FileBasedSource.con1(FileUtilities2.createFile("/part.dart")); |
| 3594 changeSet.addedSource(partSource); | 3676 changeSet.addedSource(partSource); |
| 3595 context.applyChanges(changeSet); | 3677 context.applyChanges(changeSet); |
| 3596 context.setContents( | 3678 context.setContents( |
| 3597 librarySource, | 3679 librarySource, |
| 3598 EngineTestCase.createSource( | 3680 r''' |
| 3599 ["library lib;", "import 'unused.dart';", "part 'part.dart';"])); | 3681 library lib; |
| 3682 import 'unused.dart'; |
| 3683 part 'part.dart';'''); |
| 3600 context.setContents( | 3684 context.setContents( |
| 3601 unusedSource, | 3685 unusedSource, |
| 3602 EngineTestCase.createSource(["library unused;"])); | 3686 "library unused;"); |
| 3603 context.setContents( | 3687 context.setContents( |
| 3604 partSource, | 3688 partSource, |
| 3605 EngineTestCase.createSource(["part of lib;"])); | 3689 "part of lib;"); |
| 3606 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(2); | 3690 List<TimestampedData<CompilationUnit>> units = new List<TimestampedData>(2); |
| 3607 units[0] = new TimestampedData<CompilationUnit>( | 3691 units[0] = new TimestampedData<CompilationUnit>( |
| 3608 context.getModificationStamp(librarySource), | 3692 context.getModificationStamp(librarySource), |
| 3609 context.resolveCompilationUnit2(librarySource, librarySource)); | 3693 context.resolveCompilationUnit2(librarySource, librarySource)); |
| 3610 units[1] = new TimestampedData<CompilationUnit>( | 3694 units[1] = new TimestampedData<CompilationUnit>( |
| 3611 context.getModificationStamp(partSource), | 3695 context.getModificationStamp(partSource), |
| 3612 context.resolveCompilationUnit2(partSource, librarySource)); | 3696 context.resolveCompilationUnit2(partSource, librarySource)); |
| 3613 GenerateDartHintsTask task = new GenerateDartHintsTask( | 3697 GenerateDartHintsTask task = new GenerateDartHintsTask( |
| 3614 context, | 3698 context, |
| 3615 units, | 3699 units, |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4569 TopLevelVariableDeclaration fooDecl = | 4653 TopLevelVariableDeclaration fooDecl = |
| 4570 declarations[1] as TopLevelVariableDeclaration; | 4654 declarations[1] as TopLevelVariableDeclaration; |
| 4571 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; | 4655 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; |
| 4572 JUnitTestCase.assertEquals("foo", fooName.name); | 4656 JUnitTestCase.assertEquals("foo", fooName.name); |
| 4573 JUnitTestCase.assertNotNull(fooName.staticElement); | 4657 JUnitTestCase.assertNotNull(fooName.staticElement); |
| 4574 // assert element reference is preserved | 4658 // assert element reference is preserved |
| 4575 } | 4659 } |
| 4576 | 4660 |
| 4577 CompilationUnit _assertTask(String prefix, String removed, String added, | 4661 CompilationUnit _assertTask(String prefix, String removed, String added, |
| 4578 String suffix) { | 4662 String suffix) { |
| 4579 String oldCode = | 4663 String oldCode = "${prefix}${removed}${suffix}"; |
| 4580 EngineTestCase.createSource(["${prefix}${removed}${suffix}"]); | 4664 String newCode = "${prefix}${added}${suffix}"; |
| 4581 String newCode = | |
| 4582 EngineTestCase.createSource(["${prefix}${added}${suffix}"]); | |
| 4583 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4665 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 4584 Source source = new TestSource("/test.dart", oldCode); | 4666 Source source = new TestSource("/test.dart", oldCode); |
| 4585 DartEntry entry = new DartEntry(); | 4667 DartEntry entry = new DartEntry(); |
| 4586 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); | 4668 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); |
| 4587 JUnitTestCase.assertNotNull(oldUnit); | 4669 JUnitTestCase.assertNotNull(oldUnit); |
| 4588 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); | 4670 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); |
| 4589 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 4671 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4590 null, | 4672 null, |
| 4591 source, | 4673 source, |
| 4592 oldCode, | 4674 oldCode, |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5171 void test_perform_exception() { | 5253 void test_perform_exception() { |
| 5172 TestSource source = new TestSource(); | 5254 TestSource source = new TestSource(); |
| 5173 source.generateExceptionOnRead = true; | 5255 source.generateExceptionOnRead = true; |
| 5174 InternalAnalysisContext context = new AnalysisContextImpl(); | 5256 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5175 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5257 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5176 ParseDartTask task = new ParseDartTask(context, source, null, null); | 5258 ParseDartTask task = new ParseDartTask(context, source, null, null); |
| 5177 task.perform(new ParseDartTaskTestTV_perform_exception()); | 5259 task.perform(new ParseDartTaskTestTV_perform_exception()); |
| 5178 } | 5260 } |
| 5179 | 5261 |
| 5180 void test_perform_library() { | 5262 void test_perform_library() { |
| 5181 String content = EngineTestCase.createSource( | 5263 String content = r''' |
| 5182 [ | 5264 library lib; |
| 5183 "library lib;", | 5265 import 'lib2.dart'; |
| 5184 "import 'lib2.dart';", | 5266 export 'lib3.dart'; |
| 5185 "export 'lib3.dart';", | 5267 part 'part.dart'; |
| 5186 "part 'part.dart';", | 5268 class A {'''; |
| 5187 "class A {"]); | |
| 5188 Source source = new TestSource('/test.dart', content); | 5269 Source source = new TestSource('/test.dart', content); |
| 5189 InternalAnalysisContext context = new AnalysisContextImpl(); | 5270 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5190 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5271 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5191 ParseDartTask task = _createParseTask(context, source, content); | 5272 ParseDartTask task = _createParseTask(context, source, content); |
| 5192 task.perform(new ParseDartTaskTestTV_perform_library(context, source)); | 5273 task.perform(new ParseDartTaskTestTV_perform_library(context, source)); |
| 5193 } | 5274 } |
| 5194 | 5275 |
| 5195 void test_perform_part() { | 5276 void test_perform_part() { |
| 5196 String content = | 5277 String content = |
| 5197 EngineTestCase.createSource(["part of lib;", "class B {}"]); | 5278 r''' |
| 5279 part of lib; |
| 5280 class B {}'''; |
| 5198 Source source = new TestSource('/test.dart', content); | 5281 Source source = new TestSource('/test.dart', content); |
| 5199 InternalAnalysisContext context = new AnalysisContextImpl(); | 5282 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5200 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5283 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5201 ParseDartTask task = _createParseTask(context, source, content); | 5284 ParseDartTask task = _createParseTask(context, source, content); |
| 5202 task.perform(new ParseDartTaskTestTV_perform_part(context, source)); | 5285 task.perform(new ParseDartTaskTestTV_perform_part(context, source)); |
| 5203 } | 5286 } |
| 5204 | 5287 |
| 5205 void test_perform_validateDirectives() { | 5288 void test_perform_validateDirectives() { |
| 5206 String content = EngineTestCase.createSource( | 5289 String content = r''' |
| 5207 [ | 5290 library lib; |
| 5208 "library lib;", | 5291 import '/does/not/exist.dart'; |
| 5209 "import '/does/not/exist.dart';", | 5292 import '://invaliduri.dart'; |
| 5210 "import '://invaliduri.dart';", | 5293 export '${a}lib3.dart'; |
| 5211 "export '\${a}lib3.dart';", | 5294 part 'part.dart'; |
| 5212 "part 'part.dart';", | 5295 class A {}'''; |
| 5213 "class A {}"]); | |
| 5214 Source source = new TestSource('/test.dart', content); | 5296 Source source = new TestSource('/test.dart', content); |
| 5215 InternalAnalysisContext context = new AnalysisContextImpl(); | 5297 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5216 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5298 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5217 ParseDartTask task = _createParseTask(context, source, content); | 5299 ParseDartTask task = _createParseTask(context, source, content); |
| 5218 task.perform( | 5300 task.perform( |
| 5219 new ParseDartTaskTestTV_perform_validateDirectives(context, source)); | 5301 new ParseDartTaskTestTV_perform_validateDirectives(context, source)); |
| 5220 } | 5302 } |
| 5221 | 5303 |
| 5222 /** | 5304 /** |
| 5223 * Create and return a task that will parse the given content from the given s
ource in the given | 5305 * Create and return a task that will parse the given content from the given s
ource in the given |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5384 EngineTestCase.assertLength(0, task.referencedLibraries); | 5466 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5385 } | 5467 } |
| 5386 | 5468 |
| 5387 void test_getSource() { | 5469 void test_getSource() { |
| 5388 Source source = new TestSource('/test.dart'); | 5470 Source source = new TestSource('/test.dart'); |
| 5389 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); | 5471 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); |
| 5390 JUnitTestCase.assertSame(source, task.source); | 5472 JUnitTestCase.assertSame(source, task.source); |
| 5391 } | 5473 } |
| 5392 | 5474 |
| 5393 void test_perform_embedded_source() { | 5475 void test_perform_embedded_source() { |
| 5394 String contents = EngineTestCase.createSource( | 5476 String contents = r''' |
| 5395 [ | 5477 <html> |
| 5396 "<html>", | 5478 <head> |
| 5397 "<head>", | 5479 <script type='application/dart'> |
| 5398 " <script type='application/dart'>", | 5480 void buttonPressed() {} |
| 5399 " void buttonPressed() {}", | 5481 </script> |
| 5400 " </script>", | 5482 </head> |
| 5401 "</head>", | 5483 <body> |
| 5402 "<body>", | 5484 </body> |
| 5403 "</body>", | 5485 </html>'''; |
| 5404 "</html>"]); | |
| 5405 TestLogger testLogger = new TestLogger(); | 5486 TestLogger testLogger = new TestLogger(); |
| 5406 ParseHtmlTask task = parseContents(contents, testLogger); | 5487 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5407 EngineTestCase.assertLength(0, task.referencedLibraries); | 5488 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5408 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 5489 JUnitTestCase.assertEquals(0, testLogger.errorCount); |
| 5409 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 5490 JUnitTestCase.assertEquals(0, testLogger.infoCount); |
| 5410 } | 5491 } |
| 5411 | 5492 |
| 5412 void test_perform_empty_source_reference() { | 5493 void test_perform_empty_source_reference() { |
| 5413 String contents = EngineTestCase.createSource( | 5494 String contents = r''' |
| 5414 [ | 5495 <html> |
| 5415 "<html>", | 5496 <head> |
| 5416 "<head>", | 5497 <script type='application/dart' src=''/> |
| 5417 " <script type='application/dart' src=''/>", | 5498 </head> |
| 5418 "</head>", | 5499 <body> |
| 5419 "<body>", | 5500 </body> |
| 5420 "</body>", | 5501 </html>'''; |
| 5421 "</html>"]); | |
| 5422 TestLogger testLogger = new TestLogger(); | 5502 TestLogger testLogger = new TestLogger(); |
| 5423 ParseHtmlTask task = parseContents(contents, testLogger); | 5503 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5424 EngineTestCase.assertLength(0, task.referencedLibraries); | 5504 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5425 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 5505 JUnitTestCase.assertEquals(0, testLogger.errorCount); |
| 5426 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 5506 JUnitTestCase.assertEquals(0, testLogger.infoCount); |
| 5427 } | 5507 } |
| 5428 | 5508 |
| 5429 void test_perform_invalid_source_reference() { | 5509 void test_perform_invalid_source_reference() { |
| 5430 String contents = EngineTestCase.createSource( | 5510 String contents = r''' |
| 5431 [ | 5511 <html> |
| 5432 "<html>", | 5512 <head> |
| 5433 "<head>", | 5513 <script type='application/dart' src='an;invalid:[]uri'/> |
| 5434 " <script type='application/dart' src='an;invalid:[]uri'/>", | 5514 </head> |
| 5435 "</head>", | 5515 <body> |
| 5436 "<body>", | 5516 </body> |
| 5437 "</body>", | 5517 </html>'''; |
| 5438 "</html>"]); | |
| 5439 TestLogger testLogger = new TestLogger(); | 5518 TestLogger testLogger = new TestLogger(); |
| 5440 ParseHtmlTask task = parseContents(contents, testLogger); | 5519 ParseHtmlTask task = parseContents(contents, testLogger); |
| 5441 EngineTestCase.assertLength(0, task.referencedLibraries); | 5520 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5442 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 5521 JUnitTestCase.assertEquals(0, testLogger.errorCount); |
| 5443 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 5522 JUnitTestCase.assertEquals(0, testLogger.infoCount); |
| 5444 } | 5523 } |
| 5445 | 5524 |
| 5446 void test_perform_non_existing_source_reference() { | 5525 void test_perform_non_existing_source_reference() { |
| 5447 String contents = EngineTestCase.createSource( | 5526 String contents = r''' |
| 5448 [ | 5527 <html> |
| 5449 "<html>", | 5528 <head> |
| 5450 "<head>", | 5529 <script type='application/dart' src='does/not/exist.dart'/> |
| 5451 " <script type='application/dart' src='does/not/exist.dart'/>", | 5530 </head> |
| 5452 "</head>", | 5531 <body> |
| 5453 "<body>", | 5532 </body> |
| 5454 "</body>", | 5533 </html>'''; |
| 5455 "</html>"]); | |
| 5456 TestLogger testLogger = new TestLogger(); | 5534 TestLogger testLogger = new TestLogger(); |
| 5457 ParseHtmlTask task = parseSource( | 5535 ParseHtmlTask task = parseSource( |
| 5458 new ParseHtmlTaskTest_non_existing_source(contents), | 5536 new ParseHtmlTaskTest_non_existing_source(contents), |
| 5459 contents, | 5537 contents, |
| 5460 testLogger); | 5538 testLogger); |
| 5461 EngineTestCase.assertLength(0, task.referencedLibraries); | 5539 EngineTestCase.assertLength(0, task.referencedLibraries); |
| 5462 JUnitTestCase.assertEquals(0, testLogger.errorCount); | 5540 JUnitTestCase.assertEquals(0, testLogger.errorCount); |
| 5463 JUnitTestCase.assertEquals(0, testLogger.infoCount); | 5541 JUnitTestCase.assertEquals(0, testLogger.infoCount); |
| 5464 } | 5542 } |
| 5465 | 5543 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5582 source.generateExceptionOnRead = true; | 5660 source.generateExceptionOnRead = true; |
| 5583 InternalAnalysisContext context = new AnalysisContextImpl(); | 5661 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5584 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5662 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5585 ResolveDartLibraryTask task = | 5663 ResolveDartLibraryTask task = |
| 5586 new ResolveDartLibraryTask(context, source, source); | 5664 new ResolveDartLibraryTask(context, source, source); |
| 5587 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); | 5665 task.perform(new ResolveDartLibraryTaskTestTV_perform_exception()); |
| 5588 } | 5666 } |
| 5589 void test_perform_library() { | 5667 void test_perform_library() { |
| 5590 Source source = new TestSource( | 5668 Source source = new TestSource( |
| 5591 '/test.dart', | 5669 '/test.dart', |
| 5592 EngineTestCase.createSource(["library lib;", "class A {}"])); | 5670 r''' |
| 5671 library lib; |
| 5672 class A {}'''); |
| 5593 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 5673 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 5594 ResolveDartLibraryTask task = | 5674 ResolveDartLibraryTask task = |
| 5595 new ResolveDartLibraryTask(context, source, source); | 5675 new ResolveDartLibraryTask(context, source, source); |
| 5596 task.perform(new ResolveDartLibraryTaskTestTV_perform_library(source)); | 5676 task.perform(new ResolveDartLibraryTaskTestTV_perform_library(source)); |
| 5597 } | 5677 } |
| 5598 } | 5678 } |
| 5599 | 5679 |
| 5600 | 5680 |
| 5601 class ResolveDartLibraryTaskTestTV_accept extends TestTaskVisitor<bool> { | 5681 class ResolveDartLibraryTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 5602 @override | 5682 @override |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5683 ClassElementImpl classElement = ElementFactory.classElement2("A", []); | 5763 ClassElementImpl classElement = ElementFactory.classElement2("A", []); |
| 5684 classElement.nameOffset = 19; | 5764 classElement.nameOffset = 19; |
| 5685 ConstructorElementImpl constructorElement = | 5765 ConstructorElementImpl constructorElement = |
| 5686 ElementFactory.constructorElement2(classElement, null, []); | 5766 ElementFactory.constructorElement2(classElement, null, []); |
| 5687 constructorElement.synthetic = true; | 5767 constructorElement.synthetic = true; |
| 5688 classElement.constructors = <ConstructorElement>[constructorElement]; | 5768 classElement.constructors = <ConstructorElement>[constructorElement]; |
| 5689 unitElement.types = <ClassElement>[classElement]; | 5769 unitElement.types = <ClassElement>[classElement]; |
| 5690 Source source = unitElement.source; | 5770 Source source = unitElement.source; |
| 5691 context.setContents( | 5771 context.setContents( |
| 5692 source, | 5772 source, |
| 5693 EngineTestCase.createSource(["library lib;", "class A {}"])); | 5773 r''' |
| 5774 library lib; |
| 5775 class A {}'''); |
| 5694 ResolveDartUnitTask task = | 5776 ResolveDartUnitTask task = |
| 5695 new ResolveDartUnitTask(context, source, libraryElement); | 5777 new ResolveDartUnitTask(context, source, libraryElement); |
| 5696 task.perform( | 5778 task.perform( |
| 5697 new ResolveDartUnitTaskTestTV_perform_library(source, context)); | 5779 new ResolveDartUnitTaskTestTV_perform_library(source, context)); |
| 5698 } | 5780 } |
| 5699 } | 5781 } |
| 5700 | 5782 |
| 5701 | 5783 |
| 5702 class ResolveDartUnitTaskTestTV_accept extends TestTaskVisitor<bool> { | 5784 class ResolveDartUnitTaskTestTV_accept extends TestTaskVisitor<bool> { |
| 5703 @override | 5785 @override |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5763 void test_perform_exception() { | 5845 void test_perform_exception() { |
| 5764 Source source = new TestSource(); | 5846 Source source = new TestSource(); |
| 5765 InternalAnalysisContext context = new AnalysisContextImpl(); | 5847 InternalAnalysisContext context = new AnalysisContextImpl(); |
| 5766 context.sourceFactory = new SourceFactory([new FileUriResolver()]); | 5848 context.sourceFactory = new SourceFactory([new FileUriResolver()]); |
| 5767 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); | 5849 ResolveHtmlTask task = new ResolveHtmlTask(context, source, 0, null); |
| 5768 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); | 5850 task.perform(new ResolveHtmlTaskTestTV_perform_exception()); |
| 5769 } | 5851 } |
| 5770 | 5852 |
| 5771 void test_perform_valid() { | 5853 void test_perform_valid() { |
| 5772 int modificationStamp = 73; | 5854 int modificationStamp = 73; |
| 5773 String content = EngineTestCase.createSource( | 5855 String content = r''' |
| 5774 [ | 5856 <html> |
| 5775 "<html>", | 5857 <head> |
| 5776 "<head>", | 5858 <script type='application/dart'> |
| 5777 " <script type='application/dart'>", | 5859 void f() { x = 0; } |
| 5778 " void f() { x = 0; }", | 5860 </script> |
| 5779 " </script>", | 5861 </head> |
| 5780 "</head>", | 5862 <body> |
| 5781 "<body>", | 5863 </body> |
| 5782 "</body>", | 5864 </html>'''; |
| 5783 "</html>"]); | |
| 5784 Source source = new TestSource("/test.html", content); | 5865 Source source = new TestSource("/test.html", content); |
| 5785 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 5866 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 5786 ParseHtmlTask parseTask = | 5867 ParseHtmlTask parseTask = |
| 5787 new ParseHtmlTask(context, source, content); | 5868 new ParseHtmlTask(context, source, content); |
| 5788 parseTask.perform(new ResolveHtmlTaskTestTV_perform_valid_2()); | 5869 parseTask.perform(new ResolveHtmlTaskTestTV_perform_valid_2()); |
| 5789 ResolveHtmlTask task = new ResolveHtmlTask( | 5870 ResolveHtmlTask task = new ResolveHtmlTask( |
| 5790 context, | 5871 context, |
| 5791 source, | 5872 source, |
| 5792 modificationStamp, | 5873 modificationStamp, |
| 5793 parseTask.htmlUnit); | 5874 parseTask.htmlUnit); |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7132 } | 7213 } |
| 7133 } | 7214 } |
| 7134 | 7215 |
| 7135 | 7216 |
| 7136 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 7217 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 7137 CacheRetentionPolicy { | 7218 CacheRetentionPolicy { |
| 7138 @override | 7219 @override |
| 7139 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 7220 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7140 RetentionPriority.LOW; | 7221 RetentionPriority.LOW; |
| 7141 } | 7222 } |
| OLD | NEW |