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

Unified Diff: sdk/lib/io/string_stream.dart

Issue 11725007: Rewrite test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/standalone/io/string_decoder_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/string_stream.dart
diff --git a/sdk/lib/io/string_stream.dart b/sdk/lib/io/string_stream.dart
index 3140a3623f4c6e8d7dc848a149ec1d94b70bd27e..d3a698446cd1c63c8180121814c90581af074e0b 100644
--- a/sdk/lib/io/string_stream.dart
+++ b/sdk/lib/io/string_stream.dart
@@ -11,6 +11,8 @@ abstract class _StringDecoder {
// is transfered to the decoder and the caller most not modify it any more.
int write(List<int> buffer);
+ void done();
+
// Returns whether any decoded data is available.
bool get isEmpty;
@@ -88,6 +90,8 @@ abstract class _StringDecoderBase implements _StringDecoder {
return buffer.length;
}
+ void done() { }
+
bool get isEmpty => _result.isEmpty;
int get lineBreaks => _lineBreaks;
@@ -185,6 +189,12 @@ class _UTF8Decoder extends _StringDecoderBase {
static const kMaxCodePoint = 0x10FFFF;
static const kReplacementCodePoint = 0x3f;
+ void done() {
+ if (!_bufferList.isEmpty) {
+ _reportError(new DecoderException("Illegal UTF-8"));
+ }
+ }
+
void _reportError(error) {
if (onError != null) {
onError(error);
@@ -217,7 +227,7 @@ class _UTF8Decoder extends _StringDecoderBase {
value = value & 0x01;
additionalBytes = 5;
} else {
- _reportError(new DecoderException("Illegal UTF-8"));
+ return _reportError(new DecoderException("Illegal UTF-8"));
}
// Check if there are enough bytes to decode the character. Otherwise
// return false.
@@ -229,7 +239,7 @@ class _UTF8Decoder extends _StringDecoderBase {
for (int i = 0; i < additionalBytes; i++) {
int byte = _bufferList.next();
if ((byte & 0xc0) != 0x80) {
- _reportError(new DecoderException("Illegal UTF-8"));
+ return _reportError(new DecoderException("Illegal UTF-8"));
}
value = value << 6 | (byte & 0x3F);
}
@@ -477,6 +487,7 @@ class _StringInputStream implements StringInputStream {
void _onClosed() {
_inputClosed = true;
+ _decoder.done();
if (_decoder.isEmpty && _clientCloseHandler != null) {
_clientCloseHandler();
} else {
« no previous file with comments | « no previous file | tests/standalone/io/string_decoder_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698