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

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

Issue 10095009: Make it an error to call close twice on a file using the async API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « tests/standalone/src/io/FileErrorTest.dart ('k') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:io"); 5 #import("dart:io");
6 6
7 class FileTest { 7 class FileTest {
8 static void testOpenInvalidArgs(name) { 8 static void testOpenInvalidArgs(name) {
9 var file = new File(name); 9 var file = new File(name);
10 try { 10 try {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 file.readListSync(buffer, offset, length); 59 file.readListSync(buffer, offset, length);
60 Expect.fail('exception expected'); 60 Expect.fail('exception expected');
61 } catch (var e) { 61 } catch (var e) {
62 Expect.isTrue(e is FileIOException); 62 Expect.isTrue(e is FileIOException);
63 Expect.isTrue(e.toString().contains('Invalid arguments')); 63 Expect.isTrue(e.toString().contains('Invalid arguments'));
64 } 64 }
65 65
66 var errors = 0; 66 var errors = 0;
67 file.onError = (s) { 67 file.onError = (s) {
68 errors++; 68 errors++;
69 Expect.isTrue(s.contains('Invalid arguments')); 69 Expect.isTrue(s is FileIOException);
70 Expect.isTrue(s.toString().contains('Invalid arguments'));
70 file.close(() { 71 file.close(() {
71 Expect.equals(1, errors); 72 Expect.equals(1, errors);
72 }); 73 });
73 }; 74 };
74 file.readList(buffer, offset, length, (bytes) { 75 file.readList(buffer, offset, length, (bytes) {
75 Expect.fail('read list invalid arguments'); 76 Expect.fail('read list invalid arguments');
76 }); 77 });
77 } 78 }
78 79
79 static void testWriteByteInvalidArgs(value) { 80 static void testWriteByteInvalidArgs(value) {
80 String filename = getFilename("tests/vm/data/fixed_length_file"); 81 String filename = getFilename("tests/vm/data/fixed_length_file");
81 var file = (new File(filename + "_out")).openSync(FileMode.WRITE); 82 var file = (new File(filename + "_out")).openSync(FileMode.WRITE);
82 try { 83 try {
83 file.writeByteSync(value); 84 file.writeByteSync(value);
84 Expect.fail('exception expected'); 85 Expect.fail('exception expected');
85 } catch (var e) { 86 } catch (var e) {
86 Expect.isTrue(e is FileIOException); 87 Expect.isTrue(e is FileIOException);
87 Expect.isTrue(e.toString().contains('Invalid argument')); 88 Expect.isTrue(e.toString().contains('Invalid argument'));
88 } 89 }
89 90
90 var errors = 0; 91 var errors = 0;
91 file.onError = (s) { 92 file.onError = (s) {
92 errors++; 93 errors++;
93 Expect.isTrue(s.contains('Invalid argument')); 94 Expect.isTrue(s is FileIOException);
95 Expect.isTrue(s.toString().contains('Invalid argument'));
94 file.close(() { 96 file.close(() {
95 Expect.equals(1, errors); 97 Expect.equals(1, errors);
96 }); 98 });
97 }; 99 };
98 var calls = 0; 100 var calls = 0;
99 file.writeByte(value); 101 file.writeByte(value);
100 file.onNoPendingWrites = () { 102 file.onNoPendingWrites = () {
101 if (++calls > 1) Expect.fail('write list invalid argument'); 103 if (++calls > 1) Expect.fail('write list invalid argument');
102 }; 104 };
103 } 105 }
104 106
105 static void testWriteListInvalidArgs(buffer, offset, bytes) { 107 static void testWriteListInvalidArgs(buffer, offset, bytes) {
106 String filename = getFilename("tests/vm/data/fixed_length_file"); 108 String filename = getFilename("tests/vm/data/fixed_length_file");
107 var file = (new File(filename + "_out")).openSync(FileMode.WRITE); 109 var file = (new File(filename + "_out")).openSync(FileMode.WRITE);
108 try { 110 try {
109 file.writeListSync(buffer, offset, bytes); 111 file.writeListSync(buffer, offset, bytes);
110 Expect.fail('exception expected'); 112 Expect.fail('exception expected');
111 } catch (var e) { 113 } catch (var e) {
112 Expect.isTrue(e is FileIOException); 114 Expect.isTrue(e is FileIOException);
113 Expect.isTrue(e.toString().contains('Invalid arguments')); 115 Expect.isTrue(e.toString().contains('Invalid arguments'));
114 } 116 }
115 117
116 var errors = 0; 118 var errors = 0;
117 file.onError = (s) { 119 file.onError = (s) {
118 errors++; 120 errors++;
119 Expect.isTrue(s.contains('Invalid arguments')); 121 Expect.isTrue(s is FileIOException);
122 Expect.isTrue(s.toString().contains('Invalid arguments'));
120 file.close(() { 123 file.close(() {
121 Expect.equals(1, errors); 124 Expect.equals(1, errors);
122 }); 125 });
123 }; 126 };
124 var calls = 0; 127 var calls = 0;
125 file.writeList(buffer, offset, bytes); 128 file.writeList(buffer, offset, bytes);
126 file.onNoPendingWrites = () { 129 file.onNoPendingWrites = () {
127 if (++calls > 1) Expect.fail('write string invalid argument'); 130 if (++calls > 1) Expect.fail('write string invalid argument');
128 }; 131 };
129 } 132 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 FileTest.testCreateInvalidArgs(0); 186 FileTest.testCreateInvalidArgs(0);
184 FileTest.testReadListInvalidArgs(12, 0, 1); 187 FileTest.testReadListInvalidArgs(12, 0, 1);
185 FileTest.testReadListInvalidArgs(new List(10), '0', 1); 188 FileTest.testReadListInvalidArgs(new List(10), '0', 1);
186 FileTest.testReadListInvalidArgs(new List(10), 0, '1'); 189 FileTest.testReadListInvalidArgs(new List(10), 0, '1');
187 FileTest.testWriteByteInvalidArgs('asdf'); 190 FileTest.testWriteByteInvalidArgs('asdf');
188 FileTest.testWriteListInvalidArgs(12, 0, 1); 191 FileTest.testWriteListInvalidArgs(12, 0, 1);
189 FileTest.testWriteListInvalidArgs(new List(10), '0', 1); 192 FileTest.testWriteListInvalidArgs(new List(10), '0', 1);
190 FileTest.testWriteListInvalidArgs(new List(10), 0, '1'); 193 FileTest.testWriteListInvalidArgs(new List(10), 0, '1');
191 FileTest.testFullPathInvalidArgs(12); 194 FileTest.testFullPathInvalidArgs(12);
192 } 195 }
OLDNEW
« no previous file with comments | « tests/standalone/src/io/FileErrorTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698