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

Side by Side Diff: test/codegen/lib/convert/chunked_conversion_utf86_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 String decode(List<int> bytes) { 8 String decode(List<int> bytes) {
9 StringBuffer buffer = new StringBuffer(); 9 StringBuffer buffer = new StringBuffer();
10 ChunkedConversionSink stringSink = 10 var stringSink =
11 new StringConversionSink.fromStringSink(buffer); 11 new StringConversionSink.fromStringSink(buffer);
12 var byteSink = new Utf8Decoder().startChunkedConversion(stringSink); 12 var byteSink = new Utf8Decoder().startChunkedConversion(stringSink);
13 bytes.forEach((byte) { byteSink.add([byte]); }); 13 bytes.forEach((byte) { byteSink.add([byte]); });
14 byteSink.close(); 14 byteSink.close();
15 return buffer.toString(); 15 return buffer.toString();
16 } 16 }
17 17
18 String decodeAllowMalformed(List<int> bytes) { 18 String decodeAllowMalformed(List<int> bytes) {
19 StringBuffer buffer = new StringBuffer(); 19 StringBuffer buffer = new StringBuffer();
20 ChunkedConversionSink stringSink = 20 var stringSink =
21 new StringConversionSink.fromStringSink(buffer); 21 new StringConversionSink.fromStringSink(buffer);
22 var decoder = new Utf8Decoder(allowMalformed: true); 22 var decoder = new Utf8Decoder(allowMalformed: true);
23 var byteSink = decoder.startChunkedConversion(stringSink); 23 var byteSink = decoder.startChunkedConversion(stringSink);
24 bytes.forEach((byte) { byteSink.add([byte]); }); 24 bytes.forEach((byte) { byteSink.add([byte]); });
25 byteSink.close(); 25 byteSink.close();
26 return buffer.toString(); 26 return buffer.toString();
27 } 27 }
28 28
29 29
30 final TESTS = [ 30 final TESTS = [
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }); 120 });
121 121
122 for (var test in []..addAll(allTests)..addAll(allTests2)) { 122 for (var test in []..addAll(allTests)..addAll(allTests2)) {
123 List<int> bytes = test[0]; 123 List<int> bytes = test[0];
124 Expect.throws(() => decode(bytes), (e) => e is FormatException); 124 Expect.throws(() => decode(bytes), (e) => e is FormatException);
125 125
126 String expected = test[1]; 126 String expected = test[1];
127 Expect.equals(expected, decodeAllowMalformed(bytes)); 127 Expect.equals(expected, decodeAllowMalformed(bytes));
128 } 128 }
129 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698