| OLD | NEW |
| 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 file I/O. | 5 // Dart test program for testing file I/O. |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("dart:isolate"); | 8 #import("dart:isolate"); |
| 9 | 9 |
| 10 class MyListOfOneElement implements List { | 10 class MyListOfOneElement implements List { |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 static void testOpenDirectoryAsFileSync() { | 970 static void testOpenDirectoryAsFileSync() { |
| 971 var f = new File('.'); | 971 var f = new File('.'); |
| 972 try { | 972 try { |
| 973 f.openSync(); | 973 f.openSync(); |
| 974 Expect.fail("Expected exception opening directory as file"); | 974 Expect.fail("Expected exception opening directory as file"); |
| 975 } catch (var e) { | 975 } catch (var e) { |
| 976 Expect.isTrue(e is FileIOException); | 976 Expect.isTrue(e is FileIOException); |
| 977 } | 977 } |
| 978 } | 978 } |
| 979 | 979 |
| 980 static void testOpenFileFromPath() { |
| 981 var name = getFilename("tests/vm/data/fixed_length_file"); |
| 982 var path = new Path(name); |
| 983 var f = new File.fromPath(path); |
| 984 Expect.isTrue(f.existsSync()); |
| 985 name = f.fullPathSync(); |
| 986 path = new Path.fromNative(name); |
| 987 var g = new File.fromPath(path); |
| 988 Expect.isTrue(g.existsSync()); |
| 989 Expect.equals(name, g.fullPathSync()); |
| 990 } |
| 991 |
| 980 static void testReadAsBytes() { | 992 static void testReadAsBytes() { |
| 981 var port = new ReceivePort(); | 993 var port = new ReceivePort(); |
| 982 port.receive((result, replyTo) { | 994 port.receive((result, replyTo) { |
| 983 port.close(); | 995 port.close(); |
| 984 Expect.equals(42, result); | 996 Expect.equals(42, result); |
| 985 }); | 997 }); |
| 986 var name = getFilename("tests/vm/data/fixed_length_file"); | 998 var name = getFilename("tests/vm/data/fixed_length_file"); |
| 987 var f = new File(name); | 999 var f = new File(name); |
| 988 f.readAsBytes().then((bytes) { | 1000 f.readAsBytes().then((bytes) { |
| 989 Expect.isTrue(new String.fromCharCodes(bytes).endsWith("42 bytes.")); | 1001 Expect.isTrue(new String.fromCharCodes(bytes).endsWith("42 bytes.")); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 port = new ReceivePort(); | 1192 port = new ReceivePort(); |
| 1181 testRead(); | 1193 testRead(); |
| 1182 testReadSync(); | 1194 testReadSync(); |
| 1183 testReadStream(); | 1195 testReadStream(); |
| 1184 testLength(); | 1196 testLength(); |
| 1185 testLengthSync(); | 1197 testLengthSync(); |
| 1186 testPosition(); | 1198 testPosition(); |
| 1187 testPositionSync(); | 1199 testPositionSync(); |
| 1188 testOpenDirectoryAsFile(); | 1200 testOpenDirectoryAsFile(); |
| 1189 testOpenDirectoryAsFileSync(); | 1201 testOpenDirectoryAsFileSync(); |
| 1202 testOpenFileFromPath(); |
| 1190 testReadAsBytes(); | 1203 testReadAsBytes(); |
| 1191 testReadAsBytesSync(); | 1204 testReadAsBytesSync(); |
| 1192 testReadAsText(); | 1205 testReadAsText(); |
| 1193 testReadAsTextSync(); | 1206 testReadAsTextSync(); |
| 1194 testReadAsLines(); | 1207 testReadAsLines(); |
| 1195 testReadAsLinesSync(); | 1208 testReadAsLinesSync(); |
| 1196 testReadAsErrors(); | 1209 testReadAsErrors(); |
| 1197 testLastModified(); | 1210 testLastModified(); |
| 1198 testLastModifiedSync(); | 1211 testLastModifiedSync(); |
| 1199 | 1212 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1217 testWriteVariousLists(); | 1230 testWriteVariousLists(); |
| 1218 testDirectory(); | 1231 testDirectory(); |
| 1219 testDirectorySync(); | 1232 testDirectorySync(); |
| 1220 }); | 1233 }); |
| 1221 } | 1234 } |
| 1222 } | 1235 } |
| 1223 | 1236 |
| 1224 main() { | 1237 main() { |
| 1225 FileTest.testMain(); | 1238 FileTest.testMain(); |
| 1226 } | 1239 } |
| OLD | NEW |