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

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

Issue 23953004: Throw FileExceptions when in File when reading as String and decoding fails. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | « sdk/lib/io/file_impl.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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "package:expect/expect.dart";
6 import "package:async_helper/async_helper.dart";
7 import 'dart:io';
8
9 void testReadAsString() {
10 var tmp = new Directory('').createTempSync();
11
12 var file = new File('${tmp.path}/file');
13 file.createSync();
14
15 file.writeAsBytesSync([0xb0]);
16
17 Expect.throws(file.readAsStringSync, (e) => e is FileException);
18
19 asyncStart();
20 file.readAsString().then((_) {
21 Expect.fail("expected exception");
22 }).catchError((e) {
23 tmp.deleteSync(recursive: true);
24 asyncEnd();
25 }, test: (e) => e is FileException);
26 }
27
28 void testReadAsLines() {
29 var tmp = new Directory('').createTempSync();
30
31 var file = new File('${tmp.path}/file');
32 file.createSync();
33
34 file.writeAsBytesSync([0xb0]);
35
36 Expect.throws(file.readAsLinesSync, (e) => e is FileException);
37
38 asyncStart();
39 file.readAsLines().then((_) {
40 Expect.fail("expected exception");
41 }).catchError((e) {
42 tmp.deleteSync(recursive: true);
43 asyncEnd();
44 }, test: (e) => e is FileException);
45 }
46
47 void main() {
48 testReadAsString();
49 testReadAsLines();
50 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698