OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 analyzer.test.driver; | 5 library analyzer.test.driver; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 provider, | 70 provider, |
71 byteStore, | 71 byteStore, |
72 contentCache, | 72 contentCache, |
73 new SourceFactory([ | 73 new SourceFactory([ |
74 new DartUriResolver(sdk), | 74 new DartUriResolver(sdk), |
75 new PackageMapUriResolver(provider, <String, List<Folder>>{ | 75 new PackageMapUriResolver(provider, <String, List<Folder>>{ |
76 'test': [provider.getFolder(testProject)] | 76 'test': [provider.getFolder(testProject)] |
77 }) | 77 }) |
78 ], null, provider), | 78 ], null, provider), |
79 new AnalysisOptionsImpl()..strongMode = true); | 79 new AnalysisOptionsImpl()..strongMode = true); |
80 driver.status.listen((status) { | 80 driver.status.lastWhere((status) { |
81 allStatuses.add(status); | 81 allStatuses.add(status); |
82 if (status.isIdle) { | 82 if (status.isIdle) { |
83 idleStatusMonitor.notify(); | 83 idleStatusMonitor.notify(); |
84 } | 84 } |
85 }); | 85 }); |
86 driver.results.listen(allResults.add); | 86 driver.results.listen(allResults.add); |
87 } | 87 } |
88 | 88 |
89 test_addFile_thenRemove() async { | 89 test_addFile_thenRemove() async { |
90 var a = _p('/test/lib/a.dart'); | 90 var a = _p('/test/lib/a.dart'); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // While "b" is not analyzed explicitly, it is analyzed implicitly. | 134 // While "b" is not analyzed explicitly, it is analyzed implicitly. |
135 // The change causes "a" to be reanalyzed. | 135 // The change causes "a" to be reanalyzed. |
136 await _waitForIdle(); | 136 await _waitForIdle(); |
137 expect(allResults, hasLength(1)); | 137 expect(allResults, hasLength(1)); |
138 { | 138 { |
139 AnalysisResult ar = allResults.firstWhere((r) => r.path == a); | 139 AnalysisResult ar = allResults.firstWhere((r) => r.path == a); |
140 expect(_getTopLevelVarType(ar.unit, 'A'), 'double'); | 140 expect(_getTopLevelVarType(ar.unit, 'A'), 'double'); |
141 } | 141 } |
142 } | 142 } |
143 | 143 |
144 test_changeFile_noContentChange_noNewResult() async { | |
145 _addTestFile('main() {}', priority: true); | |
146 | |
147 // Initial analysis. | |
148 await _waitForIdle(); | |
149 expect(allResults, hasLength(1)); | |
150 | |
151 // Update the file, but don't notify the driver. | |
152 // Don't update the file in the file system. | |
153 // But tell the driver the the file was changed. | |
154 // The driver should eventually check the file and ignore. | |
155 allStatuses.clear(); | |
156 allResults.clear(); | |
157 driver.changeFile(testFile); | |
158 | |
159 // The driver switched to analysis and back to idle. | |
160 await _waitForIdle(); | |
161 expect(allStatuses, hasLength(2)); | |
162 expect(allStatuses.map((status) => status.isAnalyzing), [true, false]); | |
163 | |
164 // No new results. | |
165 expect(allResults, isEmpty); | |
166 } | |
167 | |
168 test_changeFile_selfConsistent() async { | 144 test_changeFile_selfConsistent() async { |
169 var a = _p('/test/lib/a.dart'); | 145 var a = _p('/test/lib/a.dart'); |
170 var b = _p('/test/lib/b.dart'); | 146 var b = _p('/test/lib/b.dart'); |
171 provider.newFile( | 147 provider.newFile( |
172 a, | 148 a, |
173 r''' | 149 r''' |
174 import 'b.dart'; | 150 import 'b.dart'; |
175 var A1 = 1; | 151 var A1 = 1; |
176 var A2 = B1; | 152 var A2 = B1; |
177 '''); | 153 '''); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 @override | 541 @override |
566 List<int> get(String key) { | 542 List<int> get(String key) { |
567 return map[key]; | 543 return map[key]; |
568 } | 544 } |
569 | 545 |
570 @override | 546 @override |
571 void put(String key, List<int> bytes) { | 547 void put(String key, List<int> bytes) { |
572 map[key] = bytes; | 548 map[key] = bytes; |
573 } | 549 } |
574 } | 550 } |
OLD | NEW |