| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library test.src.task.dart_work_manager_test; | 5 library test.src.task.dart_work_manager_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' | 9 import 'package:analyzer/src/generated/engine.dart' |
| 10 show | 10 show |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); | 586 new AnalysisError(source1, 1, 0, ScannerErrorCode.MISSING_DIGIT); |
| 587 AnalysisError error2 = | 587 AnalysisError error2 = |
| 588 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); | 588 new AnalysisError(source1, 2, 0, ScannerErrorCode.MISSING_DIGIT); |
| 589 when(context.getLibrariesContaining(source1)).thenReturn([source2]); | 589 when(context.getLibrariesContaining(source1)).thenReturn([source2]); |
| 590 when(context.getErrors(source1)) | 590 when(context.getErrors(source1)) |
| 591 .thenReturn(new AnalysisErrorInfoImpl([error1, error2], lineInfo)); | 591 .thenReturn(new AnalysisErrorInfoImpl([error1, error2], lineInfo)); |
| 592 entry1.setValue(LINE_INFO, lineInfo, []); | 592 entry1.setValue(LINE_INFO, lineInfo, []); |
| 593 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); | 593 entry1.setValue(SCAN_ERRORS, <AnalysisError>[error1], []); |
| 594 entry1.setValue(PARSE_ERRORS, <AnalysisError>[error2], []); | 594 entry1.setValue(PARSE_ERRORS, <AnalysisError>[error2], []); |
| 595 // PARSED_UNIT is ready, set errors | 595 // PARSED_UNIT is ready, set errors |
| 596 manager.resultsComputed( | 596 manager |
| 597 source1, {PARSED_UNIT: AstFactory.compilationUnit()}); | 597 .resultsComputed(source1, {PARSED_UNIT: AstFactory.compilationUnit()}); |
| 598 // all of the errors are included | 598 // all of the errors are included |
| 599 ChangeNoticeImpl notice = context.getNotice(source1); | 599 ChangeNoticeImpl notice = context.getNotice(source1); |
| 600 expect(notice.errors, unorderedEquals([error1, error2])); | 600 expect(notice.errors, unorderedEquals([error1, error2])); |
| 601 expect(notice.lineInfo, lineInfo); | 601 expect(notice.lineInfo, lineInfo); |
| 602 } | 602 } |
| 603 | 603 |
| 604 void test_resultsComputed_includedParts_updatePartLibraries() { | 604 void test_resultsComputed_includedParts_updatePartLibraries() { |
| 605 Source part1 = new TestSource('part1.dart'); | 605 Source part1 = new TestSource('part1.dart'); |
| 606 Source part2 = new TestSource('part2.dart'); | 606 Source part2 = new TestSource('part2.dart'); |
| 607 Source part3 = new TestSource('part3.dart'); | 607 Source part3 = new TestSource('part3.dart'); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 CacheEntry entry = cache.get(source); | 754 CacheEntry entry = cache.get(source); |
| 755 if (entry == null) { | 755 if (entry == null) { |
| 756 entry = new CacheEntry(source); | 756 entry = new CacheEntry(source); |
| 757 entry.explicitlyAdded = explicit; | 757 entry.explicitlyAdded = explicit; |
| 758 cache.put(entry); | 758 cache.put(entry); |
| 759 } | 759 } |
| 760 return entry; | 760 return entry; |
| 761 } | 761 } |
| 762 } | 762 } |
| 763 | 763 |
| 764 class _DartSdkMock extends TypedMock implements DartSdk { | 764 class _DartSdkMock extends TypedMock implements DartSdk {} |
| 765 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 766 } | |
| 767 | 765 |
| 768 class _DartWorkManagerMock extends TypedMock implements DartWorkManager { | 766 class _DartWorkManagerMock extends TypedMock implements DartWorkManager {} |
| 769 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 770 } | |
| 771 | 767 |
| 772 class _InternalAnalysisContextMock extends TypedMock | 768 class _InternalAnalysisContextMock extends TypedMock |
| 773 implements InternalAnalysisContext { | 769 implements InternalAnalysisContext { |
| 774 @override | 770 @override |
| 775 CachePartition privateAnalysisCachePartition; | 771 CachePartition privateAnalysisCachePartition; |
| 776 | 772 |
| 777 @override | 773 @override |
| 778 AnalysisCache analysisCache; | 774 AnalysisCache analysisCache; |
| 779 | 775 |
| 780 Map<Source, ChangeNoticeImpl> _pendingNotices = <Source, ChangeNoticeImpl>{}; | 776 Map<Source, ChangeNoticeImpl> _pendingNotices = <Source, ChangeNoticeImpl>{}; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 792 analysisCache.put(entry); | 788 analysisCache.put(entry); |
| 793 } | 789 } |
| 794 return entry; | 790 return entry; |
| 795 } | 791 } |
| 796 | 792 |
| 797 @override | 793 @override |
| 798 ChangeNoticeImpl getNotice(Source source) { | 794 ChangeNoticeImpl getNotice(Source source) { |
| 799 return _pendingNotices.putIfAbsent( | 795 return _pendingNotices.putIfAbsent( |
| 800 source, () => new ChangeNoticeImpl(source)); | 796 source, () => new ChangeNoticeImpl(source)); |
| 801 } | 797 } |
| 802 | |
| 803 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 804 } | 798 } |
| 805 | 799 |
| 806 class _SourceFactoryMock extends TypedMock implements SourceFactory { | 800 class _SourceFactoryMock extends TypedMock implements SourceFactory {} |
| 807 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 808 } | |
| 809 | 801 |
| 810 class _SourceMock extends TypedMock implements Source { | 802 class _SourceMock extends TypedMock implements Source { |
| 811 final String shortName; | 803 final String shortName; |
| 812 _SourceMock(this.shortName); | 804 _SourceMock(this.shortName); |
| 813 @override | 805 @override |
| 814 String get fullName => '/' + shortName; | 806 String get fullName => '/' + shortName; |
| 815 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 816 @override | 807 @override |
| 817 String toString() => fullName; | 808 String toString() => fullName; |
| 818 } | 809 } |
| OLD | NEW |