OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 /** Tests for [PathMapper]. */ | 5 /** Tests for [PathMapper]. */ |
6 library path_info_test; | 6 library path_info_test; |
7 | 7 |
8 import 'package:path/path.dart' as path; | 8 import 'package:path/path.dart' as path; |
9 import 'package:unittest/compact_vm_config.dart'; | 9 import 'package:unittest/compact_vm_config.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); | 73 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); |
74 expect(pathMapper.importUrlFor(file1, file3), | 74 expect(pathMapper.importUrlFor(file1, file3), |
75 'package:e/_f.dart.dart'); | 75 'package:e/_f.dart.dart'); |
76 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); | 76 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); |
77 expect(pathMapper.importUrlFor(file2, file3), | 77 expect(pathMapper.importUrlFor(file2, file3), |
78 'package:e/_f.dart.dart'); | 78 'package:e/_f.dart.dart'); |
79 }); | 79 }); |
80 | 80 |
81 test('windows paths', () { | 81 test('windows paths', () { |
82 try { | 82 try { |
83 utils.path = new path.Builder(style: path.Style.windows); | 83 utils.path = path.windows; |
84 var pathMapper = _newPathMapper('a', 'a', false); | 84 var pathMapper = _newPathMapper('a', 'a', false); |
85 var file1 = _mockFile('a\\b.dart', pathMapper); | 85 var file1 = _mockFile('a\\b.dart', pathMapper); |
86 var file2 = _mockFile('a\\c\\d.dart', pathMapper); | 86 var file2 = _mockFile('a\\c\\d.dart', pathMapper); |
87 var file3 = _mockFile('a\\packages\\f.dart', pathMapper); | 87 var file3 = _mockFile('a\\packages\\f.dart', pathMapper); |
88 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); | 88 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); |
89 expect(pathMapper.importUrlFor(file1, file3), | 89 expect(pathMapper.importUrlFor(file1, file3), |
90 '_from_packages/_f.dart.dart'); | 90 '_from_packages/_f.dart.dart'); |
91 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); | 91 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); |
92 expect(pathMapper.importUrlFor(file2, file3), | 92 expect(pathMapper.importUrlFor(file2, file3), |
93 '../_from_packages/_f.dart.dart'); | 93 '../_from_packages/_f.dart.dart'); |
94 expect(pathMapper.importUrlFor(file3, file2), '../c/_d.dart.dart'); | 94 expect(pathMapper.importUrlFor(file3, file2), '../c/_d.dart.dart'); |
95 expect(pathMapper.importUrlFor(file3, file1), '../_b.dart.dart'); | 95 expect(pathMapper.importUrlFor(file3, file1), '../_b.dart.dart'); |
96 } finally { | 96 } finally { |
97 utils.path = new path.Builder(); | 97 utils.path = new path.Context(); |
98 } | 98 } |
99 }); | 99 }); |
100 }); | 100 }); |
101 | 101 |
102 test('transformUrl simple paths', () { | 102 test('transformUrl simple paths', () { |
103 var pathMapper = _newPathMapper('a', 'a', false); | 103 var pathMapper = _newPathMapper('a', 'a', false); |
104 var file1 = 'a/b.dart'; | 104 var file1 = 'a/b.dart'; |
105 var file2 = 'a/c/d.html'; | 105 var file2 = 'a/c/d.html'; |
106 // when the output == input directory, no paths should be rewritten | 106 // when the output == input directory, no paths should be rewritten |
107 expect(pathMapper.transformUrl(file1, '/a.dart'), '/a.dart'); | 107 expect(pathMapper.transformUrl(file1, '/a.dart'), '/a.dart'); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 '_from_packages/e/_f.dart.dart'); | 221 '_from_packages/e/_f.dart.dart'); |
222 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); | 222 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); |
223 expect(pathMapper.importUrlFor(file2, file3), | 223 expect(pathMapper.importUrlFor(file2, file3), |
224 '../_from_packages/e/_f.dart.dart'); | 224 '../_from_packages/e/_f.dart.dart'); |
225 expect(pathMapper.importUrlFor(file3, file2), '../../c/_d.dart.dart'); | 225 expect(pathMapper.importUrlFor(file3, file2), '../../c/_d.dart.dart'); |
226 expect(pathMapper.importUrlFor(file3, file1), '../../_b.dart.dart'); | 226 expect(pathMapper.importUrlFor(file3, file1), '../../_b.dart.dart'); |
227 }); | 227 }); |
228 | 228 |
229 test('windows paths', () { | 229 test('windows paths', () { |
230 try { | 230 try { |
231 utils.path = new path.Builder(style: path.Style.windows); | 231 utils.path = path.windows; |
232 var pathMapper = _newPathMapper('a', 'out', true); | 232 var pathMapper = _newPathMapper('a', 'out', true); |
233 var file1 = _mockFile('a\\b.dart', pathMapper); | 233 var file1 = _mockFile('a\\b.dart', pathMapper); |
234 var file2 = _mockFile('a\\c\\d.dart', pathMapper); | 234 var file2 = _mockFile('a\\c\\d.dart', pathMapper); |
235 var file3 = _mockFile('a\\packages\\f.dart', pathMapper); | 235 var file3 = _mockFile('a\\packages\\f.dart', pathMapper); |
236 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); | 236 expect(pathMapper.importUrlFor(file1, file2), 'c/_d.dart.dart'); |
237 expect(pathMapper.importUrlFor(file1, file3), | 237 expect(pathMapper.importUrlFor(file1, file3), |
238 '_from_packages/_f.dart.dart'); | 238 '_from_packages/_f.dart.dart'); |
239 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); | 239 expect(pathMapper.importUrlFor(file2, file1), '../_b.dart.dart'); |
240 expect(pathMapper.importUrlFor(file2, file3), | 240 expect(pathMapper.importUrlFor(file2, file3), |
241 '../_from_packages/_f.dart.dart'); | 241 '../_from_packages/_f.dart.dart'); |
242 expect(pathMapper.importUrlFor(file3, file2), '../c/_d.dart.dart'); | 242 expect(pathMapper.importUrlFor(file3, file2), '../c/_d.dart.dart'); |
243 expect(pathMapper.importUrlFor(file3, file1), '../_b.dart.dart'); | 243 expect(pathMapper.importUrlFor(file3, file1), '../_b.dart.dart'); |
244 } finally { | 244 } finally { |
245 utils.path = new path.Builder(); | 245 utils.path = new path.Context(); |
246 } | 246 } |
247 }); | 247 }); |
248 }); | 248 }); |
249 | 249 |
250 group('transformUrl', () { | 250 group('transformUrl', () { |
251 test('simple source, not in packages/', () { | 251 test('simple source, not in packages/', () { |
252 var pathMapper = _newPathMapper('a', 'out', false); | 252 var pathMapper = _newPathMapper('a', 'out', false); |
253 var file1 = 'a/b.dart'; | 253 var file1 = 'a/b.dart'; |
254 var file2 = 'a/c/d.html'; | 254 var file2 = 'a/c/d.html'; |
255 // when the output == input directory, no paths should be rewritten | 255 // when the output == input directory, no paths should be rewritten |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 var file = new FileInfo(new UrlInfo( | 318 var file = new FileInfo(new UrlInfo( |
319 url == null ? filePath : url, filePath, null)); | 319 url == null ? filePath : url, filePath, null)); |
320 file.outputFilename = pathMapper.mangle( | 320 file.outputFilename = pathMapper.mangle( |
321 utils.path.basename(filePath), '.dart', false); | 321 utils.path.basename(filePath), '.dart', false); |
322 return file; | 322 return file; |
323 } | 323 } |
324 | 324 |
325 _checkPath(String filePath, String expected) { | 325 _checkPath(String filePath, String expected) { |
326 expect(utils.path.normalize(filePath), expected); | 326 expect(utils.path.normalize(filePath), expected); |
327 } | 327 } |
OLD | NEW |