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

Unified Diff: tests/standalone/src/StringStreamTest.dart

Issue 8953030: Add input streams based on supplying data from lists (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: tests/standalone/src/StringStreamTest.dart
diff --git a/tests/standalone/src/StringStreamTest.dart b/tests/standalone/src/StringStreamTest.dart
index 7bb608290803750940938b9b76fee1645a3b9792..667b9b2954665abbadc416bcb9fdb81efea35eb8 100644
--- a/tests/standalone/src/StringStreamTest.dart
+++ b/tests/standalone/src/StringStreamTest.dart
@@ -2,43 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-class ListInputStream implements InputStream {
- List<int> read() {
- var result = _data;
- _data = null;
- return result;
- }
-
- void set dataHandler(void callback()) {
- _dataHandler = callback;
- }
-
- void set closeHandler(void callback()) {
- _closeHandler = callback;
- }
-
- void set errorHandler(void callback(int error)) {
- }
-
- void write(List<int> data) {
- Expect.equals(null, _data);
- _data = data;
- if (_dataHandler != null) {
- // Data handler is not called through the event loop here.
- _dataHandler();
- }
- }
-
- void close() {
- // Close handler is not called through the event loop here.
- if (_closeHandler != null) _closeHandler();
- }
-
- List<int> _data;
- var _dataHandler;
- var _closeHandler;
-}
-
void testUtf8() {
List<int> data = [0x01,
0x7f,
@@ -46,7 +9,7 @@ void testUtf8() {
0xdf, 0xbf,
0xe0, 0xa0, 0x80,
0xef, 0xbf, 0xbf];
- InputStream s = new ListInputStream();
+ InputStream s = new ListInputStream(data);
StringInputStream stream = new StringInputStream(s);
void stringData() {
String s = stream.read();
@@ -59,7 +22,6 @@ void testUtf8() {
Expect.equals(new String.fromCharCodes([0xffff]), s[5]);
}
stream.dataHandler = stringData;
- s.write(data);
}
void testLatin1() {
@@ -68,7 +30,7 @@ void testLatin1() {
0x44, 0x61, 0x72, 0x74,
0x80,
0xff];
- InputStream s = new ListInputStream();
+ InputStream s = new ListInputStream(data);
StringInputStream stream = new StringInputStream(s, "ISO-8859-1");
void stringData() {
String s = stream.read();
@@ -80,14 +42,13 @@ void testLatin1() {
Expect.equals(new String.fromCharCodes([0xff]), s[7]);
}
stream.dataHandler = stringData;
- s.write(data);
}
void testAscii() {
List<int> data = [0x01,
0x44, 0x61, 0x72, 0x74,
0x7f];
- InputStream s = new ListInputStream();
+ InputStream s = new ListInputStream(data);
StringInputStream stream = new StringInputStream(s, "ASCII");
void stringData() {
String s = stream.read();
@@ -97,11 +58,10 @@ void testAscii() {
Expect.equals(new String.fromCharCodes([0x7f]), s[5]);
}
stream.dataHandler = stringData;
- s.write(data);
}
void testReadLine1() {
- InputStream s = new ListInputStream();
+ InputStream s = new DynamicListInputStream();
StringInputStream stream = new StringInputStream(s);
var stage = 0;
@@ -111,7 +71,7 @@ void testReadLine1() {
line = stream.readLine();
Expect.equals(null, line);
stage++;
- s.close();
+ s.markEndOfStream();
} else if (stage == 1) {
line = stream.readLine();
Expect.equals("Line", line);
@@ -132,7 +92,7 @@ void testReadLine1() {
}
void testReadLine2() {
- InputStream s = new ListInputStream();
+ InputStream s = new DynamicListInputStream();
StringInputStream stream = new StringInputStream(s);
var stage = 0;
@@ -166,7 +126,7 @@ void testReadLine2() {
line = stream.readLine();
Expect.equals(null, line);
stage++;
- s.close();
+ s.markEndOfStream();
} else if (stage == 3) {
// The final \r can now be interpreted as an end of line.
line = stream.readLine();
« runtime/bin/stream_util.dart ('K') | « tests/standalone/src/ListInputStreamTest.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698