| 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'; |
| 10 import 'package:analyzer/file_system/memory_file_system.dart'; |
| 9 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; | 11 import 'package:analyzer/src/generated/engine.dart' show TimestampedData; |
| 10 import 'package:analyzer/src/generated/source.dart'; | 12 import 'package:analyzer/src/generated/source.dart'; |
| 11 import 'package:path/path.dart'; | 13 import 'package:path/path.dart'; |
| 12 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
| 13 import 'package:watcher/watcher.dart'; | 15 import 'package:watcher/watcher.dart'; |
| 14 import 'package:analyzer/file_system/memory_file_system.dart'; | |
| 15 import 'package:analyzer/file_system/file_system.dart'; | |
| 16 | 16 |
| 17 | 17 |
| 18 var _isFile = new isInstanceOf<File>(); | 18 var _isFile = new isInstanceOf<File>(); |
| 19 var _isFolder = new isInstanceOf<Folder>(); | 19 var _isFolder = new isInstanceOf<Folder>(); |
| 20 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); | 20 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); |
| 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(); |
| 31 }); | 31 }); |
| 32 | 32 |
| 33 test('MemoryResourceException', () { | 33 test('MemoryResourceException', () { |
| 34 var exception = new MemoryResourceException('/my/path', 'my message'); | 34 var exception = new MemoryResourceException('/my/path', 'my message'); |
| 35 expect(exception.path, '/my/path'); | 35 expect(exception.path, '/my/path'); |
| 36 expect(exception.message, 'my message'); | 36 expect(exception.message, 'my message'); |
| 37 expect(exception.toString(), | 37 expect( |
| 38 exception.toString(), |
| 38 'MemoryResourceException(path=/my/path; message=my message)'); | 39 'MemoryResourceException(path=/my/path; message=my message)'); |
| 39 }); | 40 }); |
| 40 | 41 |
| 41 group('Watch', () { | 42 group('Watch', () { |
| 42 | 43 |
| 43 Future delayed(computation()) { | 44 Future delayed(computation()) { |
| 44 return new Future.delayed(Duration.ZERO, computation); | 45 return new Future.delayed(Duration.ZERO, computation); |
| 45 } | 46 } |
| 46 | 47 |
| 47 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { | 48 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 | 463 |
| 463 test('hashCode', () { | 464 test('hashCode', () { |
| 464 source.hashCode; | 465 source.hashCode; |
| 465 }); | 466 }); |
| 466 | 467 |
| 467 test('shortName', () { | 468 test('shortName', () { |
| 468 expect(source.shortName, 'test.dart'); | 469 expect(source.shortName, 'test.dart'); |
| 469 }); | 470 }); |
| 470 | 471 |
| 471 test('resolveRelative', () { | 472 test('resolveRelative', () { |
| 472 Uri relative = source.resolveRelativeUri(new Uri.file('bar/baz.dart'))
; | 473 Uri relative = |
| 474 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); |
| 473 expect(relative.path, '/foo/bar/baz.dart'); | 475 expect(relative.path, '/foo/bar/baz.dart'); |
| 474 }); | 476 }); |
| 475 }); | 477 }); |
| 476 | 478 |
| 477 group('non-existent', () { | 479 group('non-existent', () { |
| 478 setUp(() { | 480 setUp(() { |
| 479 File file = provider.getResource('/foo/test.dart'); | 481 File file = provider.getResource('/foo/test.dart'); |
| 480 source = file.createSource(); | 482 source = file.createSource(); |
| 481 }); | 483 }); |
| 482 | 484 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 496 | 498 |
| 497 test('fullName', () { | 499 test('fullName', () { |
| 498 expect(source.fullName, '/foo/test.dart'); | 500 expect(source.fullName, '/foo/test.dart'); |
| 499 }); | 501 }); |
| 500 | 502 |
| 501 test('shortName', () { | 503 test('shortName', () { |
| 502 expect(source.shortName, 'test.dart'); | 504 expect(source.shortName, 'test.dart'); |
| 503 }); | 505 }); |
| 504 | 506 |
| 505 test('resolveRelative', () { | 507 test('resolveRelative', () { |
| 506 Uri relative = source.resolveRelativeUri(new Uri.file('bar/baz.dart'))
; | 508 Uri relative = |
| 509 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); |
| 507 expect(relative.path, '/foo/bar/baz.dart'); | 510 expect(relative.path, '/foo/bar/baz.dart'); |
| 508 }); | 511 }); |
| 509 }); | 512 }); |
| 510 }); | 513 }); |
| 511 }); | 514 }); |
| 512 } | 515 } |
| OLD | NEW |