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

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

Issue 1199283002: Fix bot failure: use platform specific separator (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 import "package:async_helper/async_helper.dart"; 10 import "package:async_helper/async_helper.dart";
(...skipping 17 matching lines...) Expand all
28 } 28 }
29 } 29 }
30 30
31 Future expectThrowsAsync(Future future, String message) { 31 Future expectThrowsAsync(Future future, String message) {
32 return future.then((r) => Expect.fail(message)) 32 return future.then((r) => Expect.fail(message))
33 .catchError((e) {}); 33 .catchError((e) {});
34 } 34 }
35 35
36 36
37 Future write(Directory dir) async { 37 Future write(Directory dir) async {
38 var f = new File(dir.path + '/write'); 38 var f = new File("${dir.path}${Platform.pathSeparator}write");
39 var raf = await f.open(mode: WRITE_ONLY); 39 var raf = await f.open(mode: WRITE_ONLY);
40 await raf.writeString('Hello'); 40 await raf.writeString('Hello');
41 await raf.setPosition(0); 41 await raf.setPosition(0);
42 await raf.writeString('Hello'); 42 await raf.writeString('Hello');
43 await raf.setPosition(0); 43 await raf.setPosition(0);
44 await expectThrowsAsync( 44 await expectThrowsAsync(
45 raf.readByte(), 'Read from write only file succeeded'); 45 raf.readByte(), 'Read from write only file succeeded');
46 await raf.close(); 46 await raf.close();
47 raf = await f.open(mode: WRITE_ONLY_APPEND); 47 raf = await f.open(mode: WRITE_ONLY_APPEND);
48 await raf.writeString('Hello'); 48 await raf.writeString('Hello');
49 await expectThrowsAsync( 49 await expectThrowsAsync(
50 raf.readByte(), 'Read from write only file succeeded'); 50 raf.readByte(), 'Read from write only file succeeded');
51 await raf.setPosition(0); 51 await raf.setPosition(0);
52 await raf.writeString('Hello'); 52 await raf.writeString('Hello');
53 await raf.close(); 53 await raf.close();
54 Expect.equals(f.lengthSync(), 10); 54 Expect.equals(f.lengthSync(), 10);
55 } 55 }
56 56
57 void writeSync(Directory dir) { 57 void writeSync(Directory dir) {
58 var f = new File(dir.path + '/write_sync'); 58 var f = new File("${dir.path}${Platform.pathSeparator}write_sync");
59 var raf = f.openSync(mode: WRITE_ONLY); 59 var raf = f.openSync(mode: WRITE_ONLY);
60 raf.writeStringSync('Hello'); 60 raf.writeStringSync('Hello');
61 raf.setPositionSync(0); 61 raf.setPositionSync(0);
62 raf.writeStringSync('Hello'); 62 raf.writeStringSync('Hello');
63 raf.setPositionSync(0); 63 raf.setPositionSync(0);
64 Expect.throws(() => raf.readByteSync()); 64 Expect.throws(() => raf.readByteSync());
65 raf.close(); 65 raf.close();
66 } 66 }
67 67
68 Future openWrite(Directory dir) async { 68 Future openWrite(Directory dir) async {
69 var f = new File(dir.path + '/open_write'); 69 var f = new File("${dir.path}${Platform.pathSeparator}open_write");
70 var sink = f.openWrite(mode: WRITE_ONLY); 70 var sink = f.openWrite(mode: WRITE_ONLY);
71 sink.write('Hello'); 71 sink.write('Hello');
72 await sink.close(); 72 await sink.close();
73 sink = await f.openWrite(mode: WRITE_ONLY_APPEND); 73 sink = await f.openWrite(mode: WRITE_ONLY_APPEND);
74 sink.write('Hello'); 74 sink.write('Hello');
75 await sink.close(); 75 await sink.close();
76 Expect.equals(f.lengthSync(), 10); 76 Expect.equals(f.lengthSync(), 10);
77 } 77 }
78 78
79 main() async { 79 main() async {
80 asyncStart(); 80 asyncStart();
81 await withTempDir('file_write_only_test_1', write); 81 await withTempDir('file_write_only_test_1', write);
82 withTempDirSync('file_write_only_test_2', writeSync); 82 withTempDirSync('file_write_only_test_2', writeSync);
83 await withTempDir('file_write_only_test_3', openWrite); 83 await withTempDir('file_write_only_test_3', openWrite);
84 asyncEnd(); 84 asyncEnd();
85 } 85 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698