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

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

Issue 18115002: Make writes consistent across socket and file synchronous/asynchronus writes in terms of truncation… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 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) 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 'dart:async'; 8 import 'dart:async';
9 import 'dart:collection'; 9 import 'dart:collection';
10 import 'dart:io'; 10 import 'dart:io';
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 final File file = new File(fileName); 522 final File file = new File(fileName);
523 file.create().then((ignore) { 523 file.create().then((ignore) {
524 file.open(mode: WRITE).then((RandomAccessFile openedFile) { 524 file.open(mode: WRITE).then((RandomAccessFile openedFile) {
525 // Write bytes from 0 to 7. 525 // Write bytes from 0 to 7.
526 openedFile.writeFrom([0], 0, 1); 526 openedFile.writeFrom([0], 0, 1);
527 openedFile.writeFrom(const [1], 0, 1); 527 openedFile.writeFrom(const [1], 0, 1);
528 openedFile.writeFrom(new MyListOfOneElement(2), 0, 1); 528 openedFile.writeFrom(new MyListOfOneElement(2), 0, 1);
529 var x = 12345678901234567890123456789012345678901234567890; 529 var x = 12345678901234567890123456789012345678901234567890;
530 var y = 12345678901234567890123456789012345678901234567893; 530 var y = 12345678901234567890123456789012345678901234567893;
531 openedFile.writeFrom([y - x], 0, 1); 531 openedFile.writeFrom([y - x], 0, 1);
532 openedFile.writeFrom([260], 0, 1); // 260 = 256 + 4 = 0x104. 532 openedFile.writeFrom([4], 0, 1);
Anders Johnsen 2013/06/28 05:21:48 If this is illegal now, please add a test for it.
siva 2013/06/28 18:44:56 Writing values > 255 throws an ArgumentError which
533 openedFile.writeFrom(const [261], 0, 1); 533 openedFile.writeFrom(const [5], 0, 1);
534 openedFile.writeFrom(new MyListOfOneElement(262), 0, 1); 534 openedFile.writeFrom(new MyListOfOneElement(6), 0, 1);
535 x = 12345678901234567890123456789012345678901234567890; 535 x = 12345678901234567890123456789012345678901234567890;
536 y = 12345678901234567890123456789012345678901234568153; 536 y = 12345678901234567890123456789012345678901234567897;
537 openedFile.writeFrom([y - x], 0, 1).then((ignore) { 537 openedFile.writeFrom([y - x], 0, 1).then((ignore) {
538 openedFile.close().then((ignore) { 538 openedFile.close().then((ignore) {
539 // Check the written bytes. 539 // Check the written bytes.
540 final File file2 = new File(fileName); 540 final File file2 = new File(fileName);
541 var openedFile2 = file2.openSync(); 541 var openedFile2 = file2.openSync();
542 var length = openedFile2.lengthSync(); 542 var length = openedFile2.lengthSync();
543 Expect.equals(8, length); 543 Expect.equals(8, length);
544 List data = new List(length); 544 List data = new List(length);
545 openedFile2.readIntoSync(data, 0, length); 545 openedFile2.readIntoSync(data, 0, length);
546 for (var i = 0; i < data.length; i++) { 546 for (var i = 0; i < data.length; i++) {
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after
1331 testWriteStringUtf8Sync(); 1331 testWriteStringUtf8Sync();
1332 testRename(); 1332 testRename();
1333 testRenameSync(); 1333 testRenameSync();
1334 }); 1334 });
1335 } 1335 }
1336 } 1336 }
1337 1337
1338 main() { 1338 main() {
1339 FileTest.testMain(); 1339 FileTest.testMain();
1340 } 1340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698