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

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

Issue 12609004: Change all File APIs to make the mode and encoding arguments named (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments and changed other use places Created 7 years, 9 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) 2012, 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 'dart:async';
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:isolate'; 7 import 'dart:isolate';
8 8
9 testWriteAsBytesSync(dir) { 9 testWriteAsBytesSync(dir) {
10 var f = new File('${dir.path}/bytes_sync.txt'); 10 var f = new File('${dir.path}/bytes_sync.txt');
11 var data = [50,50,50]; 11 var data = [50,50,50];
12 f.writeAsBytesSync(data); 12 f.writeAsBytesSync(data);
13 Expect.listEquals(data, f.readAsBytesSync()); 13 Expect.listEquals(data, f.readAsBytesSync());
14 f.writeAsBytesSync(data, FileMode.APPEND); 14 f.writeAsBytesSync(data, mode: FileMode.APPEND);
15 var expected = [50, 50, 50, 50, 50, 50]; 15 var expected = [50, 50, 50, 50, 50, 50];
16 Expect.listEquals(expected, f.readAsBytesSync()); 16 Expect.listEquals(expected, f.readAsBytesSync());
17 } 17 }
18 18
19 testWriteAsStringSync(dir) { 19 testWriteAsStringSync(dir) {
20 var f = new File('${dir.path}/string_sync.txt'); 20 var f = new File('${dir.path}/string_sync.txt');
21 var data = 'asdf'; 21 var data = 'asdf';
22 f.writeAsStringSync(data); 22 f.writeAsStringSync(data);
23 Expect.equals(data, f.readAsStringSync()); 23 Expect.equals(data, f.readAsStringSync());
24 f.writeAsStringSync(data, mode: FileMode.APPEND); 24 f.writeAsStringSync(data, mode: FileMode.APPEND);
25 Expect.equals('$data$data', f.readAsStringSync()); 25 Expect.equals('$data$data', f.readAsStringSync());
26 } 26 }
27 27
28 Future testWriteAsBytes(dir) { 28 Future testWriteAsBytes(dir) {
29 var completer = new Completer(); 29 var completer = new Completer();
30 var f = new File('${dir.path}/bytes.txt'); 30 var f = new File('${dir.path}/bytes.txt');
31 var data = [50,50,50]; 31 var data = [50,50,50];
32 f.writeAsBytes(data).then((file){ 32 f.writeAsBytes(data).then((file){
33 Expect.equals(f, file); 33 Expect.equals(f, file);
34 f.readAsBytes().then((bytes) { 34 f.readAsBytes().then((bytes) {
35 Expect.listEquals(data, bytes); 35 Expect.listEquals(data, bytes);
36 f.writeAsBytes(data, FileMode.APPEND).then((file) { 36 f.writeAsBytes(data, mode: FileMode.APPEND).then((file) {
37 Expect.equals(f, file); 37 Expect.equals(f, file);
38 f.readAsBytes().then((bytes) { 38 f.readAsBytes().then((bytes) {
39 var expected = [50, 50, 50, 50, 50, 50]; 39 var expected = [50, 50, 50, 50, 50, 50];
40 Expect.listEquals(expected, bytes); 40 Expect.listEquals(expected, bytes);
41 completer.complete(true); 41 completer.complete(true);
42 }); 42 });
43 }); 43 });
44 }); 44 });
45 }); 45 });
46 return completer.future; 46 return completer.future;
(...skipping 24 matching lines...) Expand all
71 var tempDir = new Directory('').createTempSync(); 71 var tempDir = new Directory('').createTempSync();
72 testWriteAsBytesSync(tempDir); 72 testWriteAsBytesSync(tempDir);
73 testWriteAsStringSync(tempDir); 73 testWriteAsStringSync(tempDir);
74 testWriteAsBytes(tempDir).then((_) { 74 testWriteAsBytes(tempDir).then((_) {
75 return testWriteAsString(tempDir); 75 return testWriteAsString(tempDir);
76 }).then((_) { 76 }).then((_) {
77 tempDir.deleteSync(recursive: true); 77 tempDir.deleteSync(recursive: true);
78 port.close(); 78 port.close();
79 }); 79 });
80 } 80 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_test.dart ('k') | tests/standalone/io/skipping_dart2js_compilations_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698