| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 // Directory listing test. | 5 // Directory listing test. |
| 6 | 6 |
| 7 class DirectoryTest { | 7 class DirectoryTest { |
| 8 static void testListing() { | 8 static void testListing() { |
| 9 bool listedDir = false; | 9 bool listedDir = false; |
| 10 bool listedFile = false; | 10 bool listedFile = false; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 if (os == "windows") { | 257 if (os == "windows") { |
| 258 return "*"; | 258 return "*"; |
| 259 } | 259 } |
| 260 return null; | 260 return null; |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 testCreateTempErrorSync() { | 264 testCreateTempErrorSync() { |
| 265 var location = illegalTempDirectoryLocation(); | 265 var location = illegalTempDirectoryLocation(); |
| 266 if (location != null) { | 266 if (location != null) { |
| 267 Expect.throws(new Directory(location).createTempSync()); | 267 bool exception = false; |
| 268 try { |
| 269 new Directory(location).createTempSync(); |
| 270 } catch(DirectoryException e) { |
| 271 exception = true; |
| 272 } |
| 273 Expect.isTrue(exception); |
| 268 } | 274 } |
| 269 } | 275 } |
| 270 | 276 |
| 271 | 277 |
| 272 testCreateTempError() { | 278 testCreateTempError() { |
| 273 var location = illegalTempDirectoryLocation(); | 279 var location = illegalTempDirectoryLocation(); |
| 274 if (location == null) return; | 280 if (location == null) return; |
| 275 | 281 |
| 276 var resultPort = new ReceivePort.singleShot(); | 282 var resultPort = new ReceivePort.singleShot(); |
| 277 resultPort.receive((String message, ignored) { | 283 resultPort.receive((String message, ignored) { |
| 278 Expect.equals("error", message); | 284 Expect.equals("error", message); |
| 279 }); | 285 }); |
| 280 | 286 |
| 281 Directory dir = new Directory(location); | 287 Directory dir = new Directory(location); |
| 282 dir.errorHandler = (error) { resultPort.toSendPort().send("error"); }; | 288 dir.errorHandler = (error) { resultPort.toSendPort().send("error"); }; |
| 283 dir.createTempHandler = () { resultPort.toSendPort().send("success"); }; | 289 dir.createTempHandler = () { resultPort.toSendPort().send("success"); }; |
| 284 dir.createTemp(); | 290 dir.createTemp(); |
| 285 } | 291 } |
| 286 | 292 |
| 287 | 293 |
| 288 main() { | 294 main() { |
| 289 DirectoryTest.testMain(); | 295 DirectoryTest.testMain(); |
| 290 NestedTempDirectoryTest.testMain(); | 296 NestedTempDirectoryTest.testMain(); |
| 291 testCreateTempErrorSync(); | 297 testCreateTempErrorSync(); |
| 292 testCreateTempError(); | 298 testCreateTempError(); |
| 293 } | 299 } |
| OLD | NEW |