| 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.memory_file_system; | 5 library test.memory_file_system; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analyzer/file_system/file_system.dart'; | 9 import 'package:analyzer/file_system/file_system.dart'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; | 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 }); | 388 }); |
| 389 | 389 |
| 390 test('folder', () { | 390 test('folder', () { |
| 391 provider.newFolder('/foo/bar/foldername'); | 391 provider.newFolder('/foo/bar/foldername'); |
| 392 Folder child = folder.getChildAssumingFolder('foldername'); | 392 Folder child = folder.getChildAssumingFolder('foldername'); |
| 393 expect(child, isNotNull); | 393 expect(child, isNotNull); |
| 394 expect(child.exists, isTrue); | 394 expect(child.exists, isTrue); |
| 395 }); | 395 }); |
| 396 }); | 396 }); |
| 397 | 397 |
| 398 test('getChildren', () { | 398 group('getChildren', () { |
| 399 provider.newFile('/foo/bar/a.txt', 'aaa'); | 399 test('exists', () { |
| 400 provider.newFolder('/foo/bar/bFolder'); | 400 provider.newFile('/foo/bar/a.txt', 'aaa'); |
| 401 provider.newFile('/foo/bar/c.txt', 'ccc'); | 401 provider.newFolder('/foo/bar/bFolder'); |
| 402 // prepare 3 children | 402 provider.newFile('/foo/bar/c.txt', 'ccc'); |
| 403 List<Resource> children = folder.getChildren(); | 403 // prepare 3 children |
| 404 expect(children, hasLength(3)); | 404 List<Resource> children = folder.getChildren(); |
| 405 children.sort((a, b) => a.shortName.compareTo(b.shortName)); | 405 expect(children, hasLength(3)); |
| 406 // check that each child exists | 406 children.sort((a, b) => a.shortName.compareTo(b.shortName)); |
| 407 children.forEach((child) { | 407 // check that each child exists |
| 408 expect(child.exists, true); | 408 children.forEach((child) { |
| 409 expect(child.exists, true); |
| 410 }); |
| 411 // check names |
| 412 expect(children[0].shortName, 'a.txt'); |
| 413 expect(children[1].shortName, 'bFolder'); |
| 414 expect(children[2].shortName, 'c.txt'); |
| 415 // check types |
| 416 expect(children[0], _isFile); |
| 417 expect(children[1], _isFolder); |
| 418 expect(children[2], _isFile); |
| 409 }); | 419 }); |
| 410 // check names | 420 |
| 411 expect(children[0].shortName, 'a.txt'); | 421 test('does not exist', () { |
| 412 expect(children[1].shortName, 'bFolder'); | 422 folder = folder.getChildAssumingFolder('no-such-folder'); |
| 413 expect(children[2].shortName, 'c.txt'); | 423 expect(() { |
| 414 // check types | 424 folder.getChildren(); |
| 415 expect(children[0], _isFile); | 425 }, throwsA(_isFileSystemException)); |
| 416 expect(children[1], _isFolder); | 426 }); |
| 417 expect(children[2], _isFile); | |
| 418 }); | 427 }); |
| 419 | 428 |
| 420 test('parent', () { | 429 test('parent', () { |
| 421 Resource parent1 = folder.parent; | 430 Resource parent1 = folder.parent; |
| 422 expect(parent1, new isInstanceOf<Folder>()); | 431 expect(parent1, new isInstanceOf<Folder>()); |
| 423 expect(parent1.path, equals('/foo')); | 432 expect(parent1.path, equals('/foo')); |
| 424 Resource parent2 = parent1.parent; | 433 Resource parent2 = parent1.parent; |
| 425 expect(parent2, new isInstanceOf<Folder>()); | 434 expect(parent2, new isInstanceOf<Folder>()); |
| 426 expect(parent2.path, equals('/')); | 435 expect(parent2.path, equals('/')); |
| 427 expect(parent2.parent, isNull); | 436 expect(parent2.parent, isNull); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 | 554 |
| 546 test('resolveRelative', () { | 555 test('resolveRelative', () { |
| 547 Uri relative = | 556 Uri relative = |
| 548 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); | 557 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); |
| 549 expect(relative.path, '/foo/bar/baz.dart'); | 558 expect(relative.path, '/foo/bar/baz.dart'); |
| 550 }); | 559 }); |
| 551 }); | 560 }); |
| 552 }); | 561 }); |
| 553 }); | 562 }); |
| 554 } | 563 } |
| OLD | NEW |