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

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

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments from ager@ Created 9 years, 1 month 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/EchoServerStreamTest.dart ('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 // Testing FileInputStream, VM-only, standalone test. 4 // Testing FileInputStream, VM-only, standalone test.
5 5
6
7 String callbackString = null;
8
9 callback(List<int> buffer) {
10 callbackString = new String.fromCharCodes(buffer);
11 }
12
13 // Helper method to be able to run the test from the runtime 6 // Helper method to be able to run the test from the runtime
14 // directory, or the top directory. 7 // directory, or the top directory.
15 String getFilename(String path) => 8 String getFilename(String path) =>
16 FileUtil.fileExists(path) ? path : '../' + path; 9 FileUtil.fileExists(path) ? path : '../' + path;
17 10
18 main() { 11 main() {
19 String fName = getFilename("tests/standalone/src/readuntil_test.dat"); 12 String fName = getFilename("tests/standalone/src/readuntil_test.dat");
20 // File contains "Hello Dart, wassup!" 13 // File contains "Hello Dart\nwassup!"
21 File file = new File(fName, false); 14 File file = new File(fName, false);
22 FileInputStream x = new FileInputStream(file); 15 StringInputStream x = new StringInputStream(file.inputStream);
23 x.readUntil("Dart".charCodes(), callback); 16 String line = x.readLine();
17 Expect.equals("Hello Dart", line);
24 file.close(); 18 file.close();
25 Expect.stringEquals("Hello Dart", callbackString); 19 line = x.readLine();
26 20 Expect.equals("wassup!", line);
27 callbackString = null;
28 file = new File(fName, false);
29 x = new FileInputStream(file);
30 x.readUntil("Darty".charCodes(), callback);
31 file.close();
32 Expect.isNull(callbackString);
33
34 file = new File(fName, false);
35 x = new FileInputStream(file);
36 x.readUntil("wassup!".charCodes(), callback);
37 file.close();
38 Expect.stringEquals("Hello Dart, wassup!", callbackString);
39 } 21 }
OLDNEW
« no previous file with comments | « tests/standalone/src/EchoServerStreamTest.dart ('k') | tests/standalone/src/FileTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698