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

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

Issue 2067613002: Add Resource.delete() method. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
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 analyzer.test.file_system.memory_file_system_test; 5 library analyzer.test.file_system.memory_file_system_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 9
10 import 'package:analyzer/file_system/file_system.dart'; 10 import 'package:analyzer/file_system/file_system.dart';
(...skipping 30 matching lines...) Expand all
41 expect(exception.message, 'my message'); 41 expect(exception.message, 'my message');
42 expect(exception.toString(), 42 expect(exception.toString(),
43 'FileSystemException(path=/my/path; message=my message)'); 43 'FileSystemException(path=/my/path; message=my message)');
44 } 44 }
45 } 45 }
46 46
47 @reflectiveTest 47 @reflectiveTest
48 class FileTest { 48 class FileTest {
49 MemoryResourceProvider provider = new MemoryResourceProvider(); 49 MemoryResourceProvider provider = new MemoryResourceProvider();
50 50
51 void test_delete() {
52 File file = provider.newFile('/foo/file.txt', 'content');
53 expect(file.exists, isTrue);
54 // delete
55 file.delete();
56 expect(file.exists, isFalse);
57 }
58
51 void test_equals_beforeAndAfterCreate() { 59 void test_equals_beforeAndAfterCreate() {
52 String path = '/file.txt'; 60 String path = '/file.txt';
53 File file1 = provider.getResource(path); 61 File file1 = provider.getResource(path);
54 provider.newFile(path, 'contents'); 62 provider.newFile(path, 'contents');
55 File file2 = provider.getResource(path); 63 File file2 = provider.getResource(path);
56 expect(file1 == file2, isTrue); 64 expect(file1 == file2, isTrue);
57 } 65 }
58 66
59 void test_equals_false() { 67 void test_equals_false() {
60 File fileA = provider.getResource('/fileA.txt'); 68 File fileA = provider.getResource('/fileA.txt');
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 expect(folder.canonicalizePath('/a/b/./c'), equals('/a/b/c')); 242 expect(folder.canonicalizePath('/a/b/./c'), equals('/a/b/c'));
235 } 243 }
236 244
237 void test_contains() { 245 void test_contains() {
238 expect(folder.contains('/foo/bar/aaa.txt'), isTrue); 246 expect(folder.contains('/foo/bar/aaa.txt'), isTrue);
239 expect(folder.contains('/foo/bar/aaa/bbb.txt'), isTrue); 247 expect(folder.contains('/foo/bar/aaa/bbb.txt'), isTrue);
240 expect(folder.contains('/baz.txt'), isFalse); 248 expect(folder.contains('/baz.txt'), isFalse);
241 expect(folder.contains('/foo/bar'), isFalse); 249 expect(folder.contains('/foo/bar'), isFalse);
242 } 250 }
243 251
252 void test_delete() {
253 Folder folder = provider.newFolder('/foo');
254 Folder barFolder = provider.newFolder('/foo/bar');
255 File aFile = provider.newFile('/foo/bar/a.txt', '');
256 File bFile = provider.newFile('/foo/b.txt', '');
257 expect(folder.exists, isTrue);
258 expect(barFolder.exists, isTrue);
259 expect(aFile.exists, isTrue);
260 expect(bFile.exists, isTrue);
261 // delete 'folder'
262 folder.delete();
263 expect(folder.exists, isFalse);
264 expect(barFolder.exists, isFalse);
265 expect(aFile.exists, isFalse);
266 expect(bFile.exists, isFalse);
267 }
268
244 void test_equal_false() { 269 void test_equal_false() {
245 String path2 = '/foo/baz'; 270 String path2 = '/foo/baz';
246 Folder folder2 = provider.newFolder(path2); 271 Folder folder2 = provider.newFolder(path2);
247 expect(folder == folder2, isFalse); 272 expect(folder == folder2, isFalse);
248 } 273 }
249 274
250 void test_equal_true() { 275 void test_equal_true() {
251 Folder folder2 = provider.getResource(path); 276 Folder folder2 = provider.getResource(path);
252 expect(folder == folder2, isTrue); 277 expect(folder == folder2, isTrue);
253 } 278 }
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 return new Future.delayed(Duration.ZERO, computation); 684 return new Future.delayed(Duration.ZERO, computation);
660 } 685 }
661 686
662 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) { 687 _watchingFolder(String path, test(List<WatchEvent> changesReceived)) {
663 Folder folder = provider.getResource(path); 688 Folder folder = provider.getResource(path);
664 var changesReceived = <WatchEvent>[]; 689 var changesReceived = <WatchEvent>[];
665 folder.changes.listen(changesReceived.add); 690 folder.changes.listen(changesReceived.add);
666 return test(changesReceived); 691 return test(changesReceived);
667 } 692 }
668 } 693 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698