| 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 Source source = _addSource("/test.dart", "library test;"); | 285 Source source = _addSource("/test.dart", "library test;"); |
| 286 _context.computeErrors(source); | 286 _context.computeErrors(source); |
| 287 while (!_context.sourcesNeedingProcessing.isEmpty) { | 287 while (!_context.sourcesNeedingProcessing.isEmpty) { |
| 288 _context.performAnalysisTask(); | 288 _context.performAnalysisTask(); |
| 289 } | 289 } |
| 290 // Adding the source as a changedSource should have no effect since | 290 // Adding the source as a changedSource should have no effect since |
| 291 // it is already overridden in the content cache. | 291 // it is already overridden in the content cache. |
| 292 ChangeSet changeSet = new ChangeSet(); | 292 ChangeSet changeSet = new ChangeSet(); |
| 293 changeSet.changedSource(source); | 293 changeSet.changedSource(source); |
| 294 _context.applyChanges(changeSet); | 294 _context.applyChanges(changeSet); |
| 295 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 295 expect(_context.sourcesNeedingProcessing, hasLength(0)); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void test_applyChanges_remove() { | 298 void test_applyChanges_remove() { |
| 299 _context = AnalysisContextFactory.contextWithCore(); | 299 _context = AnalysisContextFactory.contextWithCore(); |
| 300 _sourceFactory = _context.sourceFactory; | 300 _sourceFactory = _context.sourceFactory; |
| 301 Source libA = _addSource( | 301 Source libA = _addSource( |
| 302 "/libA.dart", | 302 "/libA.dart", |
| 303 r''' | 303 r''' |
| 304 library libA; | 304 library libA; |
| 305 import 'libB.dart';'''); | 305 import 'libB.dart';'''); |
| 306 Source libB = | 306 Source libB = |
| 307 _addSource("/libB.dart", "library libB;"); | 307 _addSource("/libB.dart", "library libB;"); |
| 308 LibraryElement libAElement = _context.computeLibraryElement(libA); | 308 LibraryElement libAElement = _context.computeLibraryElement(libA); |
| 309 List<LibraryElement> importedLibraries = libAElement.importedLibraries; | 309 List<LibraryElement> importedLibraries = libAElement.importedLibraries; |
| 310 EngineTestCase.assertLength(2, importedLibraries); | 310 expect(importedLibraries, hasLength(2)); |
| 311 _context.computeErrors(libA); | 311 _context.computeErrors(libA); |
| 312 _context.computeErrors(libB); | 312 _context.computeErrors(libB); |
| 313 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 313 expect(_context.sourcesNeedingProcessing, hasLength(0)); |
| 314 _context.setContents(libB, null); | 314 _context.setContents(libB, null); |
| 315 _removeSource(libB); | 315 _removeSource(libB); |
| 316 List<Source> sources = _context.sourcesNeedingProcessing; | 316 List<Source> sources = _context.sourcesNeedingProcessing; |
| 317 EngineTestCase.assertSizeOfList(1, sources); | 317 expect(sources, hasLength(1)); |
| 318 expect(sources[0], same(libA)); | 318 expect(sources[0], same(libA)); |
| 319 libAElement = _context.computeLibraryElement(libA); | 319 libAElement = _context.computeLibraryElement(libA); |
| 320 importedLibraries = libAElement.importedLibraries; | 320 importedLibraries = libAElement.importedLibraries; |
| 321 EngineTestCase.assertLength(1, importedLibraries); | 321 expect(importedLibraries, hasLength(1)); |
| 322 } | 322 } |
| 323 | 323 |
| 324 void test_applyChanges_removeContainer() { | 324 void test_applyChanges_removeContainer() { |
| 325 _context = AnalysisContextFactory.contextWithCore(); | 325 _context = AnalysisContextFactory.contextWithCore(); |
| 326 _sourceFactory = _context.sourceFactory; | 326 _sourceFactory = _context.sourceFactory; |
| 327 Source libA = _addSource( | 327 Source libA = _addSource( |
| 328 "/libA.dart", | 328 "/libA.dart", |
| 329 r''' | 329 r''' |
| 330 library libA; | 330 library libA; |
| 331 import 'libB.dart';'''); | 331 import 'libB.dart';'''); |
| 332 Source libB = | 332 Source libB = |
| 333 _addSource("/libB.dart", "library libB;"); | 333 _addSource("/libB.dart", "library libB;"); |
| 334 _context.computeLibraryElement(libA); | 334 _context.computeLibraryElement(libA); |
| 335 _context.computeErrors(libA); | 335 _context.computeErrors(libA); |
| 336 _context.computeErrors(libB); | 336 _context.computeErrors(libB); |
| 337 EngineTestCase.assertSizeOfList(0, _context.sourcesNeedingProcessing); | 337 expect(_context.sourcesNeedingProcessing, hasLength(0)); |
| 338 ChangeSet changeSet = new ChangeSet(); | 338 ChangeSet changeSet = new ChangeSet(); |
| 339 changeSet.removedContainer( | 339 changeSet.removedContainer( |
| 340 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); | 340 new _AnalysisContextImplTest_test_applyChanges_removeContainer(libB)); |
| 341 _context.applyChanges(changeSet); | 341 _context.applyChanges(changeSet); |
| 342 List<Source> sources = _context.sourcesNeedingProcessing; | 342 List<Source> sources = _context.sourcesNeedingProcessing; |
| 343 EngineTestCase.assertSizeOfList(1, sources); | 343 expect(sources, hasLength(1)); |
| 344 expect(sources[0], same(libA)); | 344 expect(sources[0], same(libA)); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void test_computeDocumentationComment_block() { | 347 void test_computeDocumentationComment_block() { |
| 348 _context = AnalysisContextFactory.contextWithCore(); | 348 _context = AnalysisContextFactory.contextWithCore(); |
| 349 _sourceFactory = _context.sourceFactory; | 349 _sourceFactory = _context.sourceFactory; |
| 350 String comment = "/** Comment */"; | 350 String comment = "/** Comment */"; |
| 351 Source source = | 351 Source source = |
| 352 _addSource("/test.dart", """ | 352 _addSource("/test.dart", """ |
| 353 $comment | 353 $comment |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 397 expect(libraryElement, isNotNull); | 397 expect(libraryElement, isNotNull); |
| 398 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; | 398 ClassElement classElement = libraryElement.definingCompilationUnit.types[0]; |
| 399 expect(libraryElement, isNotNull); | 399 expect(libraryElement, isNotNull); |
| 400 String actual = _context.computeDocumentationComment(classElement); | 400 String actual = _context.computeDocumentationComment(classElement); |
| 401 expect(actual, "/// line 1\n/// line 2\n/// line 3"); | 401 expect(actual, "/// line 1\n/// line 2\n/// line 3"); |
| 402 } | 402 } |
| 403 | 403 |
| 404 void test_computeErrors_dart_none() { | 404 void test_computeErrors_dart_none() { |
| 405 Source source = _addSource("/lib.dart", "library lib;"); | 405 Source source = _addSource("/lib.dart", "library lib;"); |
| 406 List<AnalysisError> errors = _context.computeErrors(source); | 406 List<AnalysisError> errors = _context.computeErrors(source); |
| 407 EngineTestCase.assertLength(0, errors); | 407 expect(errors, hasLength(0)); |
| 408 } | 408 } |
| 409 | 409 |
| 410 void test_computeErrors_dart_part() { | 410 void test_computeErrors_dart_part() { |
| 411 Source librarySource = | 411 Source librarySource = |
| 412 _addSource("/lib.dart", "library lib; part 'part.dart';"); | 412 _addSource("/lib.dart", "library lib; part 'part.dart';"); |
| 413 Source partSource = _addSource("/part.dart", "part of 'lib';"); | 413 Source partSource = _addSource("/part.dart", "part of 'lib';"); |
| 414 _context.parseCompilationUnit(librarySource); | 414 _context.parseCompilationUnit(librarySource); |
| 415 List<AnalysisError> errors = _context.computeErrors(partSource); | 415 List<AnalysisError> errors = _context.computeErrors(partSource); |
| 416 expect(errors, isNotNull); | 416 expect(errors, isNotNull); |
| 417 expect(errors.length > 0, isTrue); | 417 expect(errors.length > 0, isTrue); |
| 418 } | 418 } |
| 419 | 419 |
| 420 void test_computeErrors_dart_some() { | 420 void test_computeErrors_dart_some() { |
| 421 Source source = _addSource("/lib.dart", "library 'lib';"); | 421 Source source = _addSource("/lib.dart", "library 'lib';"); |
| 422 List<AnalysisError> errors = _context.computeErrors(source); | 422 List<AnalysisError> errors = _context.computeErrors(source); |
| 423 expect(errors, isNotNull); | 423 expect(errors, isNotNull); |
| 424 expect(errors.length > 0, isTrue); | 424 expect(errors.length > 0, isTrue); |
| 425 } | 425 } |
| 426 | 426 |
| 427 void test_computeErrors_html_none() { | 427 void test_computeErrors_html_none() { |
| 428 Source source = _addSource("/test.html", "<html></html>"); | 428 Source source = _addSource("/test.html", "<html></html>"); |
| 429 List<AnalysisError> errors = _context.computeErrors(source); | 429 List<AnalysisError> errors = _context.computeErrors(source); |
| 430 EngineTestCase.assertLength(0, errors); | 430 expect(errors, hasLength(0)); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void test_computeExportedLibraries_none() { | 433 void test_computeExportedLibraries_none() { |
| 434 Source source = _addSource("/test.dart", "library test;"); | 434 Source source = _addSource("/test.dart", "library test;"); |
| 435 EngineTestCase.assertLength(0, _context.computeExportedLibraries(source)); | 435 expect(_context.computeExportedLibraries(source), hasLength(0)); |
| 436 } | 436 } |
| 437 | 437 |
| 438 void test_computeExportedLibraries_some() { | 438 void test_computeExportedLibraries_some() { |
| 439 // addSource("/lib1.dart", "library lib1;"); | 439 // addSource("/lib1.dart", "library lib1;"); |
| 440 // addSource("/lib2.dart", "library lib2;"); | 440 // addSource("/lib2.dart", "library lib2;"); |
| 441 Source source = _addSource( | 441 Source source = _addSource( |
| 442 "/test.dart", | 442 "/test.dart", |
| 443 "library test; export 'lib1.dart'; export 'lib2.dart';"); | 443 "library test; export 'lib1.dart'; export 'lib2.dart';"); |
| 444 EngineTestCase.assertLength(2, _context.computeExportedLibraries(source)); | 444 expect(_context.computeExportedLibraries(source), hasLength(2)); |
| 445 } | 445 } |
| 446 | 446 |
| 447 void test_computeHtmlElement_nonHtml() { | 447 void test_computeHtmlElement_nonHtml() { |
| 448 Source source = _addSource("/test.dart", "library test;"); | 448 Source source = _addSource("/test.dart", "library test;"); |
| 449 expect(_context.computeHtmlElement(source), isNull); | 449 expect(_context.computeHtmlElement(source), isNull); |
| 450 } | 450 } |
| 451 | 451 |
| 452 void test_computeHtmlElement_valid() { | 452 void test_computeHtmlElement_valid() { |
| 453 Source source = _addSource("/test.html", "<html></html>"); | 453 Source source = _addSource("/test.html", "<html></html>"); |
| 454 HtmlElement element = _context.computeHtmlElement(source); | 454 HtmlElement element = _context.computeHtmlElement(source); |
| 455 expect(element, isNotNull); | 455 expect(element, isNotNull); |
| 456 expect(_context.computeHtmlElement(source), same(element)); | 456 expect(_context.computeHtmlElement(source), same(element)); |
| 457 } | 457 } |
| 458 | 458 |
| 459 void test_computeImportedLibraries_none() { | 459 void test_computeImportedLibraries_none() { |
| 460 Source source = _addSource("/test.dart", "library test;"); | 460 Source source = _addSource("/test.dart", "library test;"); |
| 461 EngineTestCase.assertLength(0, _context.computeImportedLibraries(source)); | 461 expect(_context.computeImportedLibraries(source), hasLength(0)); |
| 462 } | 462 } |
| 463 | 463 |
| 464 void test_computeImportedLibraries_some() { | 464 void test_computeImportedLibraries_some() { |
| 465 // addSource("/lib1.dart", "library lib1;"); | 465 // addSource("/lib1.dart", "library lib1;"); |
| 466 // addSource("/lib2.dart", "library lib2;"); | 466 // addSource("/lib2.dart", "library lib2;"); |
| 467 Source source = _addSource( | 467 Source source = _addSource( |
| 468 "/test.dart", | 468 "/test.dart", |
| 469 "library test; import 'lib1.dart'; import 'lib2.dart';"); | 469 "library test; import 'lib1.dart'; import 'lib2.dart';"); |
| 470 EngineTestCase.assertLength(2, _context.computeImportedLibraries(source)); | 470 expect(_context.computeImportedLibraries(source), hasLength(2)); |
| 471 } | 471 } |
| 472 | 472 |
| 473 void test_computeKindOf_html() { | 473 void test_computeKindOf_html() { |
| 474 Source source = _addSource("/test.html", ""); | 474 Source source = _addSource("/test.html", ""); |
| 475 expect(_context.computeKindOf(source), same(SourceKind.HTML)); | 475 expect(_context.computeKindOf(source), same(SourceKind.HTML)); |
| 476 } | 476 } |
| 477 | 477 |
| 478 void test_computeKindOf_library() { | 478 void test_computeKindOf_library() { |
| 479 Source source = _addSource("/test.dart", "library lib;"); | 479 Source source = _addSource("/test.dart", "library lib;"); |
| 480 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); | 480 expect(_context.computeKindOf(source), same(SourceKind.LIBRARY)); |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 LibraryElement library = _context.computeLibraryElement(source); | 663 LibraryElement library = _context.computeLibraryElement(source); |
| 664 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); | 664 ClassElement myEnum = library.definingCompilationUnit.getEnum('MyEnum'); |
| 665 ElementLocation location = myEnum.location; | 665 ElementLocation location = myEnum.location; |
| 666 Element element = _context.getElement(location); | 666 Element element = _context.getElement(location); |
| 667 expect(element, same(myEnum)); | 667 expect(element, same(myEnum)); |
| 668 } | 668 } |
| 669 | 669 |
| 670 void test_getErrors_dart_none() { | 670 void test_getErrors_dart_none() { |
| 671 Source source = _addSource("/lib.dart", "library lib;"); | 671 Source source = _addSource("/lib.dart", "library lib;"); |
| 672 List<AnalysisError> errors = _context.getErrors(source).errors; | 672 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 673 EngineTestCase.assertLength(0, errors); | 673 expect(errors, hasLength(0)); |
| 674 _context.computeErrors(source); | 674 _context.computeErrors(source); |
| 675 errors = _context.getErrors(source).errors; | 675 errors = _context.getErrors(source).errors; |
| 676 EngineTestCase.assertLength(0, errors); | 676 expect(errors, hasLength(0)); |
| 677 } | 677 } |
| 678 | 678 |
| 679 void test_getErrors_dart_some() { | 679 void test_getErrors_dart_some() { |
| 680 Source source = _addSource("/lib.dart", "library 'lib';"); | 680 Source source = _addSource("/lib.dart", "library 'lib';"); |
| 681 List<AnalysisError> errors = _context.getErrors(source).errors; | 681 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 682 EngineTestCase.assertLength(0, errors); | 682 expect(errors, hasLength(0)); |
| 683 _context.computeErrors(source); | 683 _context.computeErrors(source); |
| 684 errors = _context.getErrors(source).errors; | 684 errors = _context.getErrors(source).errors; |
| 685 EngineTestCase.assertLength(1, errors); | 685 expect(errors, hasLength(1)); |
| 686 } | 686 } |
| 687 | 687 |
| 688 void test_getErrors_html_none() { | 688 void test_getErrors_html_none() { |
| 689 Source source = _addSource("/test.html", "<html></html>"); | 689 Source source = _addSource("/test.html", "<html></html>"); |
| 690 List<AnalysisError> errors = _context.getErrors(source).errors; | 690 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 691 EngineTestCase.assertLength(0, errors); | 691 expect(errors, hasLength(0)); |
| 692 _context.computeErrors(source); | 692 _context.computeErrors(source); |
| 693 errors = _context.getErrors(source).errors; | 693 errors = _context.getErrors(source).errors; |
| 694 EngineTestCase.assertLength(0, errors); | 694 expect(errors, hasLength(0)); |
| 695 } | 695 } |
| 696 | 696 |
| 697 void test_getErrors_html_some() { | 697 void test_getErrors_html_some() { |
| 698 Source source = _addSource( | 698 Source source = _addSource( |
| 699 "/test.html", | 699 "/test.html", |
| 700 r''' | 700 r''' |
| 701 <html><head> | 701 <html><head> |
| 702 <script type='application/dart' src='test.dart'/> | 702 <script type='application/dart' src='test.dart'/> |
| 703 </head></html>'''); | 703 </head></html>'''); |
| 704 List<AnalysisError> errors = _context.getErrors(source).errors; | 704 List<AnalysisError> errors = _context.getErrors(source).errors; |
| 705 EngineTestCase.assertLength(0, errors); | 705 expect(errors, hasLength(0)); |
| 706 _context.computeErrors(source); | 706 _context.computeErrors(source); |
| 707 errors = _context.getErrors(source).errors; | 707 errors = _context.getErrors(source).errors; |
| 708 EngineTestCase.assertLength(1, errors); | 708 expect(errors, hasLength(1)); |
| 709 } | 709 } |
| 710 | 710 |
| 711 void test_getHtmlElement_dart() { | 711 void test_getHtmlElement_dart() { |
| 712 Source source = _addSource("/test.dart", ""); | 712 Source source = _addSource("/test.dart", ""); |
| 713 expect(_context.getHtmlElement(source), isNull); | 713 expect(_context.getHtmlElement(source), isNull); |
| 714 expect(_context.computeHtmlElement(source), isNull); | 714 expect(_context.computeHtmlElement(source), isNull); |
| 715 expect(_context.getHtmlElement(source), isNull); | 715 expect(_context.getHtmlElement(source), isNull); |
| 716 } | 716 } |
| 717 | 717 |
| 718 void test_getHtmlElement_html() { | 718 void test_getHtmlElement_html() { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 731 "/test.html", | 731 "/test.html", |
| 732 r''' | 732 r''' |
| 733 <html><head> | 733 <html><head> |
| 734 <script type='application/dart' src='test.dart'/> | 734 <script type='application/dart' src='test.dart'/> |
| 735 <script type='application/dart' src='test.js'/> | 735 <script type='application/dart' src='test.js'/> |
| 736 </head></html>'''); | 736 </head></html>'''); |
| 737 Source librarySource = _addSource("/test.dart", "library lib;"); | 737 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 738 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); | 738 Source secondHtmlSource = _addSource("/test.html", "<html></html>"); |
| 739 _context.computeLibraryElement(librarySource); | 739 _context.computeLibraryElement(librarySource); |
| 740 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); | 740 List<Source> result = _context.getHtmlFilesReferencing(secondHtmlSource); |
| 741 EngineTestCase.assertLength(0, result); | 741 expect(result, hasLength(0)); |
| 742 _context.parseHtmlUnit(htmlSource); | 742 _context.parseHtmlUnit(htmlSource); |
| 743 result = _context.getHtmlFilesReferencing(secondHtmlSource); | 743 result = _context.getHtmlFilesReferencing(secondHtmlSource); |
| 744 EngineTestCase.assertLength(0, result); | 744 expect(result, hasLength(0)); |
| 745 } | 745 } |
| 746 | 746 |
| 747 void test_getHtmlFilesReferencing_library() { | 747 void test_getHtmlFilesReferencing_library() { |
| 748 Source htmlSource = _addSource( | 748 Source htmlSource = _addSource( |
| 749 "/test.html", | 749 "/test.html", |
| 750 r''' | 750 r''' |
| 751 <html><head> | 751 <html><head> |
| 752 <script type='application/dart' src='test.dart'/> | 752 <script type='application/dart' src='test.dart'/> |
| 753 <script type='application/dart' src='test.js'/> | 753 <script type='application/dart' src='test.js'/> |
| 754 </head></html>'''); | 754 </head></html>'''); |
| 755 Source librarySource = _addSource("/test.dart", "library lib;"); | 755 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 756 List<Source> result = _context.getHtmlFilesReferencing(librarySource); | 756 List<Source> result = _context.getHtmlFilesReferencing(librarySource); |
| 757 EngineTestCase.assertLength(0, result); | 757 expect(result, hasLength(0)); |
| 758 _context.parseHtmlUnit(htmlSource); | 758 _context.parseHtmlUnit(htmlSource); |
| 759 result = _context.getHtmlFilesReferencing(librarySource); | 759 result = _context.getHtmlFilesReferencing(librarySource); |
| 760 EngineTestCase.assertLength(1, result); | 760 expect(result, hasLength(1)); |
| 761 expect(result[0], htmlSource); | 761 expect(result[0], htmlSource); |
| 762 } | 762 } |
| 763 | 763 |
| 764 void test_getHtmlFilesReferencing_part() { | 764 void test_getHtmlFilesReferencing_part() { |
| 765 _context = AnalysisContextFactory.contextWithCore(); | 765 _context = AnalysisContextFactory.contextWithCore(); |
| 766 _sourceFactory = _context.sourceFactory; | 766 _sourceFactory = _context.sourceFactory; |
| 767 Source htmlSource = _addSource( | 767 Source htmlSource = _addSource( |
| 768 "/test.html", | 768 "/test.html", |
| 769 r''' | 769 r''' |
| 770 <html><head> | 770 <html><head> |
| 771 <script type='application/dart' src='test.dart'/> | 771 <script type='application/dart' src='test.dart'/> |
| 772 <script type='application/dart' src='test.js'/> | 772 <script type='application/dart' src='test.js'/> |
| 773 </head></html>'''); | 773 </head></html>'''); |
| 774 Source librarySource = | 774 Source librarySource = |
| 775 _addSource("/test.dart", "library lib; part 'part.dart';"); | 775 _addSource("/test.dart", "library lib; part 'part.dart';"); |
| 776 Source partSource = _addSource("/part.dart", "part of lib;"); | 776 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 777 _context.computeLibraryElement(librarySource); | 777 _context.computeLibraryElement(librarySource); |
| 778 List<Source> result = _context.getHtmlFilesReferencing(partSource); | 778 List<Source> result = _context.getHtmlFilesReferencing(partSource); |
| 779 EngineTestCase.assertLength(0, result); | 779 expect(result, hasLength(0)); |
| 780 _context.parseHtmlUnit(htmlSource); | 780 _context.parseHtmlUnit(htmlSource); |
| 781 result = _context.getHtmlFilesReferencing(partSource); | 781 result = _context.getHtmlFilesReferencing(partSource); |
| 782 EngineTestCase.assertLength(1, result); | 782 expect(result, hasLength(1)); |
| 783 expect(result[0], htmlSource); | 783 expect(result[0], htmlSource); |
| 784 } | 784 } |
| 785 | 785 |
| 786 void test_getHtmlSources() { | 786 void test_getHtmlSources() { |
| 787 List<Source> sources = _context.htmlSources; | 787 List<Source> sources = _context.htmlSources; |
| 788 EngineTestCase.assertLength(0, sources); | 788 expect(sources, hasLength(0)); |
| 789 Source source = _addSource("/test.html", ""); | 789 Source source = _addSource("/test.html", ""); |
| 790 _context.computeKindOf(source); | 790 _context.computeKindOf(source); |
| 791 sources = _context.htmlSources; | 791 sources = _context.htmlSources; |
| 792 EngineTestCase.assertLength(1, sources); | 792 expect(sources, hasLength(1)); |
| 793 expect(sources[0], source); | 793 expect(sources[0], source); |
| 794 } | 794 } |
| 795 | 795 |
| 796 void test_getKindOf_html() { | 796 void test_getKindOf_html() { |
| 797 Source source = _addSource("/test.html", ""); | 797 Source source = _addSource("/test.html", ""); |
| 798 expect(_context.getKindOf(source), same(SourceKind.HTML)); | 798 expect(_context.getKindOf(source), same(SourceKind.HTML)); |
| 799 } | 799 } |
| 800 | 800 |
| 801 void test_getKindOf_library() { | 801 void test_getKindOf_library() { |
| 802 Source source = _addSource("/test.dart", "library lib;"); | 802 Source source = _addSource("/test.dart", "library lib;"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 814 | 814 |
| 815 void test_getKindOf_unknown() { | 815 void test_getKindOf_unknown() { |
| 816 Source source = _addSource("/test.css", ""); | 816 Source source = _addSource("/test.css", ""); |
| 817 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); | 817 expect(_context.getKindOf(source), same(SourceKind.UNKNOWN)); |
| 818 } | 818 } |
| 819 | 819 |
| 820 void test_getLaunchableClientLibrarySources() { | 820 void test_getLaunchableClientLibrarySources() { |
| 821 _context = AnalysisContextFactory.contextWithCore(); | 821 _context = AnalysisContextFactory.contextWithCore(); |
| 822 _sourceFactory = _context.sourceFactory; | 822 _sourceFactory = _context.sourceFactory; |
| 823 List<Source> sources = _context.launchableClientLibrarySources; | 823 List<Source> sources = _context.launchableClientLibrarySources; |
| 824 EngineTestCase.assertLength(0, sources); | 824 expect(sources, hasLength(0)); |
| 825 Source source = _addSource( | 825 Source source = _addSource( |
| 826 "/test.dart", | 826 "/test.dart", |
| 827 r''' | 827 r''' |
| 828 import 'dart:html'; | 828 import 'dart:html'; |
| 829 main() {}'''); | 829 main() {}'''); |
| 830 _context.computeLibraryElement(source); | 830 _context.computeLibraryElement(source); |
| 831 sources = _context.launchableClientLibrarySources; | 831 sources = _context.launchableClientLibrarySources; |
| 832 EngineTestCase.assertLength(1, sources); | 832 expect(sources, hasLength(1)); |
| 833 } | 833 } |
| 834 | 834 |
| 835 void test_getLaunchableServerLibrarySources() { | 835 void test_getLaunchableServerLibrarySources() { |
| 836 _context = AnalysisContextFactory.contextWithCore(); | 836 _context = AnalysisContextFactory.contextWithCore(); |
| 837 _sourceFactory = _context.sourceFactory; | 837 _sourceFactory = _context.sourceFactory; |
| 838 List<Source> sources = _context.launchableServerLibrarySources; | 838 List<Source> sources = _context.launchableServerLibrarySources; |
| 839 EngineTestCase.assertLength(0, sources); | 839 expect(sources, hasLength(0)); |
| 840 Source source = _addSource("/test.dart", "main() {}"); | 840 Source source = _addSource("/test.dart", "main() {}"); |
| 841 _context.computeLibraryElement(source); | 841 _context.computeLibraryElement(source); |
| 842 sources = _context.launchableServerLibrarySources; | 842 sources = _context.launchableServerLibrarySources; |
| 843 EngineTestCase.assertLength(1, sources); | 843 expect(sources, hasLength(1)); |
| 844 } | 844 } |
| 845 | 845 |
| 846 void test_getLibrariesContaining() { | 846 void test_getLibrariesContaining() { |
| 847 _context = AnalysisContextFactory.contextWithCore(); | 847 _context = AnalysisContextFactory.contextWithCore(); |
| 848 _sourceFactory = _context.sourceFactory; | 848 _sourceFactory = _context.sourceFactory; |
| 849 Source librarySource = _addSource( | 849 Source librarySource = _addSource( |
| 850 "/lib.dart", | 850 "/lib.dart", |
| 851 r''' | 851 r''' |
| 852 library lib; | 852 library lib; |
| 853 part 'part.dart';'''); | 853 part 'part.dart';'''); |
| 854 Source partSource = _addSource("/part.dart", "part of lib;"); | 854 Source partSource = _addSource("/part.dart", "part of lib;"); |
| 855 _context.computeLibraryElement(librarySource); | 855 _context.computeLibraryElement(librarySource); |
| 856 List<Source> result = _context.getLibrariesContaining(librarySource); | 856 List<Source> result = _context.getLibrariesContaining(librarySource); |
| 857 EngineTestCase.assertLength(1, result); | 857 expect(result, hasLength(1)); |
| 858 expect(result[0], librarySource); | 858 expect(result[0], librarySource); |
| 859 result = _context.getLibrariesContaining(partSource); | 859 result = _context.getLibrariesContaining(partSource); |
| 860 EngineTestCase.assertLength(1, result); | 860 expect(result, hasLength(1)); |
| 861 expect(result[0], librarySource); | 861 expect(result[0], librarySource); |
| 862 } | 862 } |
| 863 | 863 |
| 864 void test_getLibrariesDependingOn() { | 864 void test_getLibrariesDependingOn() { |
| 865 _context = AnalysisContextFactory.contextWithCore(); | 865 _context = AnalysisContextFactory.contextWithCore(); |
| 866 _sourceFactory = _context.sourceFactory; | 866 _sourceFactory = _context.sourceFactory; |
| 867 Source libASource = _addSource("/libA.dart", "library libA;"); | 867 Source libASource = _addSource("/libA.dart", "library libA;"); |
| 868 _addSource("/libB.dart", "library libB;"); | 868 _addSource("/libB.dart", "library libB;"); |
| 869 Source lib1Source = _addSource( | 869 Source lib1Source = _addSource( |
| 870 "/lib1.dart", | 870 "/lib1.dart", |
| (...skipping 20 matching lines...) Expand all Loading... |
| 891 "/test.html", | 891 "/test.html", |
| 892 r''' | 892 r''' |
| 893 <html><head> | 893 <html><head> |
| 894 <script type='application/dart' src='test.dart'/> | 894 <script type='application/dart' src='test.dart'/> |
| 895 <script type='application/dart' src='test.js'/> | 895 <script type='application/dart' src='test.js'/> |
| 896 </head></html>'''); | 896 </head></html>'''); |
| 897 Source librarySource = _addSource("/test.dart", "library lib;"); | 897 Source librarySource = _addSource("/test.dart", "library lib;"); |
| 898 _context.computeLibraryElement(librarySource); | 898 _context.computeLibraryElement(librarySource); |
| 899 _context.parseHtmlUnit(htmlSource); | 899 _context.parseHtmlUnit(htmlSource); |
| 900 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 900 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 901 EngineTestCase.assertLength(1, result); | 901 expect(result, hasLength(1)); |
| 902 expect(result[0], librarySource); | 902 expect(result[0], librarySource); |
| 903 } | 903 } |
| 904 | 904 |
| 905 void test_getLibrariesReferencedFromHtml_no() { | 905 void test_getLibrariesReferencedFromHtml_no() { |
| 906 _context = AnalysisContextFactory.contextWithCore(); | 906 _context = AnalysisContextFactory.contextWithCore(); |
| 907 _sourceFactory = _context.sourceFactory; | 907 _sourceFactory = _context.sourceFactory; |
| 908 Source htmlSource = _addSource( | 908 Source htmlSource = _addSource( |
| 909 "/test.html", | 909 "/test.html", |
| 910 r''' | 910 r''' |
| 911 <html><head> | 911 <html><head> |
| 912 <script type='application/dart' src='test.js'/> | 912 <script type='application/dart' src='test.js'/> |
| 913 </head></html>'''); | 913 </head></html>'''); |
| 914 _addSource("/test.dart", "library lib;"); | 914 _addSource("/test.dart", "library lib;"); |
| 915 _context.parseHtmlUnit(htmlSource); | 915 _context.parseHtmlUnit(htmlSource); |
| 916 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); | 916 List<Source> result = _context.getLibrariesReferencedFromHtml(htmlSource); |
| 917 EngineTestCase.assertLength(0, result); | 917 expect(result, hasLength(0)); |
| 918 } | 918 } |
| 919 | 919 |
| 920 void test_getLibraryElement() { | 920 void test_getLibraryElement() { |
| 921 _context = AnalysisContextFactory.contextWithCore(); | 921 _context = AnalysisContextFactory.contextWithCore(); |
| 922 _sourceFactory = _context.sourceFactory; | 922 _sourceFactory = _context.sourceFactory; |
| 923 Source source = _addSource("/test.dart", "library lib;"); | 923 Source source = _addSource("/test.dart", "library lib;"); |
| 924 LibraryElement element = _context.getLibraryElement(source); | 924 LibraryElement element = _context.getLibraryElement(source); |
| 925 expect(element, isNull); | 925 expect(element, isNull); |
| 926 _context.computeLibraryElement(source); | 926 _context.computeLibraryElement(source); |
| 927 element = _context.getLibraryElement(source); | 927 element = _context.getLibraryElement(source); |
| 928 expect(element, isNotNull); | 928 expect(element, isNotNull); |
| 929 } | 929 } |
| 930 | 930 |
| 931 void test_getLibrarySources() { | 931 void test_getLibrarySources() { |
| 932 List<Source> sources = _context.librarySources; | 932 List<Source> sources = _context.librarySources; |
| 933 int originalLength = sources.length; | 933 int originalLength = sources.length; |
| 934 Source source = _addSource("/test.dart", "library lib;"); | 934 Source source = _addSource("/test.dart", "library lib;"); |
| 935 _context.computeKindOf(source); | 935 _context.computeKindOf(source); |
| 936 sources = _context.librarySources; | 936 sources = _context.librarySources; |
| 937 EngineTestCase.assertLength(originalLength + 1, sources); | 937 expect(sources, hasLength(originalLength + 1)); |
| 938 for (Source returnedSource in sources) { | 938 for (Source returnedSource in sources) { |
| 939 if (returnedSource == source) { | 939 if (returnedSource == source) { |
| 940 return; | 940 return; |
| 941 } | 941 } |
| 942 } | 942 } |
| 943 fail("The added source was not in the list of library sources"); | 943 fail("The added source was not in the list of library sources"); |
| 944 } | 944 } |
| 945 | 945 |
| 946 void test_getLineInfo() { | 946 void test_getLineInfo() { |
| 947 Source source = _addSource( | 947 Source source = _addSource( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 expect(namespace, isNotNull); | 980 expect(namespace, isNotNull); |
| 981 EngineTestCase.assertInstanceOf( | 981 EngineTestCase.assertInstanceOf( |
| 982 (obj) => obj is ClassElement, | 982 (obj) => obj is ClassElement, |
| 983 ClassElement, | 983 ClassElement, |
| 984 namespace.get("A")); | 984 namespace.get("A")); |
| 985 } | 985 } |
| 986 | 986 |
| 987 void test_getRefactoringUnsafeSources() { | 987 void test_getRefactoringUnsafeSources() { |
| 988 // not sources initially | 988 // not sources initially |
| 989 List<Source> sources = _context.refactoringUnsafeSources; | 989 List<Source> sources = _context.refactoringUnsafeSources; |
| 990 EngineTestCase.assertLength(0, sources); | 990 expect(sources, hasLength(0)); |
| 991 // add new source, unresolved | 991 // add new source, unresolved |
| 992 Source source = _addSource("/test.dart", "library lib;"); | 992 Source source = _addSource("/test.dart", "library lib;"); |
| 993 sources = _context.refactoringUnsafeSources; | 993 sources = _context.refactoringUnsafeSources; |
| 994 EngineTestCase.assertLength(1, sources); | 994 expect(sources, hasLength(1)); |
| 995 expect(sources[0], source); | 995 expect(sources[0], source); |
| 996 // resolve source | 996 // resolve source |
| 997 _context.computeLibraryElement(source); | 997 _context.computeLibraryElement(source); |
| 998 sources = _context.refactoringUnsafeSources; | 998 sources = _context.refactoringUnsafeSources; |
| 999 EngineTestCase.assertLength(0, sources); | 999 expect(sources, hasLength(0)); |
| 1000 } | 1000 } |
| 1001 | 1001 |
| 1002 void test_getResolvedCompilationUnit_library() { | 1002 void test_getResolvedCompilationUnit_library() { |
| 1003 _context = AnalysisContextFactory.contextWithCore(); | 1003 _context = AnalysisContextFactory.contextWithCore(); |
| 1004 _sourceFactory = _context.sourceFactory; | 1004 _sourceFactory = _context.sourceFactory; |
| 1005 Source source = _addSource("/lib.dart", "library libb;"); | 1005 Source source = _addSource("/lib.dart", "library libb;"); |
| 1006 LibraryElement library = _context.computeLibraryElement(source); | 1006 LibraryElement library = _context.computeLibraryElement(source); |
| 1007 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); | 1007 expect(_context.getResolvedCompilationUnit(source, library), isNotNull); |
| 1008 _context.setContents(source, "library lib;"); | 1008 _context.setContents(source, "library lib;"); |
| 1009 expect(_context.getResolvedCompilationUnit(source, library), isNull); | 1009 expect(_context.getResolvedCompilationUnit(source, library), isNull); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 | 1120 |
| 1121 void test_parseCompilationUnit_html() { | 1121 void test_parseCompilationUnit_html() { |
| 1122 Source source = _addSource("/test.html", "<html></html>"); | 1122 Source source = _addSource("/test.html", "<html></html>"); |
| 1123 expect(_context.parseCompilationUnit(source), isNull); | 1123 expect(_context.parseCompilationUnit(source), isNull); |
| 1124 } | 1124 } |
| 1125 | 1125 |
| 1126 void test_parseCompilationUnit_noErrors() { | 1126 void test_parseCompilationUnit_noErrors() { |
| 1127 Source source = _addSource("/lib.dart", "library lib;"); | 1127 Source source = _addSource("/lib.dart", "library lib;"); |
| 1128 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); | 1128 CompilationUnit compilationUnit = _context.parseCompilationUnit(source); |
| 1129 expect(compilationUnit, isNotNull); | 1129 expect(compilationUnit, isNotNull); |
| 1130 EngineTestCase.assertLength(0, _context.getErrors(source).errors); | 1130 expect(_context.getErrors(source).errors, hasLength(0)); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 void test_parseCompilationUnit_nonExistentSource() { | 1133 void test_parseCompilationUnit_nonExistentSource() { |
| 1134 Source source = | 1134 Source source = |
| 1135 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); | 1135 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); |
| 1136 try { | 1136 try { |
| 1137 _context.parseCompilationUnit(source); | 1137 _context.parseCompilationUnit(source); |
| 1138 fail("Expected AnalysisException because file does not exist"); | 1138 fail("Expected AnalysisException because file does not exist"); |
| 1139 } on AnalysisException catch (exception) { | 1139 } on AnalysisException catch (exception) { |
| 1140 // Expected result | 1140 // Expected result |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1278 _context.setContents( | 1278 _context.setContents( |
| 1279 partSource, | 1279 partSource, |
| 1280 r''' | 1280 r''' |
| 1281 part of lib; | 1281 part of lib; |
| 1282 void g() { f(null); }'''); | 1282 void g() { f(null); }'''); |
| 1283 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); | 1283 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNull, r
eason: "library changed 2"); |
| 1284 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); | 1284 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNull,
reason: "part changed 2"); |
| 1285 _analyzeAll_assertFinished(); | 1285 _analyzeAll_assertFinished(); |
| 1286 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); | 1286 expect(_context.getResolvedCompilationUnit2(libSource, libSource), isNotNull
, reason: "library resolved 2"); |
| 1287 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 2"); | 1287 expect(_context.getResolvedCompilationUnit2(partSource, libSource), isNotNul
l, reason: "part resolved 2"); |
| 1288 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1288 expect(_context.getErrors(libSource).errors, hasLength(0)); |
| 1289 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1289 expect(_context.getErrors(partSource).errors, hasLength(0)); |
| 1290 } | 1290 } |
| 1291 | 1291 |
| 1292 /** | 1292 /** |
| 1293 * https://code.google.com/p/dart/issues/detail?id=12424 | 1293 * https://code.google.com/p/dart/issues/detail?id=12424 |
| 1294 */ | 1294 */ |
| 1295 void test_performAnalysisTask_changePartContents_makeItNotPart() { | 1295 void test_performAnalysisTask_changePartContents_makeItNotPart() { |
| 1296 Source libSource = _addSource( | 1296 Source libSource = _addSource( |
| 1297 "/lib.dart", | 1297 "/lib.dart", |
| 1298 r''' | 1298 r''' |
| 1299 library lib; | 1299 library lib; |
| 1300 part 'part.dart'; | 1300 part 'part.dart'; |
| 1301 void f(x) {}'''); | 1301 void f(x) {}'''); |
| 1302 Source partSource = _addSource( | 1302 Source partSource = _addSource( |
| 1303 "/part.dart", | 1303 "/part.dart", |
| 1304 r''' | 1304 r''' |
| 1305 part of lib; | 1305 part of lib; |
| 1306 void g() { f(null); }'''); | 1306 void g() { f(null); }'''); |
| 1307 _analyzeAll_assertFinished(); | 1307 _analyzeAll_assertFinished(); |
| 1308 EngineTestCase.assertLength(0, _context.getErrors(libSource).errors); | 1308 expect(_context.getErrors(libSource).errors, hasLength(0)); |
| 1309 EngineTestCase.assertLength(0, _context.getErrors(partSource).errors); | 1309 expect(_context.getErrors(partSource).errors, hasLength(0)); |
| 1310 // Remove 'part' directive, which should make "f(null)" an error. | 1310 // Remove 'part' directive, which should make "f(null)" an error. |
| 1311 _context.setContents( | 1311 _context.setContents( |
| 1312 partSource, | 1312 partSource, |
| 1313 r''' | 1313 r''' |
| 1314 //part of lib; | 1314 //part of lib; |
| 1315 void g() { f(null); }'''); | 1315 void g() { f(null); }'''); |
| 1316 _analyzeAll_assertFinished(); | 1316 _analyzeAll_assertFinished(); |
| 1317 expect(_context.getErrors(libSource).errors.length != 0, isTrue); | 1317 expect(_context.getErrors(libSource).errors.length != 0, isTrue); |
| 1318 } | 1318 } |
| 1319 | 1319 |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); | 2033 expect(entry.getState(DartEntry.TOKEN_STREAM), same(CacheState.INVALID)); |
| 2034 expect(entry.getStateInLibrary(DartEntry.HINTS, librarySource), same(CacheSt
ate.INVALID)); | 2034 expect(entry.getStateInLibrary(DartEntry.HINTS, librarySource), same(CacheSt
ate.INVALID)); |
| 2035 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource),
same(CacheState.INVALID)); | 2035 expect(entry.getStateInLibrary(DartEntry.RESOLUTION_ERRORS, librarySource),
same(CacheState.INVALID)); |
| 2036 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource), same
(CacheState.INVALID)); | 2036 expect(entry.getStateInLibrary(DartEntry.RESOLVED_UNIT, librarySource), same
(CacheState.INVALID)); |
| 2037 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource)
, same(CacheState.INVALID)); | 2037 expect(entry.getStateInLibrary(DartEntry.VERIFICATION_ERRORS, librarySource)
, same(CacheState.INVALID)); |
| 2038 } | 2038 } |
| 2039 | 2039 |
| 2040 void test_getAllErrors() { | 2040 void test_getAllErrors() { |
| 2041 Source source = new TestSource(); | 2041 Source source = new TestSource(); |
| 2042 DartEntry entry = new DartEntry(); | 2042 DartEntry entry = new DartEntry(); |
| 2043 EngineTestCase.assertLength(0, entry.allErrors); | 2043 expect(entry.allErrors, hasLength(0)); |
| 2044 entry.setValue( | 2044 entry.setValue( |
| 2045 DartEntry.SCAN_ERRORS, | 2045 DartEntry.SCAN_ERRORS, |
| 2046 <AnalysisError>[ | 2046 <AnalysisError>[ |
| 2047 new AnalysisError.con1( | 2047 new AnalysisError.con1( |
| 2048 source, | 2048 source, |
| 2049 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, | 2049 ScannerErrorCode.UNTERMINATED_STRING_LITERAL, |
| 2050 [])]); | 2050 [])]); |
| 2051 entry.setValue( | 2051 entry.setValue( |
| 2052 DartEntry.PARSE_ERRORS, | 2052 DartEntry.PARSE_ERRORS, |
| 2053 <AnalysisError>[ | 2053 <AnalysisError>[ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2065 source, | 2065 source, |
| 2066 <AnalysisError>[ | 2066 <AnalysisError>[ |
| 2067 new AnalysisError.con1( | 2067 new AnalysisError.con1( |
| 2068 source, | 2068 source, |
| 2069 StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, | 2069 StaticWarningCode.CASE_BLOCK_NOT_TERMINATED, |
| 2070 [])]); | 2070 [])]); |
| 2071 entry.setValueInLibrary( | 2071 entry.setValueInLibrary( |
| 2072 DartEntry.HINTS, | 2072 DartEntry.HINTS, |
| 2073 source, | 2073 source, |
| 2074 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; | 2074 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; |
| 2075 EngineTestCase.assertLength(5, entry.allErrors); | 2075 expect(entry.allErrors, hasLength(5)); |
| 2076 } | 2076 } |
| 2077 | 2077 |
| 2078 void test_getResolvableCompilationUnit_none() { | 2078 void test_getResolvableCompilationUnit_none() { |
| 2079 DartEntry entry = new DartEntry(); | 2079 DartEntry entry = new DartEntry(); |
| 2080 expect(entry.resolvableCompilationUnit, isNull); | 2080 expect(entry.resolvableCompilationUnit, isNull); |
| 2081 } | 2081 } |
| 2082 | 2082 |
| 2083 void test_getResolvableCompilationUnit_parsed_accessed() { | 2083 void test_getResolvableCompilationUnit_parsed_accessed() { |
| 2084 Source librarySource = new TestSource("/lib.dart"); | 2084 Source librarySource = new TestSource("/lib.dart"); |
| 2085 String importUri = "/f1.dart"; | 2085 String importUri = "/f1.dart"; |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 fail("Expected IllegalArgumentException for VERIFICATION_ERRORS"); | 2194 fail("Expected IllegalArgumentException for VERIFICATION_ERRORS"); |
| 2195 } on ArgumentError catch (exception) { | 2195 } on ArgumentError catch (exception) { |
| 2196 // Expected | 2196 // Expected |
| 2197 } | 2197 } |
| 2198 } | 2198 } |
| 2199 | 2199 |
| 2200 void test_getValue_containingLibraries() { | 2200 void test_getValue_containingLibraries() { |
| 2201 Source testSource = new TestSource(); | 2201 Source testSource = new TestSource(); |
| 2202 DartEntry entry = new DartEntry(); | 2202 DartEntry entry = new DartEntry(); |
| 2203 List<Source> value = entry.containingLibraries; | 2203 List<Source> value = entry.containingLibraries; |
| 2204 EngineTestCase.assertLength(0, value); | 2204 expect(value, hasLength(0)); |
| 2205 entry.addContainingLibrary(testSource); | 2205 entry.addContainingLibrary(testSource); |
| 2206 value = entry.containingLibraries; | 2206 value = entry.containingLibraries; |
| 2207 EngineTestCase.assertLength(1, value); | 2207 expect(value, hasLength(1)); |
| 2208 expect(value[0], testSource); | 2208 expect(value[0], testSource); |
| 2209 entry.removeContainingLibrary(testSource); | 2209 entry.removeContainingLibrary(testSource); |
| 2210 value = entry.containingLibraries; | 2210 value = entry.containingLibraries; |
| 2211 EngineTestCase.assertLength(0, value); | 2211 expect(value, hasLength(0)); |
| 2212 } | 2212 } |
| 2213 | 2213 |
| 2214 void test_getValueInLibrary_invalid_element() { | 2214 void test_getValueInLibrary_invalid_element() { |
| 2215 DartEntry entry = new DartEntry(); | 2215 DartEntry entry = new DartEntry(); |
| 2216 try { | 2216 try { |
| 2217 entry.getValueInLibrary(DartEntry.ELEMENT, new TestSource()); | 2217 entry.getValueInLibrary(DartEntry.ELEMENT, new TestSource()); |
| 2218 fail("Expected IllegalArgumentException for ELEMENT"); | 2218 fail("Expected IllegalArgumentException for ELEMENT"); |
| 2219 } on ArgumentError catch (exception) { | 2219 } on ArgumentError catch (exception) { |
| 2220 // Expected | 2220 // Expected |
| 2221 } | 2221 } |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3033 GenerateDartErrorsTaskTestTV_perform(this.libraryElement, this.source); | 3033 GenerateDartErrorsTaskTestTV_perform(this.libraryElement, this.source); |
| 3034 @override | 3034 @override |
| 3035 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 3035 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 3036 CaughtException exception = task.exception; | 3036 CaughtException exception = task.exception; |
| 3037 if (exception != null) { | 3037 if (exception != null) { |
| 3038 throw exception; | 3038 throw exception; |
| 3039 } | 3039 } |
| 3040 expect(task.libraryElement, same(libraryElement)); | 3040 expect(task.libraryElement, same(libraryElement)); |
| 3041 expect(task.source, same(source)); | 3041 expect(task.source, same(source)); |
| 3042 List<AnalysisError> errors = task.errors; | 3042 List<AnalysisError> errors = task.errors; |
| 3043 EngineTestCase.assertLength(1, errors); | 3043 expect(errors, hasLength(1)); |
| 3044 return true; | 3044 return true; |
| 3045 } | 3045 } |
| 3046 } | 3046 } |
| 3047 | 3047 |
| 3048 | 3048 |
| 3049 class GenerateDartErrorsTaskTestTV_perform_validateDirectives extends | 3049 class GenerateDartErrorsTaskTestTV_perform_validateDirectives extends |
| 3050 TestTaskVisitor<bool> { | 3050 TestTaskVisitor<bool> { |
| 3051 LibraryElement libraryElement; | 3051 LibraryElement libraryElement; |
| 3052 Source source; | 3052 Source source; |
| 3053 GenerateDartErrorsTaskTestTV_perform_validateDirectives(this.libraryElement, | 3053 GenerateDartErrorsTaskTestTV_perform_validateDirectives(this.libraryElement, |
| 3054 this.source); | 3054 this.source); |
| 3055 @override | 3055 @override |
| 3056 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { | 3056 bool visitGenerateDartErrorsTask(GenerateDartErrorsTask task) { |
| 3057 CaughtException exception = task.exception; | 3057 CaughtException exception = task.exception; |
| 3058 if (exception != null) { | 3058 if (exception != null) { |
| 3059 throw exception; | 3059 throw exception; |
| 3060 } | 3060 } |
| 3061 expect(task.libraryElement, same(libraryElement)); | 3061 expect(task.libraryElement, same(libraryElement)); |
| 3062 expect(task.source, same(source)); | 3062 expect(task.source, same(source)); |
| 3063 List<AnalysisError> errors = task.errors; | 3063 List<AnalysisError> errors = task.errors; |
| 3064 EngineTestCase.assertLength(1, errors); | 3064 expect(errors, hasLength(1)); |
| 3065 expect(errors[0].errorCode, same(CompileTimeErrorCode.URI_DOES_NOT_EXIST)); | 3065 expect(errors[0].errorCode, same(CompileTimeErrorCode.URI_DOES_NOT_EXIST)); |
| 3066 return true; | 3066 return true; |
| 3067 } | 3067 } |
| 3068 } | 3068 } |
| 3069 | 3069 |
| 3070 class GenerateDartHintsTaskTest extends EngineTestCase { | 3070 class GenerateDartHintsTaskTest extends EngineTestCase { |
| 3071 void test_accept() { | 3071 void test_accept() { |
| 3072 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); | 3072 GenerateDartHintsTask task = new GenerateDartHintsTask(null, null, null); |
| 3073 expect(task.accept(new GenerateDartHintsTaskTestTV_accept()), isTrue); | 3073 expect(task.accept(new GenerateDartHintsTaskTestTV_accept()), isTrue); |
| 3074 } | 3074 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 Source partSource; | 3140 Source partSource; |
| 3141 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); | 3141 GenerateDartHintsTaskTestTV_perform(this.librarySource, this.partSource); |
| 3142 @override | 3142 @override |
| 3143 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { | 3143 bool visitGenerateDartHintsTask(GenerateDartHintsTask task) { |
| 3144 CaughtException exception = task.exception; | 3144 CaughtException exception = task.exception; |
| 3145 if (exception != null) { | 3145 if (exception != null) { |
| 3146 throw exception; | 3146 throw exception; |
| 3147 } | 3147 } |
| 3148 expect(task.libraryElement, isNotNull); | 3148 expect(task.libraryElement, isNotNull); |
| 3149 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; | 3149 HashMap<Source, List<AnalysisError>> hintMap = task.hintMap; |
| 3150 EngineTestCase.assertSizeOfMap(2, hintMap); | 3150 expect(hintMap, hasLength(2)); |
| 3151 EngineTestCase.assertLength(1, hintMap[librarySource]); | 3151 expect(hintMap[librarySource], hasLength(1)); |
| 3152 EngineTestCase.assertLength(0, hintMap[partSource]); | 3152 expect(hintMap[partSource], hasLength(0)); |
| 3153 return true; | 3153 return true; |
| 3154 } | 3154 } |
| 3155 } | 3155 } |
| 3156 | 3156 |
| 3157 | 3157 |
| 3158 class GetContentTaskTest extends EngineTestCase { | 3158 class GetContentTaskTest extends EngineTestCase { |
| 3159 void test_accept() { | 3159 void test_accept() { |
| 3160 Source source = new TestSource('/test.dart', ''); | 3160 Source source = new TestSource('/test.dart', ''); |
| 3161 GetContentTask task = new GetContentTask(null, source); | 3161 GetContentTask task = new GetContentTask(null, source); |
| 3162 expect(task.accept(new GetContentTaskTestTV_accept()), isTrue); | 3162 expect(task.accept(new GetContentTaskTestTV_accept()), isTrue); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3240 } | 3240 } |
| 3241 | 3241 |
| 3242 void test_creation() { | 3242 void test_creation() { |
| 3243 HtmlEntry entry = new HtmlEntry(); | 3243 HtmlEntry entry = new HtmlEntry(); |
| 3244 expect(entry, isNotNull); | 3244 expect(entry, isNotNull); |
| 3245 } | 3245 } |
| 3246 | 3246 |
| 3247 void test_getAllErrors() { | 3247 void test_getAllErrors() { |
| 3248 Source source = new TestSource(); | 3248 Source source = new TestSource(); |
| 3249 HtmlEntry entry = new HtmlEntry(); | 3249 HtmlEntry entry = new HtmlEntry(); |
| 3250 EngineTestCase.assertLength(0, entry.allErrors); | 3250 expect(entry.allErrors, hasLength(0)); |
| 3251 entry.setValue( | 3251 entry.setValue( |
| 3252 HtmlEntry.PARSE_ERRORS, | 3252 HtmlEntry.PARSE_ERRORS, |
| 3253 <AnalysisError>[ | 3253 <AnalysisError>[ |
| 3254 new AnalysisError.con1(source, ParserErrorCode.EXPECTED_TOKEN, [";"]
)]); | 3254 new AnalysisError.con1(source, ParserErrorCode.EXPECTED_TOKEN, [";"]
)]); |
| 3255 entry.setValue( | 3255 entry.setValue( |
| 3256 HtmlEntry.RESOLUTION_ERRORS, | 3256 HtmlEntry.RESOLUTION_ERRORS, |
| 3257 <AnalysisError>[ | 3257 <AnalysisError>[ |
| 3258 new AnalysisError.con1(source, HtmlWarningCode.INVALID_URI, ["-"])])
; | 3258 new AnalysisError.con1(source, HtmlWarningCode.INVALID_URI, ["-"])])
; |
| 3259 entry.setValue( | 3259 entry.setValue( |
| 3260 HtmlEntry.ANGULAR_ERRORS, | 3260 HtmlEntry.ANGULAR_ERRORS, |
| 3261 <AnalysisError>[ | 3261 <AnalysisError>[ |
| 3262 new AnalysisError.con1(source, AngularCode.INVALID_REPEAT_SYNTAX, ["
-"])]); | 3262 new AnalysisError.con1(source, AngularCode.INVALID_REPEAT_SYNTAX, ["
-"])]); |
| 3263 entry.setValue( | 3263 entry.setValue( |
| 3264 HtmlEntry.POLYMER_BUILD_ERRORS, | 3264 HtmlEntry.POLYMER_BUILD_ERRORS, |
| 3265 <AnalysisError>[ | 3265 <AnalysisError>[ |
| 3266 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); | 3266 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); |
| 3267 entry.setValue( | 3267 entry.setValue( |
| 3268 HtmlEntry.POLYMER_RESOLUTION_ERRORS, | 3268 HtmlEntry.POLYMER_RESOLUTION_ERRORS, |
| 3269 <AnalysisError>[ | 3269 <AnalysisError>[ |
| 3270 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); | 3270 new AnalysisError.con1(source, PolymerCode.INVALID_ATTRIBUTE_NAME, [
"-"])]); |
| 3271 entry.setValue( | 3271 entry.setValue( |
| 3272 HtmlEntry.HINTS, | 3272 HtmlEntry.HINTS, |
| 3273 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; | 3273 <AnalysisError>[new AnalysisError.con1(source, HintCode.DEAD_CODE, [])])
; |
| 3274 EngineTestCase.assertLength(6, entry.allErrors); | 3274 expect(entry.allErrors, hasLength(6)); |
| 3275 } | 3275 } |
| 3276 | 3276 |
| 3277 void test_invalidateAllResolutionInformation() { | 3277 void test_invalidateAllResolutionInformation() { |
| 3278 HtmlEntry entry = _entryWithValidState(); | 3278 HtmlEntry entry = _entryWithValidState(); |
| 3279 entry.invalidateAllResolutionInformation(false); | 3279 entry.invalidateAllResolutionInformation(false); |
| 3280 expect(entry.getState(HtmlEntry.ANGULAR_APPLICATION), same(CacheState.VALID)
); | 3280 expect(entry.getState(HtmlEntry.ANGULAR_APPLICATION), same(CacheState.VALID)
); |
| 3281 expect(entry.getState(HtmlEntry.ANGULAR_COMPONENT), same(CacheState.VALID)); | 3281 expect(entry.getState(HtmlEntry.ANGULAR_COMPONENT), same(CacheState.VALID)); |
| 3282 expect(entry.getState(HtmlEntry.ANGULAR_ENTRY), same(CacheState.INVALID)); | 3282 expect(entry.getState(HtmlEntry.ANGULAR_ENTRY), same(CacheState.INVALID)); |
| 3283 expect(entry.getState(HtmlEntry.ANGULAR_ERRORS), same(CacheState.INVALID)); | 3283 expect(entry.getState(HtmlEntry.ANGULAR_ERRORS), same(CacheState.INVALID)); |
| 3284 expect(entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS), same(CacheState.INVAL
ID)); | 3284 expect(entry.getState(HtmlEntry.POLYMER_BUILD_ERRORS), same(CacheState.INVAL
ID)); |
| (...skipping 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4515 expect(task.accept(new ParseDartTaskTestTV_accept()), isTrue); | 4515 expect(task.accept(new ParseDartTaskTestTV_accept()), isTrue); |
| 4516 } | 4516 } |
| 4517 | 4517 |
| 4518 void test_getCompilationUnit() { | 4518 void test_getCompilationUnit() { |
| 4519 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4519 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 4520 expect(task.compilationUnit, isNull); | 4520 expect(task.compilationUnit, isNull); |
| 4521 } | 4521 } |
| 4522 | 4522 |
| 4523 void test_getErrors() { | 4523 void test_getErrors() { |
| 4524 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4524 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 4525 EngineTestCase.assertLength(0, task.errors); | 4525 expect(task.errors, hasLength(0)); |
| 4526 } | 4526 } |
| 4527 | 4527 |
| 4528 void test_getException() { | 4528 void test_getException() { |
| 4529 ParseDartTask task = new ParseDartTask(null, null, null, null); | 4529 ParseDartTask task = new ParseDartTask(null, null, null, null); |
| 4530 expect(task.exception, isNull); | 4530 expect(task.exception, isNull); |
| 4531 } | 4531 } |
| 4532 | 4532 |
| 4533 void test_getSource() { | 4533 void test_getSource() { |
| 4534 Source source = new TestSource('/test.dart'); | 4534 Source source = new TestSource('/test.dart'); |
| 4535 ParseDartTask task = new ParseDartTask(null, source, null, null); | 4535 ParseDartTask task = new ParseDartTask(null, source, null, null); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4648 InternalAnalysisContext context; | 4648 InternalAnalysisContext context; |
| 4649 Source source; | 4649 Source source; |
| 4650 ParseDartTaskTestTV_perform_library(this.context, this.source); | 4650 ParseDartTaskTestTV_perform_library(this.context, this.source); |
| 4651 @override | 4651 @override |
| 4652 Object visitParseDartTask(ParseDartTask task) { | 4652 Object visitParseDartTask(ParseDartTask task) { |
| 4653 CaughtException exception = task.exception; | 4653 CaughtException exception = task.exception; |
| 4654 if (exception != null) { | 4654 if (exception != null) { |
| 4655 throw exception; | 4655 throw exception; |
| 4656 } | 4656 } |
| 4657 expect(task.compilationUnit, isNotNull); | 4657 expect(task.compilationUnit, isNotNull); |
| 4658 EngineTestCase.assertLength(1, task.errors); | 4658 expect(task.errors, hasLength(1)); |
| 4659 expect(task.source, same(source)); | 4659 expect(task.source, same(source)); |
| 4660 expect(task.hasNonPartOfDirective, isTrue); | 4660 expect(task.hasNonPartOfDirective, isTrue); |
| 4661 expect(task.hasPartOfDirective, isFalse); | 4661 expect(task.hasPartOfDirective, isFalse); |
| 4662 return null; | 4662 return null; |
| 4663 } | 4663 } |
| 4664 } | 4664 } |
| 4665 | 4665 |
| 4666 | 4666 |
| 4667 class ParseDartTaskTestTV_perform_part extends TestTaskVisitor<Object> { | 4667 class ParseDartTaskTestTV_perform_part extends TestTaskVisitor<Object> { |
| 4668 InternalAnalysisContext context; | 4668 InternalAnalysisContext context; |
| 4669 Source source; | 4669 Source source; |
| 4670 ParseDartTaskTestTV_perform_part(this.context, this.source); | 4670 ParseDartTaskTestTV_perform_part(this.context, this.source); |
| 4671 @override | 4671 @override |
| 4672 Object visitParseDartTask(ParseDartTask task) { | 4672 Object visitParseDartTask(ParseDartTask task) { |
| 4673 CaughtException exception = task.exception; | 4673 CaughtException exception = task.exception; |
| 4674 if (exception != null) { | 4674 if (exception != null) { |
| 4675 throw exception; | 4675 throw exception; |
| 4676 } | 4676 } |
| 4677 expect(task.compilationUnit, isNotNull); | 4677 expect(task.compilationUnit, isNotNull); |
| 4678 EngineTestCase.assertLength(0, task.errors); | 4678 expect(task.errors, hasLength(0)); |
| 4679 expect(task.source, same(source)); | 4679 expect(task.source, same(source)); |
| 4680 expect(task.hasNonPartOfDirective, isFalse); | 4680 expect(task.hasNonPartOfDirective, isFalse); |
| 4681 expect(task.hasPartOfDirective, isTrue); | 4681 expect(task.hasPartOfDirective, isTrue); |
| 4682 return null; | 4682 return null; |
| 4683 } | 4683 } |
| 4684 } | 4684 } |
| 4685 | 4685 |
| 4686 | 4686 |
| 4687 class ParseDartTaskTestTV_perform_validateDirectives extends | 4687 class ParseDartTaskTestTV_perform_validateDirectives extends |
| 4688 TestTaskVisitor<Object> { | 4688 TestTaskVisitor<Object> { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4752 expect(task.htmlUnit, isNull); | 4752 expect(task.htmlUnit, isNull); |
| 4753 } | 4753 } |
| 4754 | 4754 |
| 4755 void test_getLineInfo() { | 4755 void test_getLineInfo() { |
| 4756 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4756 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 4757 expect(task.lineInfo, isNull); | 4757 expect(task.lineInfo, isNull); |
| 4758 } | 4758 } |
| 4759 | 4759 |
| 4760 void test_getReferencedLibraries() { | 4760 void test_getReferencedLibraries() { |
| 4761 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); | 4761 ParseHtmlTask task = new ParseHtmlTask(null, null, ""); |
| 4762 EngineTestCase.assertLength(0, task.referencedLibraries); | 4762 expect(task.referencedLibraries, hasLength(0)); |
| 4763 } | 4763 } |
| 4764 | 4764 |
| 4765 void test_getSource() { | 4765 void test_getSource() { |
| 4766 Source source = new TestSource('/test.dart'); | 4766 Source source = new TestSource('/test.dart'); |
| 4767 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); | 4767 ParseHtmlTask task = new ParseHtmlTask(null, source, ""); |
| 4768 expect(task.source, same(source)); | 4768 expect(task.source, same(source)); |
| 4769 } | 4769 } |
| 4770 | 4770 |
| 4771 void test_perform_embedded_source() { | 4771 void test_perform_embedded_source() { |
| 4772 String contents = r''' | 4772 String contents = r''' |
| 4773 <html> | 4773 <html> |
| 4774 <head> | 4774 <head> |
| 4775 <script type='application/dart'> | 4775 <script type='application/dart'> |
| 4776 void buttonPressed() {} | 4776 void buttonPressed() {} |
| 4777 </script> | 4777 </script> |
| 4778 </head> | 4778 </head> |
| 4779 <body> | 4779 <body> |
| 4780 </body> | 4780 </body> |
| 4781 </html>'''; | 4781 </html>'''; |
| 4782 TestLogger testLogger = new TestLogger(); | 4782 TestLogger testLogger = new TestLogger(); |
| 4783 ParseHtmlTask task = parseContents(contents, testLogger); | 4783 ParseHtmlTask task = parseContents(contents, testLogger); |
| 4784 EngineTestCase.assertLength(0, task.referencedLibraries); | 4784 expect(task.referencedLibraries, hasLength(0)); |
| 4785 expect(testLogger.errorCount, 0); | 4785 expect(testLogger.errorCount, 0); |
| 4786 expect(testLogger.infoCount, 0); | 4786 expect(testLogger.infoCount, 0); |
| 4787 } | 4787 } |
| 4788 | 4788 |
| 4789 void test_perform_empty_source_reference() { | 4789 void test_perform_empty_source_reference() { |
| 4790 String contents = r''' | 4790 String contents = r''' |
| 4791 <html> | 4791 <html> |
| 4792 <head> | 4792 <head> |
| 4793 <script type='application/dart' src=''/> | 4793 <script type='application/dart' src=''/> |
| 4794 </head> | 4794 </head> |
| 4795 <body> | 4795 <body> |
| 4796 </body> | 4796 </body> |
| 4797 </html>'''; | 4797 </html>'''; |
| 4798 TestLogger testLogger = new TestLogger(); | 4798 TestLogger testLogger = new TestLogger(); |
| 4799 ParseHtmlTask task = parseContents(contents, testLogger); | 4799 ParseHtmlTask task = parseContents(contents, testLogger); |
| 4800 EngineTestCase.assertLength(0, task.referencedLibraries); | 4800 expect(task.referencedLibraries, hasLength(0)); |
| 4801 expect(testLogger.errorCount, 0); | 4801 expect(testLogger.errorCount, 0); |
| 4802 expect(testLogger.infoCount, 0); | 4802 expect(testLogger.infoCount, 0); |
| 4803 } | 4803 } |
| 4804 | 4804 |
| 4805 void test_perform_invalid_source_reference() { | 4805 void test_perform_invalid_source_reference() { |
| 4806 String contents = r''' | 4806 String contents = r''' |
| 4807 <html> | 4807 <html> |
| 4808 <head> | 4808 <head> |
| 4809 <script type='application/dart' src='an;invalid:[]uri'/> | 4809 <script type='application/dart' src='an;invalid:[]uri'/> |
| 4810 </head> | 4810 </head> |
| 4811 <body> | 4811 <body> |
| 4812 </body> | 4812 </body> |
| 4813 </html>'''; | 4813 </html>'''; |
| 4814 TestLogger testLogger = new TestLogger(); | 4814 TestLogger testLogger = new TestLogger(); |
| 4815 ParseHtmlTask task = parseContents(contents, testLogger); | 4815 ParseHtmlTask task = parseContents(contents, testLogger); |
| 4816 EngineTestCase.assertLength(0, task.referencedLibraries); | 4816 expect(task.referencedLibraries, hasLength(0)); |
| 4817 expect(testLogger.errorCount, 0); | 4817 expect(testLogger.errorCount, 0); |
| 4818 expect(testLogger.infoCount, 0); | 4818 expect(testLogger.infoCount, 0); |
| 4819 } | 4819 } |
| 4820 | 4820 |
| 4821 void test_perform_non_existing_source_reference() { | 4821 void test_perform_non_existing_source_reference() { |
| 4822 String contents = r''' | 4822 String contents = r''' |
| 4823 <html> | 4823 <html> |
| 4824 <head> | 4824 <head> |
| 4825 <script type='application/dart' src='does/not/exist.dart'/> | 4825 <script type='application/dart' src='does/not/exist.dart'/> |
| 4826 </head> | 4826 </head> |
| 4827 <body> | 4827 <body> |
| 4828 </body> | 4828 </body> |
| 4829 </html>'''; | 4829 </html>'''; |
| 4830 TestLogger testLogger = new TestLogger(); | 4830 TestLogger testLogger = new TestLogger(); |
| 4831 ParseHtmlTask task = parseSource( | 4831 ParseHtmlTask task = parseSource( |
| 4832 new ParseHtmlTaskTest_non_existing_source(contents), | 4832 new ParseHtmlTaskTest_non_existing_source(contents), |
| 4833 contents, | 4833 contents, |
| 4834 testLogger); | 4834 testLogger); |
| 4835 EngineTestCase.assertLength(0, task.referencedLibraries); | 4835 expect(task.referencedLibraries, hasLength(0)); |
| 4836 expect(testLogger.errorCount, 0); | 4836 expect(testLogger.errorCount, 0); |
| 4837 expect(testLogger.infoCount, 0); | 4837 expect(testLogger.infoCount, 0); |
| 4838 } | 4838 } |
| 4839 | 4839 |
| 4840 void test_perform_referenced_source() { | 4840 void test_perform_referenced_source() { |
| 4841 // TODO(scheglov) this test fails because we put into cache TestSource | 4841 // TODO(scheglov) this test fails because we put into cache TestSource |
| 4842 // test.dart (and actually should test.html), but resolve | 4842 // test.dart (and actually should test.html), but resolve |
| 4843 // src='test.dart' as a FileBasedSource | 4843 // src='test.dart' as a FileBasedSource |
| 4844 // We need to switch to a virtual file system and use it everywhere. | 4844 // We need to switch to a virtual file system and use it everywhere. |
| 4845 // String contents = EngineTestCase.createSource([ | 4845 // String contents = EngineTestCase.createSource([ |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5120 expect(task.element, isNull); | 5120 expect(task.element, isNull); |
| 5121 } | 5121 } |
| 5122 | 5122 |
| 5123 void test_getException() { | 5123 void test_getException() { |
| 5124 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5124 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5125 expect(task.exception, isNull); | 5125 expect(task.exception, isNull); |
| 5126 } | 5126 } |
| 5127 | 5127 |
| 5128 void test_getResolutionErrors() { | 5128 void test_getResolutionErrors() { |
| 5129 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); | 5129 ResolveHtmlTask task = new ResolveHtmlTask(null, null, 0, null); |
| 5130 EngineTestCase.assertLength(0, task.resolutionErrors); | 5130 expect(task.resolutionErrors, hasLength(0)); |
| 5131 } | 5131 } |
| 5132 | 5132 |
| 5133 void test_getSource() { | 5133 void test_getSource() { |
| 5134 Source source = new TestSource('test.dart', ''); | 5134 Source source = new TestSource('test.dart', ''); |
| 5135 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); | 5135 ResolveHtmlTask task = new ResolveHtmlTask(null, source, 0, null); |
| 5136 expect(task.source, same(source)); | 5136 expect(task.source, same(source)); |
| 5137 } | 5137 } |
| 5138 | 5138 |
| 5139 void test_perform_exception() { | 5139 void test_perform_exception() { |
| 5140 Source source = new TestSource(); | 5140 Source source = new TestSource(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5191 int modificationStamp; | 5191 int modificationStamp; |
| 5192 Source source; | 5192 Source source; |
| 5193 ResolveHtmlTaskTestTV_perform_valid(this.modificationStamp, this.source); | 5193 ResolveHtmlTaskTestTV_perform_valid(this.modificationStamp, this.source); |
| 5194 @override | 5194 @override |
| 5195 Object visitResolveHtmlTask(ResolveHtmlTask task) { | 5195 Object visitResolveHtmlTask(ResolveHtmlTask task) { |
| 5196 CaughtException exception = task.exception; | 5196 CaughtException exception = task.exception; |
| 5197 if (exception != null) { | 5197 if (exception != null) { |
| 5198 throw exception; | 5198 throw exception; |
| 5199 } | 5199 } |
| 5200 expect(task.element, isNotNull); | 5200 expect(task.element, isNotNull); |
| 5201 EngineTestCase.assertLength(1, task.resolutionErrors); | 5201 expect(task.resolutionErrors, hasLength(1)); |
| 5202 expect(task.source, same(source)); | 5202 expect(task.source, same(source)); |
| 5203 return null; | 5203 return null; |
| 5204 } | 5204 } |
| 5205 } | 5205 } |
| 5206 | 5206 |
| 5207 | 5207 |
| 5208 class ResolveHtmlTaskTestTV_perform_valid_2 extends TestTaskVisitor<Object> { | 5208 class ResolveHtmlTaskTestTV_perform_valid_2 extends TestTaskVisitor<Object> { |
| 5209 @override | 5209 @override |
| 5210 Object visitParseHtmlTask(ParseHtmlTask task) => null; | 5210 Object visitParseHtmlTask(ParseHtmlTask task) => null; |
| 5211 } | 5211 } |
| 5212 | 5212 |
| 5213 | 5213 |
| 5214 class ScanDartTaskTest extends EngineTestCase { | 5214 class ScanDartTaskTest extends EngineTestCase { |
| 5215 void test_accept() { | 5215 void test_accept() { |
| 5216 ScanDartTask task = new ScanDartTask(null, null, null); | 5216 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5217 expect(task.accept(new ScanDartTaskTestTV_accept()), isTrue); | 5217 expect(task.accept(new ScanDartTaskTestTV_accept()), isTrue); |
| 5218 } | 5218 } |
| 5219 | 5219 |
| 5220 void test_getErrors() { | 5220 void test_getErrors() { |
| 5221 ScanDartTask task = new ScanDartTask(null, null, null); | 5221 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5222 EngineTestCase.assertLength(0, task.errors); | 5222 expect(task.errors, hasLength(0)); |
| 5223 } | 5223 } |
| 5224 | 5224 |
| 5225 void test_getException() { | 5225 void test_getException() { |
| 5226 ScanDartTask task = new ScanDartTask(null, null, null); | 5226 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5227 expect(task.exception, isNull); | 5227 expect(task.exception, isNull); |
| 5228 } | 5228 } |
| 5229 | 5229 |
| 5230 void test_getLineInfo() { | 5230 void test_getLineInfo() { |
| 5231 ScanDartTask task = new ScanDartTask(null, null, null); | 5231 ScanDartTask task = new ScanDartTask(null, null, null); |
| 5232 expect(task.lineInfo, isNull); | 5232 expect(task.lineInfo, isNull); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 5260 InternalAnalysisContext context; | 5260 InternalAnalysisContext context; |
| 5261 Source source; | 5261 Source source; |
| 5262 ScanDartTaskTestTV_perform_valid(this.context, this.source); | 5262 ScanDartTaskTestTV_perform_valid(this.context, this.source); |
| 5263 @override | 5263 @override |
| 5264 bool visitScanDartTask(ScanDartTask task) { | 5264 bool visitScanDartTask(ScanDartTask task) { |
| 5265 CaughtException exception = task.exception; | 5265 CaughtException exception = task.exception; |
| 5266 if (exception != null) { | 5266 if (exception != null) { |
| 5267 throw exception; | 5267 throw exception; |
| 5268 } | 5268 } |
| 5269 expect(task.tokenStream, isNotNull); | 5269 expect(task.tokenStream, isNotNull); |
| 5270 EngineTestCase.assertLength(0, task.errors); | 5270 expect(task.errors, hasLength(0)); |
| 5271 expect(task.lineInfo, isNotNull); | 5271 expect(task.lineInfo, isNotNull); |
| 5272 expect(task.source, same(source)); | 5272 expect(task.source, same(source)); |
| 5273 return true; | 5273 return true; |
| 5274 } | 5274 } |
| 5275 } | 5275 } |
| 5276 | 5276 |
| 5277 | 5277 |
| 5278 class SdkCachePartitionTest extends EngineTestCase { | 5278 class SdkCachePartitionTest extends EngineTestCase { |
| 5279 void test_contains_false() { | 5279 void test_contains_false() { |
| 5280 SdkCachePartition partition = new SdkCachePartition(null, 8); | 5280 SdkCachePartition partition = new SdkCachePartition(null, 8); |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6496 } | 6496 } |
| 6497 } | 6497 } |
| 6498 | 6498 |
| 6499 | 6499 |
| 6500 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 6500 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 6501 CacheRetentionPolicy { | 6501 CacheRetentionPolicy { |
| 6502 @override | 6502 @override |
| 6503 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 6503 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 6504 RetentionPriority.LOW; | 6504 RetentionPriority.LOW; |
| 6505 } | 6505 } |
| OLD | NEW |