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/byte_store/byte_store.dart'; |
8 import 'package:front_end/src/fasta/uri_translator_impl.dart'; | 9 import 'package:front_end/src/fasta/uri_translator_impl.dart'; |
9 import 'package:front_end/src/byte_store/byte_store.dart'; | |
10 import 'package:front_end/src/incremental/file_state.dart'; | 10 import 'package:front_end/src/incremental/file_state.dart'; |
| 11 import 'package:kernel/target/targets.dart'; |
11 import 'package:package_config/packages.dart'; | 12 import 'package:package_config/packages.dart'; |
12 import 'package:test/test.dart'; | 13 import 'package:test/test.dart'; |
13 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 14 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
14 import 'package:kernel/target/targets.dart'; | |
15 | 15 |
16 import 'mock_sdk.dart'; | 16 import 'mock_sdk.dart'; |
17 | 17 |
18 main() { | 18 main() { |
19 defineReflectiveSuite(() { | 19 defineReflectiveSuite(() { |
20 defineReflectiveTests(FileSystemStateTest); | 20 defineReflectiveTests(FileSystemStateTest); |
21 }); | 21 }); |
22 } | 22 } |
23 | 23 |
24 @reflectiveTest | 24 @reflectiveTest |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 expect(aFile.exportedLibraries, isEmpty); | 217 expect(aFile.exportedLibraries, isEmpty); |
218 expect(aFile.partFiles, isEmpty); | 218 expect(aFile.partFiles, isEmpty); |
219 | 219 |
220 expect(bFile.fileUri, b); | 220 expect(bFile.fileUri, b); |
221 expect(bFile.exists, isTrue); | 221 expect(bFile.exists, isTrue); |
222 _assertImportedUris(bFile, [_coreUri]); | 222 _assertImportedUris(bFile, [_coreUri]); |
223 expect(bFile.exportedLibraries, isEmpty); | 223 expect(bFile.exportedLibraries, isEmpty); |
224 expect(bFile.partFiles, isEmpty); | 224 expect(bFile.partFiles, isEmpty); |
225 } | 225 } |
226 | 226 |
227 test_getFile_exports() async { | |
228 var a = writeFile('/a.dart', ''); | |
229 var b = writeFile('/b.dart', ''); | |
230 var c = writeFile('/c.dart', ''); | |
231 var d = writeFile('/d.dart', r''' | |
232 export "a.dart" show A, B; | |
233 export "b.dart" hide C, D; | |
234 export "c.dart" show A, B, C, D hide C show A, D; | |
235 '''); | |
236 | |
237 FileState aFile = await fsState.getFile(a); | |
238 FileState bFile = await fsState.getFile(b); | |
239 FileState cFile = await fsState.getFile(c); | |
240 FileState dFile = await fsState.getFile(d); | |
241 | |
242 expect(dFile.exports, hasLength(3)); | |
243 { | |
244 NamespaceExport export_ = dFile.exports[0]; | |
245 expect(export_.library, aFile); | |
246 expect(export_.combinators, hasLength(1)); | |
247 expect(export_.combinators[0].isShow, isTrue); | |
248 expect(export_.combinators[0].names, unorderedEquals(['A', 'B'])); | |
249 expect(export_.isExposed('A'), isTrue); | |
250 expect(export_.isExposed('B'), isTrue); | |
251 expect(export_.isExposed('C'), isFalse); | |
252 expect(export_.isExposed('D'), isFalse); | |
253 } | |
254 { | |
255 NamespaceExport export_ = dFile.exports[1]; | |
256 expect(export_.library, bFile); | |
257 expect(export_.combinators, hasLength(1)); | |
258 expect(export_.combinators[0].isShow, isFalse); | |
259 expect(export_.combinators[0].names, unorderedEquals(['C', 'D'])); | |
260 expect(export_.isExposed('A'), isTrue); | |
261 expect(export_.isExposed('B'), isTrue); | |
262 expect(export_.isExposed('C'), isFalse); | |
263 expect(export_.isExposed('D'), isFalse); | |
264 } | |
265 { | |
266 NamespaceExport export_ = dFile.exports[2]; | |
267 expect(export_.library, cFile); | |
268 expect(export_.combinators, hasLength(3)); | |
269 expect(export_.combinators[0].isShow, isTrue); | |
270 expect( | |
271 export_.combinators[0].names, unorderedEquals(['A', 'B', 'C', 'D'])); | |
272 expect(export_.combinators[1].isShow, isFalse); | |
273 expect(export_.combinators[1].names, unorderedEquals(['C'])); | |
274 expect(export_.combinators[2].isShow, isTrue); | |
275 expect(export_.combinators[2].names, unorderedEquals(['A', 'D'])); | |
276 expect(export_.isExposed('A'), isTrue); | |
277 expect(export_.isExposed('B'), isFalse); | |
278 expect(export_.isExposed('C'), isFalse); | |
279 expect(export_.isExposed('D'), isTrue); | |
280 } | |
281 } | |
282 | |
283 test_hasMixinApplication_false() async { | 227 test_hasMixinApplication_false() async { |
284 writeFile('/a.dart', r''' | 228 writeFile('/a.dart', r''' |
285 class A {} | 229 class A {} |
286 class B extends Object with A {} | 230 class B extends Object with A {} |
287 '''); | 231 '''); |
288 var uri = writeFile('/test.dart', r''' | 232 var uri = writeFile('/test.dart', r''' |
289 import 'a.dart'; | 233 import 'a.dart'; |
290 class T1 extends A {} | 234 class T1 extends A {} |
291 class T2 extends B {} | 235 class T2 extends B {} |
292 '''); | 236 '''); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 } | 460 } |
517 | 461 |
518 Uri _writeFileDirectives(String path, | 462 Uri _writeFileDirectives(String path, |
519 {List<String> imports: const [], List<String> exports: const []}) { | 463 {List<String> imports: const [], List<String> exports: const []}) { |
520 return writeFile(path, ''' | 464 return writeFile(path, ''' |
521 ${imports.map((uri) => 'import "$uri";').join('\n')} | 465 ${imports.map((uri) => 'import "$uri";').join('\n')} |
522 ${exports.map((uri) => 'export "$uri";').join('\n')} | 466 ${exports.map((uri) => 'export "$uri";').join('\n')} |
523 '''); | 467 '''); |
524 } | 468 } |
525 } | 469 } |
OLD | NEW |