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

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

Issue 8318009: Update the streams interfaces (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Starting implementation Created 9 years, 2 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class ListInputStream implements InputStream2 {
6 List<int> read() {
7 var result = _data;
8 _data = null;
9 return result;
10 }
11
12 void set dataHandler(void callback()) {
13 _datahandler = callback;
14 }
15
16 void set closeHandler(void callback()) {
17 }
18
19 void set errorHandler(void callback(int error)) {
20 }
21
22 write(List<int> data) {
23 Expect.equals(null, _data);
24 _data = data;
25 if (_datahandler != null) {
26 _datahandler();
27 }
28 }
29
30 List<int> _data;
31 var _datahandler;
32 }
33
34
35 main() {
36 List<int> data = [0x01,
37 0x7f,
38 0xc2, 0x80,
39 0xdf, 0xbf,
40 0xe0, 0xa0, 0x80,
41 0xef, 0xbf, 0xbf];
42 InputStream2 s = new ListInputStream();
43 StringInputStream stream = new StringInputStream(s);
44 void stringData() {
45 String s = stream.read();
46 Expect.equals(6, s.length);
47 Expect.equals(new String.fromCharCodes([0x01]), s[0]);
48 Expect.equals(new String.fromCharCodes([0x7f]), s[1]);
49 Expect.equals(new String.fromCharCodes([0x80]), s[2]);
50 Expect.equals(new String.fromCharCodes([0x7ff]), s[3]);
51 Expect.equals(new String.fromCharCodes([0x800]), s[4]);
52 Expect.equals(new String.fromCharCodes([0xffff]), s[5]);
53 }
54 stream.dataHandler = stringData;
55 s.write(data);
56 }
OLDNEW
« runtime/bin/process.dart ('K') | « tests/standalone/src/ProcessStdoutTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698