| 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'; |
| 11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 12 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 13 import 'package:path/path.dart'; | 13 import 'package:path/path.dart'; |
| 14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 15 import 'package:watcher/watcher.dart'; | 15 import 'package:watcher/watcher.dart'; |
| 16 | 16 |
| 17 | 17 |
| 18 var _isFile = new isInstanceOf<File>(); | 18 var _isFile = new isInstanceOf<File>(); |
| 19 var _isFileSystemException = new isInstanceOf<FileSystemException>(); |
| 19 var _isFolder = new isInstanceOf<Folder>(); | 20 var _isFolder = new isInstanceOf<Folder>(); |
| 20 var _isFileSystemException = new isInstanceOf<FileSystemException>(); | |
| 21 | 21 |
| 22 | 22 |
| 23 main() { | 23 main() { |
| 24 groupSep = ' | '; | 24 groupSep = ' | '; |
| 25 | 25 |
| 26 group('MemoryResourceProvider', () { | 26 group('MemoryResourceProvider', () { |
| 27 MemoryResourceProvider provider; | 27 MemoryResourceProvider provider; |
| 28 | 28 |
| 29 setUp(() { | 29 setUp(() { |
| 30 provider = new MemoryResourceProvider(); | 30 provider = new MemoryResourceProvider(); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 }); | 370 }); |
| 371 | 371 |
| 372 test('folder', () { | 372 test('folder', () { |
| 373 provider.newFolder('/foo/bar/baz'); | 373 provider.newFolder('/foo/bar/baz'); |
| 374 Folder child = folder.getChild('baz'); | 374 Folder child = folder.getChild('baz'); |
| 375 expect(child, isNotNull); | 375 expect(child, isNotNull); |
| 376 expect(child.exists, isTrue); | 376 expect(child.exists, isTrue); |
| 377 }); | 377 }); |
| 378 }); | 378 }); |
| 379 | 379 |
| 380 group('getChildAssumingFolder', () { |
| 381 test('does not exist', () { |
| 382 Folder child = folder.getChildAssumingFolder('foldername'); |
| 383 expect(child, isNotNull); |
| 384 expect(child.exists, isFalse); |
| 385 }); |
| 386 |
| 387 test('file', () { |
| 388 provider.newFile('/foo/bar/foldername', 'content'); |
| 389 Folder child = folder.getChildAssumingFolder('foldername'); |
| 390 expect(child, isNotNull); |
| 391 expect(child.exists, isFalse); |
| 392 }); |
| 393 |
| 394 test('folder', () { |
| 395 provider.newFolder('/foo/bar/foldername'); |
| 396 Folder child = folder.getChildAssumingFolder('foldername'); |
| 397 expect(child, isNotNull); |
| 398 expect(child.exists, isTrue); |
| 399 }); |
| 400 }); |
| 401 |
| 380 test('getChildren', () { | 402 test('getChildren', () { |
| 381 provider.newFile('/foo/bar/a.txt', 'aaa'); | 403 provider.newFile('/foo/bar/a.txt', 'aaa'); |
| 382 provider.newFolder('/foo/bar/bFolder'); | 404 provider.newFolder('/foo/bar/bFolder'); |
| 383 provider.newFile('/foo/bar/c.txt', 'ccc'); | 405 provider.newFile('/foo/bar/c.txt', 'ccc'); |
| 384 // prepare 3 children | 406 // prepare 3 children |
| 385 List<Resource> children = folder.getChildren(); | 407 List<Resource> children = folder.getChildren(); |
| 386 expect(children, hasLength(3)); | 408 expect(children, hasLength(3)); |
| 387 children.sort((a, b) => a.shortName.compareTo(b.shortName)); | 409 children.sort((a, b) => a.shortName.compareTo(b.shortName)); |
| 388 // check that each child exists | 410 // check that each child exists |
| 389 children.forEach((child) { | 411 children.forEach((child) { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 549 |
| 528 test('resolveRelative', () { | 550 test('resolveRelative', () { |
| 529 Uri relative = | 551 Uri relative = |
| 530 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); | 552 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); |
| 531 expect(relative.path, '/foo/bar/baz.dart'); | 553 expect(relative.path, '/foo/bar/baz.dart'); |
| 532 }); | 554 }); |
| 533 }); | 555 }); |
| 534 }); | 556 }); |
| 535 }); | 557 }); |
| 536 } | 558 } |
| OLD | NEW |