| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 test.physical_file_system; | 5 library test.physical_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
| 9 | 9 |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 }); | 305 }); |
| 306 | 306 |
| 307 test('folder', () { | 307 test('folder', () { |
| 308 new io.Directory(join(path, 'myFolder')).createSync(); | 308 new io.Directory(join(path, 'myFolder')).createSync(); |
| 309 Folder child = folder.getChildAssumingFolder('myFolder'); | 309 Folder child = folder.getChildAssumingFolder('myFolder'); |
| 310 expect(child, isNotNull); | 310 expect(child, isNotNull); |
| 311 expect(child.exists, isTrue); | 311 expect(child.exists, isTrue); |
| 312 }); | 312 }); |
| 313 }); | 313 }); |
| 314 | 314 |
| 315 test('getChildren', () { | 315 group('getChildren', () { |
| 316 // create 2 files and 1 folder | 316 test('exists', () { |
| 317 new io.File(join(path, 'a.txt')).createSync(); | 317 // create 2 files and 1 folder |
| 318 new io.Directory(join(path, 'bFolder')).createSync(); | 318 new io.File(join(path, 'a.txt')).createSync(); |
| 319 new io.File(join(path, 'c.txt')).createSync(); | 319 new io.Directory(join(path, 'bFolder')).createSync(); |
| 320 // prepare 3 children | 320 new io.File(join(path, 'c.txt')).createSync(); |
| 321 List<Resource> children = folder.getChildren(); | 321 // prepare 3 children |
| 322 expect(children, hasLength(3)); | 322 List<Resource> children = folder.getChildren(); |
| 323 children.sort((a, b) => a.shortName.compareTo(b.shortName)); | 323 expect(children, hasLength(3)); |
| 324 // check that each child exists | 324 children.sort((a, b) => a.shortName.compareTo(b.shortName)); |
| 325 children.forEach((child) { | 325 // check that each child exists |
| 326 expect(child.exists, true); | 326 children.forEach((child) { |
| 327 expect(child.exists, true); |
| 328 }); |
| 329 // check names |
| 330 expect(children[0].shortName, 'a.txt'); |
| 331 expect(children[1].shortName, 'bFolder'); |
| 332 expect(children[2].shortName, 'c.txt'); |
| 333 // check types |
| 334 expect(children[0], _isFile); |
| 335 expect(children[1], _isFolder); |
| 336 expect(children[2], _isFile); |
| 327 }); | 337 }); |
| 328 // check names | 338 |
| 329 expect(children[0].shortName, 'a.txt'); | 339 test('does not exist', () { |
| 330 expect(children[1].shortName, 'bFolder'); | 340 folder = folder.getChildAssumingFolder('no-such-folder'); |
| 331 expect(children[2].shortName, 'c.txt'); | 341 expect(() { |
| 332 // check types | 342 folder.getChildren(); |
| 333 expect(children[0], _isFile); | 343 }, throwsA(_isFileSystemException)); |
| 334 expect(children[1], _isFolder); | 344 }); |
| 335 expect(children[2], _isFile); | |
| 336 }); | 345 }); |
| 337 | 346 |
| 338 test('parent', () { | 347 test('parent', () { |
| 339 Resource parent = folder.parent; | 348 Resource parent = folder.parent; |
| 340 expect(parent, new isInstanceOf<Folder>()); | 349 expect(parent, new isInstanceOf<Folder>()); |
| 341 expect(parent.path, equals(tempPath)); | 350 expect(parent.path, equals(tempPath)); |
| 342 | 351 |
| 343 // Since the OS is in control of where tempPath is, we don't know how | 352 // Since the OS is in control of where tempPath is, we don't know how |
| 344 // far it should be from the root. So just verify that each call to | 353 // far it should be from the root. So just verify that each call to |
| 345 // parent results in a a folder with a shorter path, and that we | 354 // parent results in a a folder with a shorter path, and that we |
| (...skipping 18 matching lines...) Expand all Loading... |
| 364 expect(folder.canonicalizePath(join(path2, '..', 'folder3')), | 373 expect(folder.canonicalizePath(join(path2, '..', 'folder3')), |
| 365 equals(path3)); | 374 equals(path3)); |
| 366 expect(folder.canonicalizePath(join('.', 'baz')), | 375 expect(folder.canonicalizePath(join('.', 'baz')), |
| 367 equals(join(path, 'baz'))); | 376 equals(join(path, 'baz'))); |
| 368 expect(folder.canonicalizePath(join(path2, '.', 'baz')), | 377 expect(folder.canonicalizePath(join(path2, '.', 'baz')), |
| 369 equals(join(path2, 'baz'))); | 378 equals(join(path2, 'baz'))); |
| 370 }); | 379 }); |
| 371 }); | 380 }); |
| 372 }); | 381 }); |
| 373 } | 382 } |
| OLD | NEW |