OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:front_end/memory_file_system.dart'; | 7 import 'package:front_end/memory_file_system.dart'; |
8 import 'package:front_end/src/fasta/translate_uri.dart'; | 8 import 'package:front_end/src/fasta/translate_uri.dart'; |
9 import 'package:front_end/src/incremental/file_state.dart'; | 9 import 'package:front_end/src/incremental/file_state.dart'; |
10 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 var eFile = await fsState.getFile(e); | 156 var eFile = await fsState.getFile(e); |
157 | 157 |
158 // The root and four files. | 158 // The root and four files. |
159 expect(fsState.fileUris, contains(e)); | 159 expect(fsState.fileUris, contains(e)); |
160 expect(fsState.fileUris, contains(a)); | 160 expect(fsState.fileUris, contains(a)); |
161 expect(fsState.fileUris, contains(b)); | 161 expect(fsState.fileUris, contains(b)); |
162 expect(fsState.fileUris, contains(c)); | 162 expect(fsState.fileUris, contains(c)); |
163 expect(fsState.fileUris, contains(d)); | 163 expect(fsState.fileUris, contains(d)); |
164 | 164 |
165 // No changes after GC. | 165 // No changes after GC. |
166 fsState.gc(e); | 166 expect(fsState.gc(e), isEmpty); |
167 expect(fsState.fileUris, contains(e)); | 167 expect(fsState.fileUris, contains(e)); |
168 expect(fsState.fileUris, contains(a)); | 168 expect(fsState.fileUris, contains(a)); |
169 expect(fsState.fileUris, contains(b)); | 169 expect(fsState.fileUris, contains(b)); |
170 expect(fsState.fileUris, contains(c)); | 170 expect(fsState.fileUris, contains(c)); |
171 expect(fsState.fileUris, contains(d)); | 171 expect(fsState.fileUris, contains(d)); |
172 | 172 |
173 // Update e.dart so that it does not reference c.dart anymore. | 173 // Update e.dart so that it does not reference c.dart anymore. |
174 // Then GC removes both c.dart and a.dart it references. | 174 // Then GC removes both c.dart and a.dart it references. |
175 writeFile( | 175 writeFile( |
176 '/e.dart', | 176 '/e.dart', |
177 r''' | 177 r''' |
178 import "d.dart"; | 178 import "d.dart"; |
179 '''); | 179 '''); |
180 await eFile.refresh(); | 180 await eFile.refresh(); |
181 fsState.gc(e); | 181 { |
| 182 var gcFiles = fsState.gc(e); |
| 183 expect(gcFiles.map((file) => file.uri), unorderedEquals([a, c])); |
| 184 } |
182 expect(fsState.fileUris, contains(e)); | 185 expect(fsState.fileUris, contains(e)); |
183 expect(fsState.fileUris, isNot(contains(a))); | 186 expect(fsState.fileUris, isNot(contains(a))); |
184 expect(fsState.fileUris, contains(b)); | 187 expect(fsState.fileUris, contains(b)); |
185 expect(fsState.fileUris, isNot(contains(c))); | 188 expect(fsState.fileUris, isNot(contains(c))); |
186 expect(fsState.fileUris, contains(d)); | 189 expect(fsState.fileUris, contains(d)); |
187 } | 190 } |
188 | 191 |
189 test_getFile() async { | 192 test_getFile() async { |
190 var a = writeFile('/a.dart', ''); | 193 var a = writeFile('/a.dart', ''); |
191 var b = writeFile('/b.dart', ''); | 194 var b = writeFile('/b.dart', ''); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 Uri _writeFileDirectives(String path, | 391 Uri _writeFileDirectives(String path, |
389 {List<String> imports: const [], List<String> exports: const []}) { | 392 {List<String> imports: const [], List<String> exports: const []}) { |
390 return writeFile( | 393 return writeFile( |
391 path, | 394 path, |
392 ''' | 395 ''' |
393 ${imports.map((uri) => 'import "$uri";').join('\n')} | 396 ${imports.map((uri) => 'import "$uri";').join('\n')} |
394 ${exports.map((uri) => 'export "$uri";').join('\n')} | 397 ${exports.map((uri) => 'export "$uri";').join('\n')} |
395 '''); | 398 '''); |
396 } | 399 } |
397 } | 400 } |
OLD | NEW |