| OLD | NEW |
| 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 import "dart:async"; |
| 5 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 6 import "dart:io"; | 7 import "dart:io"; |
| 7 import "dart:isolate"; | 8 import "dart:isolate"; |
| 8 | 9 |
| 9 void testReadInvalidArgs(arg) { | 10 void testReadInvalidArgs(arg) { |
| 10 var port = new ReceivePort(); | 11 var port = new ReceivePort(); |
| 11 String filename = getFilename("tests/vm/data/fixed_length_file"); | 12 String filename = getFilename("tests/vm/data/fixed_length_file"); |
| 12 var file = (new File(filename)).openSync(); | 13 var file = (new File(filename)).openSync(); |
| 13 try { | 14 try { |
| 14 file.readSync(arg); | 15 file.readSync(arg); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 Future futureThrows(Future result) { | 134 Future futureThrows(Future result) { |
| 134 return result.then((value) { | 135 return result.then((value) { |
| 135 throw new ExpectException( | 136 throw new ExpectException( |
| 136 "futureThrows received $value instead of an exception"); | 137 "futureThrows received $value instead of an exception"); |
| 137 }, | 138 }, |
| 138 onError: (_) => null | 139 onError: (_) => null |
| 139 ); | 140 ); |
| 140 } | 141 } |
| 141 | 142 |
| 142 void testFileSystemEntity() { | 143 void testFileSystemEntity() { |
| 143 Expect.throws(() => FileSystemEntity.typeSync([1,2,3])); | 144 Expect.throws(() => ((x) => FileSystemEntity.typeSync(x))([1,2,3])); |
| 144 Expect.throws(() => | 145 Expect.throws(() => ((x, y) => |
| 145 FileSystemEntity.typeSync(".", followLinks: "why not?")); | 146 FileSystemEntity.typeSync(x, followLinks: y))(".", "why not?")); |
| 146 Expect.throws(() => FileSystemEntity.identicalSync([1,2,3], ".")); | 147 Expect.throws(() => ((x, y) => |
| 147 Expect.throws(() => FileSystemEntity.identicalSync(".")); | 148 FileSystemEntity.identicalSync(x, y))([1,2,3], ".")); |
| 148 Expect.throws(() => FileSystemEntity.identicalSync(".", 52)); | 149 Expect.throws(() => ((x, y) => |
| 149 Expect.throws(() => FileSystemEntity.isLinkSync(52)); | 150 FileSystemEntity.identicalSync(x, y))(".", 52)); |
| 150 Expect.throws(() => FileSystemEntity.isFileSync(52)); | 151 Expect.throws(() => ((x) => FileSystemEntity.isLinkSync(x))(52)); |
| 151 Expect.throws(() => FileSystemEntity.isDirectorySync(52)); | 152 Expect.throws(() => ((x) => FileSystemEntity.isFileSync(x))(52)); |
| 153 Expect.throws(() => ((x) => FileSystemEntity.isDirectorySync(x))(52)); |
| 152 | 154 |
| 153 ReceivePort keepAlive = new ReceivePort(); | 155 ReceivePort keepAlive = new ReceivePort(); |
| 154 futureThrows(FileSystemEntity.type([1,2,3])) | 156 futureThrows(((x) => FileSystemEntity.type(x))([1,2,3])) |
| 155 .then((_) => futureThrows( | 157 .then((_) => futureThrows(((x, y) => |
| 156 FileSystemEntity.type(".", followLinks: "why not?"))) | 158 FileSystemEntity.type(x, followLinks: y))(".", "why not?"))) |
| 157 .then((_) => futureThrows(FileSystemEntity.identical([1,2,3], "."))) | 159 .then((_) => futureThrows(((x, y) => |
| 158 .then((_) => Expect.throws(() =>FileSystemEntity.identical("."))) | 160 FileSystemEntity.identical(x, y))([1,2,3], "."))) |
| 159 .then((_) => futureThrows(FileSystemEntity.identical(".", 52))) | 161 .then((_) => futureThrows(((x, y) => |
| 160 .then((_) => futureThrows(FileSystemEntity.isLink(52))) | 162 FileSystemEntity.identical(x, y))(".", 52))) |
| 161 .then((_) => futureThrows(FileSystemEntity.isFile(52))) | 163 .then((_) => futureThrows(((x) => FileSystemEntity.isLink(x))(52))) |
| 162 .then((_) => futureThrows(FileSystemEntity.isDirectory(52))) | 164 .then((_) => futureThrows(((x) => FileSystemEntity.isFile(x))(52))) |
| 165 .then((_) => futureThrows(((x) => FileSystemEntity.isDirectory(x))(52))) |
| 163 .then((_) => keepAlive.close()); | 166 .then((_) => keepAlive.close()); |
| 164 } | 167 } |
| 165 | 168 |
| 166 String getFilename(String path) { | 169 String getFilename(String path) { |
| 167 return new File(path).existsSync() ? path : 'runtime/$path'; | 170 return new File(path).existsSync() ? path : 'runtime/$path'; |
| 168 } | 171 } |
| 169 | 172 |
| 170 main() { | 173 main() { |
| 171 testReadInvalidArgs('asdf'); | 174 testReadInvalidArgs('asdf'); |
| 172 testReadIntoInvalidArgs(12, 0, 1); | 175 testReadIntoInvalidArgs(12, 0, 1); |
| 173 testReadIntoInvalidArgs(new List(10), '0', 1); | 176 testReadIntoInvalidArgs(new List(10), '0', 1); |
| 174 testReadIntoInvalidArgs(new List(10), 0, '1'); | 177 testReadIntoInvalidArgs(new List(10), 0, '1'); |
| 175 testWriteByteInvalidArgs('asdf'); | 178 testWriteByteInvalidArgs('asdf'); |
| 176 testWriteFromInvalidArgs(12, 0, 1); | 179 testWriteFromInvalidArgs(12, 0, 1); |
| 177 testWriteFromInvalidArgs(new List(10), '0', 1); | 180 testWriteFromInvalidArgs(new List(10), '0', 1); |
| 178 testWriteFromInvalidArgs(new List(10), 0, '1'); | 181 testWriteFromInvalidArgs(new List(10), 0, '1'); |
| 179 testWriteStringInvalidArgs("Hello, world", 42); | 182 testWriteStringInvalidArgs("Hello, world", 42); |
| 180 testFileSystemEntity(); | 183 testFileSystemEntity(); |
| 181 } | 184 } |
| OLD | NEW |