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

Side by Side Diff: tests/standalone/io/parent_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // Dart test program for testing file I/O. 5 // Dart test program for testing file I/O.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:io'; 10 import 'dart:io';
11 11
12 import "package:async_helper/async_helper.dart"; 12 import "package:async_helper/async_helper.dart";
13 import "package:expect/expect.dart"; 13 import "package:expect/expect.dart";
14 import "package:path/path.dart"; 14 import "package:path/path.dart";
15 15
16 String tempDirectory; 16 String tempDirectory;
17 17
18 void main() { 18 void main() {
19 if (Platform.isWindows) { 19 if (Platform.isWindows) {
20 testWindowsCases(); 20 testWindowsCases();
21 } else { 21 } else {
22 testPosixCases(); 22 testPosixCases();
23 } 23 }
24 asyncStart(); 24 asyncStart();
25 createTempDirectories() 25 createTempDirectories().then(testObjects).whenComplete(() {
26 .then(testObjects) 26 asyncEnd();
27 .whenComplete(() { 27 new Directory(tempDirectory).delete(recursive: true);
28 asyncEnd(); 28 });
29 new Directory(tempDirectory).delete(recursive: true);
30 });
31 } 29 }
32 30
33 testPosixCases() { 31 testPosixCases() {
34 Expect.equals('/dir', FileSystemEntity.parentOf('/dir/file')); 32 Expect.equals('/dir', FileSystemEntity.parentOf('/dir/file'));
35 Expect.equals('/dir', FileSystemEntity.parentOf('/dir/file/')); 33 Expect.equals('/dir', FileSystemEntity.parentOf('/dir/file/'));
36 Expect.equals('/dir', FileSystemEntity.parentOf('/dir//file//')); 34 Expect.equals('/dir', FileSystemEntity.parentOf('/dir//file//'));
37 Expect.equals('/', FileSystemEntity.parentOf('/dir')); 35 Expect.equals('/', FileSystemEntity.parentOf('/dir'));
38 Expect.equals('/', FileSystemEntity.parentOf('/dir///')); 36 Expect.equals('/', FileSystemEntity.parentOf('/dir///'));
39 Expect.equals('/', FileSystemEntity.parentOf('/')); 37 Expect.equals('/', FileSystemEntity.parentOf('/'));
40 38
41 Expect.equals('.', FileSystemEntity.parentOf('file')); 39 Expect.equals('.', FileSystemEntity.parentOf('file'));
42 Expect.equals('.', FileSystemEntity.parentOf('file//')); 40 Expect.equals('.', FileSystemEntity.parentOf('file//'));
43 Expect.equals('.', FileSystemEntity.parentOf('')); 41 Expect.equals('.', FileSystemEntity.parentOf(''));
44 Expect.equals('.', FileSystemEntity.parentOf('..')); 42 Expect.equals('.', FileSystemEntity.parentOf('..'));
45 Expect.equals('.', FileSystemEntity.parentOf('.')); 43 Expect.equals('.', FileSystemEntity.parentOf('.'));
46 Expect.equals('.', FileSystemEntity.parentOf('')); 44 Expect.equals('.', FileSystemEntity.parentOf(''));
47 Expect.equals('/', FileSystemEntity.parentOf('/')); 45 Expect.equals('/', FileSystemEntity.parentOf('/'));
48 Expect.equals('/', FileSystemEntity.parentOf('//')); 46 Expect.equals('/', FileSystemEntity.parentOf('//'));
49 Expect.equals('/', FileSystemEntity.parentOf('//file///')); 47 Expect.equals('/', FileSystemEntity.parentOf('//file///'));
50 Expect.equals('dir', FileSystemEntity.parentOf('dir/file')); 48 Expect.equals('dir', FileSystemEntity.parentOf('dir/file'));
51 Expect.equals('dir', FileSystemEntity.parentOf('dir/file/')); 49 Expect.equals('dir', FileSystemEntity.parentOf('dir/file/'));
52 Expect.equals('dir', FileSystemEntity.parentOf('dir/file//')); 50 Expect.equals('dir', FileSystemEntity.parentOf('dir/file//'));
53 Expect.equals('dir/subdir', FileSystemEntity.parentOf('dir/subdir/file')); 51 Expect.equals('dir/subdir', FileSystemEntity.parentOf('dir/subdir/file'));
54 Expect.equals('dir//subdir', FileSystemEntity.parentOf('dir//subdir//file/')); 52 Expect.equals('dir//subdir', FileSystemEntity.parentOf('dir//subdir//file/'));
55 Expect.equals('dir/sub.dir', 53 Expect.equals(
56 FileSystemEntity.parentOf('dir/sub.dir/fi le///')); 54 'dir/sub.dir', FileSystemEntity.parentOf('dir/sub.dir/fi le///'));
57 Expect.equals('dir/..', FileSystemEntity.parentOf('dir/../file/')); 55 Expect.equals('dir/..', FileSystemEntity.parentOf('dir/../file/'));
58 Expect.equals('dir/..', FileSystemEntity.parentOf('dir/../..')); 56 Expect.equals('dir/..', FileSystemEntity.parentOf('dir/../..'));
59 Expect.equals('.', FileSystemEntity.parentOf('./..')); 57 Expect.equals('.', FileSystemEntity.parentOf('./..'));
60 Expect.equals('..', FileSystemEntity.parentOf('../.')); 58 Expect.equals('..', FileSystemEntity.parentOf('../.'));
61 } 59 }
62 60
63 testWindowsCases() { 61 testWindowsCases() {
64 Expect.equals(r'C:/dir', FileSystemEntity.parentOf(r'C:/dir/file')); 62 Expect.equals(r'C:/dir', FileSystemEntity.parentOf(r'C:/dir/file'));
65 Expect.equals(r'C:/dir', FileSystemEntity.parentOf(r'C:/dir/file/')); 63 Expect.equals(r'C:/dir', FileSystemEntity.parentOf(r'C:/dir/file/'));
66 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\file')); 64 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\file'));
67 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\file\')); 65 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\file\'));
68 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\\file\\')); 66 Expect.equals(r'C:\dir', FileSystemEntity.parentOf(r'C:\dir\\file\\'));
69 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\dir')); 67 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\dir'));
70 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\dir\/\')); 68 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\dir\/\'));
71 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\')); 69 Expect.equals(r'C:\', FileSystemEntity.parentOf(r'C:\'));
72 // FileSystemEntity.isAbsolute returns false for 'C:'. 70 // FileSystemEntity.isAbsolute returns false for 'C:'.
73 Expect.equals(r'.', FileSystemEntity.parentOf(r'C:')); 71 Expect.equals(r'.', FileSystemEntity.parentOf(r'C:'));
74 72
75 Expect.equals(r'\\server\share\dir', 73 Expect.equals(r'\\server\share\dir',
76 FileSystemEntity.parentOf(r'\\server\share\dir\file')); 74 FileSystemEntity.parentOf(r'\\server\share\dir\file'));
77 Expect.equals(r'\\server\share\dir', 75 Expect.equals(r'\\server\share\dir',
78 FileSystemEntity.parentOf(r'\\server\share\dir\file\')); 76 FileSystemEntity.parentOf(r'\\server\share\dir\file\'));
79 Expect.equals(r'\\server\share', 77 Expect.equals(
80 FileSystemEntity.parentOf(r'\\server\share\file')); 78 r'\\server\share', FileSystemEntity.parentOf(r'\\server\share\file'));
81 Expect.equals(r'\\server\', 79 Expect.equals(r'\\server\', FileSystemEntity.parentOf(r'\\server\share'));
82 FileSystemEntity.parentOf(r'\\server\share')); 80 Expect.equals(r'\\server\', FileSystemEntity.parentOf(r'\\server\share\'));
83 Expect.equals(r'\\server\', 81 Expect.equals(r'\\server\', FileSystemEntity.parentOf(r'\\server\'));
84 FileSystemEntity.parentOf(r'\\server\share\')); 82 Expect.equals(r'\\server/', FileSystemEntity.parentOf(r'\\server/'));
85 Expect.equals(r'\\server\', 83 Expect.equals(r'\\serve', FileSystemEntity.parentOf(r'\\serve'));
86 FileSystemEntity.parentOf(r'\\server\'));
87 Expect.equals(r'\\server/',
88 FileSystemEntity.parentOf(r'\\server/'));
89 Expect.equals(r'\\serve',
90 FileSystemEntity.parentOf(r'\\serve'));
91 84
92 Expect.equals(r'.', FileSystemEntity.parentOf(r'file')); 85 Expect.equals(r'.', FileSystemEntity.parentOf(r'file'));
93 Expect.equals(r'.', FileSystemEntity.parentOf(r'')); 86 Expect.equals(r'.', FileSystemEntity.parentOf(r''));
94 Expect.equals(r'.', FileSystemEntity.parentOf(r'..')); 87 Expect.equals(r'.', FileSystemEntity.parentOf(r'..'));
95 Expect.equals(r'.', FileSystemEntity.parentOf(r'.')); 88 Expect.equals(r'.', FileSystemEntity.parentOf(r'.'));
96 Expect.equals(r'.', FileSystemEntity.parentOf(r'')); 89 Expect.equals(r'.', FileSystemEntity.parentOf(r''));
97 Expect.equals(r'/', FileSystemEntity.parentOf(r'/')); 90 Expect.equals(r'/', FileSystemEntity.parentOf(r'/'));
98 Expect.equals(r'\', FileSystemEntity.parentOf(r'\')); 91 Expect.equals(r'\', FileSystemEntity.parentOf(r'\'));
99 Expect.equals(r'\', FileSystemEntity.parentOf(r'\file\\/')); 92 Expect.equals(r'\', FileSystemEntity.parentOf(r'\file\\/'));
100 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir\file')); 93 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir\file'));
101 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir\file\')); 94 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir\file\'));
102 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir/file/')); 95 Expect.equals(r'dir', FileSystemEntity.parentOf(r'dir/file/'));
103 Expect.equals(r'dir\subdir', FileSystemEntity.parentOf(r'dir\subdir\file')); 96 Expect.equals(r'dir\subdir', FileSystemEntity.parentOf(r'dir\subdir\file'));
104 Expect.equals(r'dir\sub.dir', 97 Expect.equals(
105 FileSystemEntity.parentOf(r'dir\sub.dir\fi le')); 98 r'dir\sub.dir', FileSystemEntity.parentOf(r'dir\sub.dir\fi le'));
106 } 99 }
107 100
108 Future createTempDirectories() { 101 Future createTempDirectories() {
109 return Directory.systemTemp.createTemp('dart_parent_').then((dir) { 102 return Directory.systemTemp
110 tempDirectory = dir.path; 103 .createTemp('dart_parent_')
111 }).then((_) => new File(join(tempDirectory, 'file1')).create()) 104 .then((dir) {
112 .then((_) => new Link(join(tempDirectory, 'link1')).create('.')) 105 tempDirectory = dir.path;
113 .then((_) => new Directory(join(tempDirectory, 'dir1')).create()); 106 })
107 .then((_) => new File(join(tempDirectory, 'file1')).create())
108 .then((_) => new Link(join(tempDirectory, 'link1')).create('.'))
109 .then((_) => new Directory(join(tempDirectory, 'dir1')).create());
114 } 110 }
115 111
116 testObjects(var ignored) { 112 testObjects(var ignored) {
117 ['file1', 'link1', 'dir1', 'file2', 'link2', 'dir2'].map(testPath); 113 ['file1', 'link1', 'dir1', 'file2', 'link2', 'dir2'].map(testPath);
118 } 114 }
119 115
120 testPath(String path) { 116 testPath(String path) {
121 Expect.equals(tempDirectory, 117 Expect.equals(tempDirectory, new File(join(tempDirectory, path)).parent.path);
122 new File(join(tempDirectory, path)).parent.path); 118 Expect.equals(tempDirectory, new Link(join(tempDirectory, path)).parent.path);
123 Expect.equals(tempDirectory, 119 Expect.equals(
124 new Link(join(tempDirectory, path)).parent.path); 120 tempDirectory, new Directory(join(tempDirectory, path)).parent.path);
125 Expect.equals(tempDirectory,
126 new Directory(join(tempDirectory, path)).parent.path);
127 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698