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

Side by Side Diff: test/codegen/lib/convert/chunked_conversion_utf89_test.dart

Issue 2254883002: roll analyzer (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: update Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 4
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 import 'dart:convert'; 6 import 'dart:convert';
7 7
8 class MySink extends ChunkedConversionSink<String> { 8 class MySink extends ChunkedConversionSink<String> {
9 final Function _add; 9 final Function _add;
10 final Function _close; 10 final Function _close;
11 11
12 MySink(this._add, this._close); 12 MySink(this._add, this._close);
13 13
14 void add(x) { _add(x); } 14 void add(x) { _add(x); }
15 void close() { _close(); } 15 void close() { _close(); }
16 } 16 }
17 17
18 main() { 18 main() {
19 // Make sure the UTF-8 decoder works eagerly. 19 // Make sure the UTF-8 decoder works eagerly.
20 String lastString; 20 String lastString;
21 bool isClosed = false; 21 bool isClosed = false;
22 ChunkedConversionSink sink = new MySink((x) => lastString = x, 22 var sink = new MySink((x) => lastString = x,
23 () => isClosed = true); 23 () => isClosed = true);
24 var byteSink = new Utf8Decoder().startChunkedConversion(sink); 24 var byteSink = new Utf8Decoder().startChunkedConversion(sink);
25 byteSink.add("abc".codeUnits); 25 byteSink.add("abc".codeUnits);
26 Expect.equals("abc", lastString); 26 Expect.equals("abc", lastString);
27 byteSink.add([0x61, 0xc3]); // 'a' followed by first part of Î. 27 byteSink.add([0x61, 0xc3]); // 'a' followed by first part of Î.
28 Expect.equals("a", lastString); 28 Expect.equals("a", lastString);
29 byteSink.add([0x8e]); // second part of Î. 29 byteSink.add([0x8e]); // second part of Î.
30 Expect.equals("Î", lastString); 30 Expect.equals("Î", lastString);
31 Expect.isFalse(isClosed); 31 Expect.isFalse(isClosed);
32 byteSink.close(); 32 byteSink.close();
33 Expect.isTrue(isClosed); 33 Expect.isTrue(isClosed);
34 } 34 }
OLDNEW
« no previous file with comments | « test/codegen/lib/convert/chunked_conversion_utf87_test.dart ('k') | test/codegen/lib/convert/latin1_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698