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

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

Issue 10351011: Change Platform members to getters instead of methods. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new test binaries Created 8 years, 7 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 error handling in file I/O. 5 // Dart test program for testing error handling in file I/O.
6 6
7 #import("dart:io"); 7 #import("dart:io");
8 #import("dart:isolate"); 8 #import("dart:isolate");
9 9
10 Directory tempDir() { 10 Directory tempDir() {
11 var d = new Directory(''); 11 var d = new Directory('');
12 d.createTempSync(); 12 d.createTempSync();
13 return d; 13 return d;
14 } 14 }
15 15
16 16
17 bool checkNonExistentFileException(e, str) { 17 bool checkNonExistentFileException(e, str) {
18 Expect.isTrue(e is FileIOException); 18 Expect.isTrue(e is FileIOException);
19 Expect.isTrue(e.osError != null); 19 Expect.isTrue(e.osError != null);
20 Expect.isTrue(e.toString().indexOf(str) != -1); 20 Expect.isTrue(e.toString().indexOf(str) != -1);
21 if (Platform.operatingSystem() == "linux") { 21 if (Platform.operatingSystem == "linux") {
22 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 22 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
23 } else if (Platform.operatingSystem() == "macos") { 23 } else if (Platform.operatingSystem == "macos") {
24 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 24 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
25 } else if (Platform.operatingSystem() == "windows") { 25 } else if (Platform.operatingSystem == "windows") {
26 Expect.isTrue( 26 Expect.isTrue(
27 e.toString().indexOf( 27 e.toString().indexOf(
28 "The system cannot find the file specified") != -1); 28 "The system cannot find the file specified") != -1);
29 } 29 }
30 // File not not found has error code 2 on all supported platforms. 30 // File not not found has error code 2 on all supported platforms.
31 Expect.equals(2, e.osError.errorCode); 31 Expect.equals(2, e.osError.errorCode);
32 32
33 return true; 33 return true;
34 } 34 }
35 35
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 checkLengthNonExistentFileException(e); 109 checkLengthNonExistentFileException(e);
110 p.toSendPort().send(null); 110 p.toSendPort().send(null);
111 }; 111 };
112 } 112 }
113 113
114 114
115 bool checkCreateInNonExistentDirectoryException(e) { 115 bool checkCreateInNonExistentDirectoryException(e) {
116 Expect.isTrue(e is FileIOException); 116 Expect.isTrue(e is FileIOException);
117 Expect.isTrue(e.osError != null); 117 Expect.isTrue(e.osError != null);
118 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1); 118 Expect.isTrue(e.toString().indexOf("Cannot create file") != -1);
119 if (Platform.operatingSystem() == "linux") { 119 if (Platform.operatingSystem == "linux") {
120 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 120 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
121 Expect.equals(2, e.osError.errorCode); 121 Expect.equals(2, e.osError.errorCode);
122 } else if (Platform.operatingSystem() == "macos") { 122 } else if (Platform.operatingSystem == "macos") {
123 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 123 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
124 Expect.equals(2, e.osError.errorCode); 124 Expect.equals(2, e.osError.errorCode);
125 } else if (Platform.operatingSystem() == "windows") { 125 } else if (Platform.operatingSystem == "windows") {
126 Expect.isTrue( 126 Expect.isTrue(
127 e.toString().indexOf( 127 e.toString().indexOf(
128 "The system cannot find the path specified") != -1); 128 "The system cannot find the path specified") != -1);
129 Expect.equals(3, e.osError.errorCode); 129 Expect.equals(3, e.osError.errorCode);
130 } 130 }
131 131
132 return true; 132 return true;
133 } 133 }
134 134
135 void testCreateInNonExistentDirectory() { 135 void testCreateInNonExistentDirectory() {
(...skipping 13 matching lines...) Expand all
149 file.onError = (e) { 149 file.onError = (e) {
150 checkCreateInNonExistentDirectoryException(e); 150 checkCreateInNonExistentDirectoryException(e);
151 p.toSendPort().send(null); 151 p.toSendPort().send(null);
152 }; 152 };
153 } 153 }
154 154
155 bool checkFullPathOnNonExistentDirectoryException(e) { 155 bool checkFullPathOnNonExistentDirectoryException(e) {
156 Expect.isTrue(e is FileIOException); 156 Expect.isTrue(e is FileIOException);
157 Expect.isTrue(e.osError != null); 157 Expect.isTrue(e.osError != null);
158 Expect.isTrue(e.toString().indexOf("Cannot retrieve full path") != -1); 158 Expect.isTrue(e.toString().indexOf("Cannot retrieve full path") != -1);
159 if (Platform.operatingSystem() == "linux") { 159 if (Platform.operatingSystem == "linux") {
160 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 160 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
161 } else if (Platform.operatingSystem() == "macos") { 161 } else if (Platform.operatingSystem == "macos") {
162 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 162 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
163 } else if (Platform.operatingSystem() == "windows") { 163 } else if (Platform.operatingSystem == "windows") {
164 Expect.isTrue( 164 Expect.isTrue(
165 e.toString().indexOf( 165 e.toString().indexOf(
166 "The system cannot find the file specified") != -1); 166 "The system cannot find the file specified") != -1);
167 } 167 }
168 // File not not found has error code 2 on all supported platforms. 168 // File not not found has error code 2 on all supported platforms.
169 Expect.equals(2, e.osError.errorCode); 169 Expect.equals(2, e.osError.errorCode);
170 170
171 return true; 171 return true;
172 } 172 }
173 173
(...skipping 15 matching lines...) Expand all
189 checkFullPathOnNonExistentDirectoryException(e); 189 checkFullPathOnNonExistentDirectoryException(e);
190 p.toSendPort().send(null); 190 p.toSendPort().send(null);
191 }; 191 };
192 } 192 }
193 193
194 bool checkDirectoryInNonExistentDirectoryException(e) { 194 bool checkDirectoryInNonExistentDirectoryException(e) {
195 Expect.isTrue(e is FileIOException); 195 Expect.isTrue(e is FileIOException);
196 Expect.isTrue(e.osError != null); 196 Expect.isTrue(e.osError != null);
197 Expect.isTrue( 197 Expect.isTrue(
198 e.toString().indexOf("Cannot retrieve directory for file") != -1); 198 e.toString().indexOf("Cannot retrieve directory for file") != -1);
199 if (Platform.operatingSystem() == "linux") { 199 if (Platform.operatingSystem == "linux") {
200 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 200 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
201 } else if (Platform.operatingSystem() == "macos") { 201 } else if (Platform.operatingSystem == "macos") {
202 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1); 202 Expect.isTrue(e.toString().indexOf("No such file or directory") != -1);
203 } else if (Platform.operatingSystem() == "windows") { 203 } else if (Platform.operatingSystem == "windows") {
204 Expect.isTrue( 204 Expect.isTrue(
205 e.toString().indexOf( 205 e.toString().indexOf(
206 "The system cannot find the file specified") != -1); 206 "The system cannot find the file specified") != -1);
207 } 207 }
208 // File not not found has error code 2 on all supported platforms. 208 // File not not found has error code 2 on all supported platforms.
209 Expect.equals(2, e.osError.errorCode); 209 Expect.equals(2, e.osError.errorCode);
210 210
211 return true; 211 return true;
212 } 212 }
213 213
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 testDirectoryInNonExistentDirectory(); 456 testDirectoryInNonExistentDirectory();
457 testReadAsBytesNonExistent(); 457 testReadAsBytesNonExistent();
458 testReadAsTextNonExistent(); 458 testReadAsTextNonExistent();
459 testReadAsLinesNonExistent(); 459 testReadAsLinesNonExistent();
460 testWriteByteToReadOnlyFile(); 460 testWriteByteToReadOnlyFile();
461 testWriteListToReadOnlyFile(); 461 testWriteListToReadOnlyFile();
462 testTruncateReadOnlyFile(); 462 testTruncateReadOnlyFile();
463 testOperateOnClosedFile(); 463 testOperateOnClosedFile();
464 testRepeatedlyCloseFile(); 464 testRepeatedlyCloseFile();
465 } 465 }
OLDNEW
« no previous file with comments | « tests/standalone/io/directory_test.dart ('k') | tests/standalone/io/file_system_links_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698