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 'package:front_end/memory_file_system.dart'; | 5 import 'package:front_end/memory_file_system.dart'; |
6 import 'package:front_end/src/fasta/translate_uri.dart'; | 6 import 'package:front_end/src/fasta/translate_uri.dart'; |
7 import 'package:front_end/src/incremental/file_state.dart'; | 7 import 'package:front_end/src/incremental/file_state.dart'; |
8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
10 | 10 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 expect(aFile.exportedLibraries, isEmpty); | 62 expect(aFile.exportedLibraries, isEmpty); |
63 expect(aFile.partFiles, isEmpty); | 63 expect(aFile.partFiles, isEmpty); |
64 | 64 |
65 expect(bFile.fileUri, b); | 65 expect(bFile.fileUri, b); |
66 expect(bFile.exists, isTrue); | 66 expect(bFile.exists, isTrue); |
67 _assertImportedUris(bFile, [_coreUri]); | 67 _assertImportedUris(bFile, [_coreUri]); |
68 expect(bFile.exportedLibraries, isEmpty); | 68 expect(bFile.exportedLibraries, isEmpty); |
69 expect(bFile.partFiles, isEmpty); | 69 expect(bFile.partFiles, isEmpty); |
70 } | 70 } |
71 | 71 |
| 72 test_getFile_exports() async { |
| 73 var a = writeFile('/a.dart', ''); |
| 74 var b = writeFile('/b.dart', ''); |
| 75 var c = writeFile('/c.dart', ''); |
| 76 var d = writeFile( |
| 77 '/d.dart', |
| 78 r''' |
| 79 export "a.dart" show A, B; |
| 80 export "b.dart" hide C, D; |
| 81 export "c.dart" show A, B, C, D hide C show A, D; |
| 82 '''); |
| 83 |
| 84 FileState aFile = await fsState.getFile(a); |
| 85 FileState bFile = await fsState.getFile(b); |
| 86 FileState cFile = await fsState.getFile(c); |
| 87 FileState dFile = await fsState.getFile(d); |
| 88 |
| 89 expect(dFile.exports, hasLength(3)); |
| 90 { |
| 91 NamespaceExport export_ = dFile.exports[0]; |
| 92 expect(export_.library, aFile); |
| 93 expect(export_.combinators, hasLength(1)); |
| 94 expect(export_.combinators[0].isShow, isTrue); |
| 95 expect(export_.combinators[0].names, unorderedEquals(['A', 'B'])); |
| 96 expect(export_.filter('A'), isTrue); |
| 97 expect(export_.filter('B'), isTrue); |
| 98 expect(export_.filter('C'), isFalse); |
| 99 expect(export_.filter('D'), isFalse); |
| 100 } |
| 101 { |
| 102 NamespaceExport export_ = dFile.exports[1]; |
| 103 expect(export_.library, bFile); |
| 104 expect(export_.combinators, hasLength(1)); |
| 105 expect(export_.combinators[0].isShow, isFalse); |
| 106 expect(export_.combinators[0].names, unorderedEquals(['C', 'D'])); |
| 107 expect(export_.filter('A'), isTrue); |
| 108 expect(export_.filter('B'), isTrue); |
| 109 expect(export_.filter('C'), isFalse); |
| 110 expect(export_.filter('D'), isFalse); |
| 111 } |
| 112 { |
| 113 NamespaceExport export_ = dFile.exports[2]; |
| 114 expect(export_.library, cFile); |
| 115 expect(export_.combinators, hasLength(3)); |
| 116 expect(export_.combinators[0].isShow, isTrue); |
| 117 expect( |
| 118 export_.combinators[0].names, unorderedEquals(['A', 'B', 'C', 'D'])); |
| 119 expect(export_.combinators[1].isShow, isFalse); |
| 120 expect(export_.combinators[1].names, unorderedEquals(['C'])); |
| 121 expect(export_.combinators[2].isShow, isTrue); |
| 122 expect(export_.combinators[2].names, unorderedEquals(['A', 'D'])); |
| 123 expect(export_.filter('A'), isTrue); |
| 124 expect(export_.filter('B'), isFalse); |
| 125 expect(export_.filter('C'), isFalse); |
| 126 expect(export_.filter('D'), isTrue); |
| 127 } |
| 128 } |
| 129 |
72 test_topologicalOrder_cycleBeforeTarget() async { | 130 test_topologicalOrder_cycleBeforeTarget() async { |
73 var aUri = _writeFileDirectives('/a.dart'); | 131 var aUri = _writeFileDirectives('/a.dart'); |
74 var bUri = _writeFileDirectives('/b.dart', imports: ['c.dart']); | 132 var bUri = _writeFileDirectives('/b.dart', imports: ['c.dart']); |
75 var cUri = _writeFileDirectives('/c.dart', imports: ['b.dart']); | 133 var cUri = _writeFileDirectives('/c.dart', imports: ['b.dart']); |
76 var dUri = _writeFileDirectives('/d.dart', imports: ['a.dart', 'b.dart']); | 134 var dUri = _writeFileDirectives('/d.dart', imports: ['a.dart', 'b.dart']); |
77 | 135 |
78 FileState core = await fsState.getFile(_coreUri); | 136 FileState core = await fsState.getFile(_coreUri); |
79 FileState a = await fsState.getFile(aUri); | 137 FileState a = await fsState.getFile(aUri); |
80 FileState b = await fsState.getFile(bUri); | 138 FileState b = await fsState.getFile(bUri); |
81 FileState c = await fsState.getFile(cUri); | 139 FileState c = await fsState.getFile(cUri); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 Uri _writeFileDirectives(String path, | 204 Uri _writeFileDirectives(String path, |
147 {List<String> imports: const [], List<String> exports: const []}) { | 205 {List<String> imports: const [], List<String> exports: const []}) { |
148 return writeFile( | 206 return writeFile( |
149 path, | 207 path, |
150 ''' | 208 ''' |
151 ${imports.map((uri) => 'import "$uri";').join('\n')} | 209 ${imports.map((uri) => 'import "$uri";').join('\n')} |
152 ${exports.map((uri) => 'export "$uri";').join('\n')} | 210 ${exports.map((uri) => 'export "$uri";').join('\n')} |
153 '''); | 211 '''); |
154 } | 212 } |
155 } | 213 } |
OLD | NEW |