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

Side by Side Diff: tests/standalone/src/FileInvalidArgumentsTest.dart

Issue 9034005: Change the behavior of open on files to not truncate by default (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comment.s Created 8 years, 11 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
« no previous file with comments | « runtime/bin/main.cc ('k') | tests/standalone/src/FileTest.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 class FileTest { 5 class FileTest {
6 static void testOpenInvalidArgs(name, [writable = false]) { 6 static void testOpenInvalidArgs(name, [writable = false]) {
7 var file = new File(name); 7 var file = new File(name);
8 try { 8 try {
9 file.openSync(); 9 file.openSync();
10 Expect.fail('exception expected'); 10 Expect.fail('exception expected');
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 }; 81 };
82 file.readList(buffer, offset, length); 82 file.readList(buffer, offset, length);
83 file.closeHandler = () { 83 file.closeHandler = () {
84 Expect.equals(1, errors); 84 Expect.equals(1, errors);
85 }; 85 };
86 file.close(); 86 file.close();
87 } 87 }
88 88
89 static void testWriteByteInvalidArgs(value) { 89 static void testWriteByteInvalidArgs(value) {
90 String filename = getFilename("tests/vm/data/fixed_length_file"); 90 String filename = getFilename("tests/vm/data/fixed_length_file");
91 var file = (new File(filename + "_out")).openSync(true); 91 var file = (new File(filename + "_out")).openSync(FileMode.WRITE);
92 try { 92 try {
93 file.writeByteSync(value); 93 file.writeByteSync(value);
94 Expect.fail('exception expected'); 94 Expect.fail('exception expected');
95 } catch (var e) { 95 } catch (var e) {
96 Expect.isTrue(e is FileIOException); 96 Expect.isTrue(e is FileIOException);
97 Expect.isTrue(e.toString().contains('Invalid argument')); 97 Expect.isTrue(e.toString().contains('Invalid argument'));
98 } 98 }
99 99
100 var errors = 0; 100 var errors = 0;
101 file.errorHandler = (s) { 101 file.errorHandler = (s) {
102 errors++; 102 errors++;
103 Expect.isTrue(s.contains('Invalid argument')); 103 Expect.isTrue(s.contains('Invalid argument'));
104 }; 104 };
105 file.noPendingWriteHandler = (bytes) { 105 file.noPendingWriteHandler = (bytes) {
106 Expect.fail('write list invalid argument'); 106 Expect.fail('write list invalid argument');
107 }; 107 };
108 file.writeByte(value); 108 file.writeByte(value);
109 file.closeHandler = () { 109 file.closeHandler = () {
110 Expect.equals(1, errors); 110 Expect.equals(1, errors);
111 }; 111 };
112 file.close(); 112 file.close();
113 } 113 }
114 114
115 static void testWriteListInvalidArgs(buffer, offset, bytes) { 115 static void testWriteListInvalidArgs(buffer, offset, bytes) {
116 String filename = getFilename("tests/vm/data/fixed_length_file"); 116 String filename = getFilename("tests/vm/data/fixed_length_file");
117 var file = (new File(filename + "_out")).openSync(true); 117 var file = (new File(filename + "_out")).openSync(FileMode.WRITE);
118 try { 118 try {
119 file.writeListSync(buffer, offset, bytes); 119 file.writeListSync(buffer, offset, bytes);
120 Expect.fail('exception expected'); 120 Expect.fail('exception expected');
121 } catch (var e) { 121 } catch (var e) {
122 Expect.isTrue(e is FileIOException); 122 Expect.isTrue(e is FileIOException);
123 Expect.isTrue(e.toString().contains('Invalid arguments')); 123 Expect.isTrue(e.toString().contains('Invalid arguments'));
124 } 124 }
125 125
126 var errors = 0; 126 var errors = 0;
127 file.errorHandler = (s) { 127 file.errorHandler = (s) {
128 errors++; 128 errors++;
129 Expect.isTrue(s.contains('Invalid arguments')); 129 Expect.isTrue(s.contains('Invalid arguments'));
130 }; 130 };
131 file.noPendingWriteHandler = (bytes) { 131 file.noPendingWriteHandler = (bytes) {
132 Expect.fail('write list invalid argument'); 132 Expect.fail('write list invalid argument');
133 }; 133 };
134 file.writeList(buffer, offset, bytes); 134 file.writeList(buffer, offset, bytes);
135 file.closeHandler = () { 135 file.closeHandler = () {
136 Expect.equals(1, errors); 136 Expect.equals(1, errors);
137 }; 137 };
138 file.close(); 138 file.close();
139 } 139 }
140 140
141 static void testWriteStringInvalidArgs(string) { 141 static void testWriteStringInvalidArgs(string) {
142 String filename = getFilename("tests/vm/data/fixed_length_file"); 142 String filename = getFilename("tests/vm/data/fixed_length_file");
143 var file = new File(filename + "_out"); 143 var file = new File(filename + "_out");
144 file.openSync(true); 144 file.openSync(FileMode.WRITE);
145 try { 145 try {
146 file.writeString(string); 146 file.writeString(string);
147 Expect.fail('exception expected'); 147 Expect.fail('exception expected');
148 } catch (var e) { 148 } catch (var e) {
149 Expect.isTrue(e is FileIOException); 149 Expect.isTrue(e is FileIOException);
150 Expect.isTrue(e.toString().contains('writeString failed')); 150 Expect.isTrue(e.toString().contains('writeString failed'));
151 } 151 }
152 152
153 var errors = 0; 153 var errors = 0;
154 file.errorHandler = (s) { 154 file.errorHandler = (s) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 FileTest.testCreateInvalidArgs(0); 195 FileTest.testCreateInvalidArgs(0);
196 FileTest.testReadListInvalidArgs(12, 0, 1); 196 FileTest.testReadListInvalidArgs(12, 0, 1);
197 FileTest.testReadListInvalidArgs(new List(10), '0', 1); 197 FileTest.testReadListInvalidArgs(new List(10), '0', 1);
198 FileTest.testReadListInvalidArgs(new List(10), 0, '1'); 198 FileTest.testReadListInvalidArgs(new List(10), 0, '1');
199 FileTest.testWriteByteInvalidArgs('asdf'); 199 FileTest.testWriteByteInvalidArgs('asdf');
200 FileTest.testWriteListInvalidArgs(12, 0, 1); 200 FileTest.testWriteListInvalidArgs(12, 0, 1);
201 FileTest.testWriteListInvalidArgs(new List(10), '0', 1); 201 FileTest.testWriteListInvalidArgs(new List(10), '0', 1);
202 FileTest.testWriteListInvalidArgs(new List(10), 0, '1'); 202 FileTest.testWriteListInvalidArgs(new List(10), 0, '1');
203 FileTest.testFullPathInvalidArgs(12); 203 FileTest.testFullPathInvalidArgs(12);
204 } 204 }
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | tests/standalone/src/FileTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698