| 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 // Dart test program for testing file I/O. | 5 // Dart test program for testing file I/O. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 8 import "package:path/path.dart"; |
| 8 import 'dart:async'; | 9 import 'dart:async'; |
| 9 import 'dart:collection'; | 10 import 'dart:collection'; |
| 10 import 'dart:io'; | 11 import 'dart:io'; |
| 11 import 'dart:isolate'; | 12 import 'dart:isolate'; |
| 12 | 13 |
| 13 class MyListOfOneElement | 14 class MyListOfOneElement |
| 14 extends Object with ListMixin<int> implements List<int> { | 15 extends Object with ListMixin<int> implements List<int> { |
| 15 int _value; | 16 int _value; |
| 16 MyListOfOneElement(this._value); | 17 MyListOfOneElement(this._value); |
| 17 int get length => 1; | 18 int get length => 1; |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 static void testOpenDirectoryAsFileSync() { | 920 static void testOpenDirectoryAsFileSync() { |
| 920 var f = new File('.'); | 921 var f = new File('.'); |
| 921 try { | 922 try { |
| 922 f.openSync(); | 923 f.openSync(); |
| 923 Expect.fail("Expected exception opening directory as file"); | 924 Expect.fail("Expected exception opening directory as file"); |
| 924 } catch (e) { | 925 } catch (e) { |
| 925 Expect.isTrue(e is FileException); | 926 Expect.isTrue(e is FileException); |
| 926 } | 927 } |
| 927 } | 928 } |
| 928 | 929 |
| 929 static void testOpenFileFromPath() { | 930 static void testOpenFile() { |
| 930 var name = getFilename("tests/vm/data/fixed_length_file"); | 931 var name = getFilename("tests/vm/data/fixed_length_file"); |
| 931 var path = new Path(name); | 932 var f = new File(name); |
| 932 var f = new File.fromPath(path); | |
| 933 Expect.isTrue(f.existsSync()); | 933 Expect.isTrue(f.existsSync()); |
| 934 name = f.fullPathSync(); | 934 name = f.fullPathSync(); |
| 935 path = new Path(name); | 935 var g = new File(name); |
| 936 var g = new File.fromPath(path); | |
| 937 Expect.isTrue(g.existsSync()); | 936 Expect.isTrue(g.existsSync()); |
| 938 Expect.equals(name, g.fullPathSync()); | 937 Expect.equals(name, g.fullPathSync()); |
| 939 } | 938 } |
| 940 | 939 |
| 941 static void testReadAsBytes() { | 940 static void testReadAsBytes() { |
| 942 var port = new ReceivePort(); | 941 var port = new ReceivePort(); |
| 943 port.receive((result, replyTo) { | 942 port.receive((result, replyTo) { |
| 944 port.close(); | 943 port.close(); |
| 945 Expect.equals(42, result); | 944 Expect.equals(42, result); |
| 946 }); | 945 }); |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 port = new ReceivePort(); | 1283 port = new ReceivePort(); |
| 1285 testRead(); | 1284 testRead(); |
| 1286 testReadSync(); | 1285 testReadSync(); |
| 1287 testReadStream(); | 1286 testReadStream(); |
| 1288 testLength(); | 1287 testLength(); |
| 1289 testLengthSync(); | 1288 testLengthSync(); |
| 1290 testPosition(); | 1289 testPosition(); |
| 1291 testPositionSync(); | 1290 testPositionSync(); |
| 1292 testOpenDirectoryAsFile(); | 1291 testOpenDirectoryAsFile(); |
| 1293 testOpenDirectoryAsFileSync(); | 1292 testOpenDirectoryAsFileSync(); |
| 1294 testOpenFileFromPath(); | 1293 testOpenFile(); |
| 1295 testReadAsBytes(); | 1294 testReadAsBytes(); |
| 1296 testReadAsBytesEmptyFile(); | 1295 testReadAsBytesEmptyFile(); |
| 1297 testReadAsBytesSync(); | 1296 testReadAsBytesSync(); |
| 1298 testReadAsBytesSyncEmptyFile(); | 1297 testReadAsBytesSyncEmptyFile(); |
| 1299 testReadAsText(); | 1298 testReadAsText(); |
| 1300 testReadAsTextEmptyFile(); | 1299 testReadAsTextEmptyFile(); |
| 1301 testReadAsTextSync(); | 1300 testReadAsTextSync(); |
| 1302 testReadAsTextSyncEmptyFile(); | 1301 testReadAsTextSyncEmptyFile(); |
| 1303 testReadAsLines(); | 1302 testReadAsLines(); |
| 1304 testReadAsLinesSync(); | 1303 testReadAsLinesSync(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1331 testWriteStringUtf8Sync(); | 1330 testWriteStringUtf8Sync(); |
| 1332 testRename(); | 1331 testRename(); |
| 1333 testRenameSync(); | 1332 testRenameSync(); |
| 1334 }); | 1333 }); |
| 1335 } | 1334 } |
| 1336 } | 1335 } |
| 1337 | 1336 |
| 1338 main() { | 1337 main() { |
| 1339 FileTest.testMain(); | 1338 FileTest.testMain(); |
| 1340 } | 1339 } |
| OLD | NEW |