Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(183)

Side by Side Diff: pkg/analyzer/test/file_system/memory_file_system_test.dart

Issue 940313003: Add File.modificationStamp accessor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 _isFolder = new isInstanceOf<Folder>(); 19 var _isFolder = new isInstanceOf<Folder>();
20 var _isMemoryResourceException = new isInstanceOf<MemoryResourceException>(); 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();
31 }); 31 });
32 32
33 test('MemoryResourceException', () { 33 test('FileSystemException', () {
34 var exception = new MemoryResourceException('/my/path', 'my message'); 34 var exception = new FileSystemException('/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( 37 expect(
38 exception.toString(), 38 exception.toString(),
39 'MemoryResourceException(path=/my/path; message=my message)'); 39 'FileSystemException(path=/my/path; message=my message)');
40 }); 40 });
41 41
42 group('Watch', () { 42 group('Watch', () {
43 43
44 Future delayed(computation()) { 44 Future delayed(computation()) {
45 return new Future.delayed(Duration.ZERO, computation); 45 return new Future.delayed(Duration.ZERO, computation);
46 } 46 }
47 47
48 watchingFolder(String path, test(List<WatchEvent> changesReceived)) { 48 watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
49 Folder folder = provider.getResource(path); 49 Folder folder = provider.getResource(path);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 expect(file1.hashCode, equals(file2.hashCode)); 274 expect(file1.hashCode, equals(file2.hashCode));
275 }); 275 });
276 276
277 test('isOrContains', () { 277 test('isOrContains', () {
278 String path = '/foo/bar/file.txt'; 278 String path = '/foo/bar/file.txt';
279 File file = provider.getResource(path); 279 File file = provider.getResource(path);
280 expect(file.isOrContains(path), isTrue); 280 expect(file.isOrContains(path), isTrue);
281 expect(file.isOrContains('/foo/bar'), isFalse); 281 expect(file.isOrContains('/foo/bar'), isFalse);
282 }); 282 });
283 283
284 group('modificationStamp', () {
285 test('exists', () {
286 String path = '/foo/bar/file.txt';
287 File file = provider.newFile(path, 'qwerty');
288 expect(file.modificationStamp, isNonNegative);
289 });
290
291 test('does not exist', () {
292 String path = '/foo/bar/file.txt';
293 File file = provider.newFile(path, 'qwerty');
294 provider.deleteFile(path);
295 expect(() {
296 file.modificationStamp;
297 }, throwsA(_isFileSystemException));
298 });
299 });
300
284 test('shortName', () { 301 test('shortName', () {
285 File file = provider.getResource('/foo/bar/file.txt'); 302 File file = provider.getResource('/foo/bar/file.txt');
286 expect(file.shortName, 'file.txt'); 303 expect(file.shortName, 'file.txt');
287 }); 304 });
288 305
289 test('toString', () { 306 test('toString', () {
290 File file = provider.getResource('/foo/bar/file.txt'); 307 File file = provider.getResource('/foo/bar/file.txt');
291 expect(file.toString(), '/foo/bar/file.txt'); 308 expect(file.toString(), '/foo/bar/file.txt');
292 }); 309 });
293 310
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 495
479 group('non-existent', () { 496 group('non-existent', () {
480 setUp(() { 497 setUp(() {
481 File file = provider.getResource('/foo/test.dart'); 498 File file = provider.getResource('/foo/test.dart');
482 source = file.createSource(); 499 source = file.createSource();
483 }); 500 });
484 501
485 test('contents', () { 502 test('contents', () {
486 expect(() { 503 expect(() {
487 source.contents; 504 source.contents;
488 }, throwsA(_isMemoryResourceException)); 505 }, throwsA(_isFileSystemException));
489 }); 506 });
490 507
491 test('encoding', () { 508 test('encoding', () {
492 expect(source.encoding, 'file:///foo/test.dart'); 509 expect(source.encoding, 'file:///foo/test.dart');
493 }); 510 });
494 511
495 test('exists', () { 512 test('exists', () {
496 expect(source.exists(), isFalse); 513 expect(source.exists(), isFalse);
497 }); 514 });
498 515
499 test('fullName', () { 516 test('fullName', () {
500 expect(source.fullName, '/foo/test.dart'); 517 expect(source.fullName, '/foo/test.dart');
501 }); 518 });
502 519
520 test('modificationStamp', () {
521 expect(source.modificationStamp, -1);
522 });
523
503 test('shortName', () { 524 test('shortName', () {
504 expect(source.shortName, 'test.dart'); 525 expect(source.shortName, 'test.dart');
505 }); 526 });
506 527
507 test('resolveRelative', () { 528 test('resolveRelative', () {
508 Uri relative = 529 Uri relative =
509 source.resolveRelativeUri(new Uri.file('bar/baz.dart')); 530 source.resolveRelativeUri(new Uri.file('bar/baz.dart'));
510 expect(relative.path, '/foo/bar/baz.dart'); 531 expect(relative.path, '/foo/bar/baz.dart');
511 }); 532 });
512 }); 533 });
513 }); 534 });
514 }); 535 });
515 } 536 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698