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

Side by Side Diff: tests/lib/convert/json_utf8_chunk_test.dart

Issue 679143003: Fix test warnings and expect Safari mobile simulator bug. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test; 5 library test;
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 import "dart:convert"; 8 import "dart:convert";
9 import "unicode_tests.dart" show UNICODE_TESTS; 9 import "unicode_tests.dart" show UNICODE_TESTS;
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 var decoderSink = JSON.decoder.startChunkedConversion(sink) 197 var decoderSink = JSON.decoder.startChunkedConversion(sink)
198 .asUtf8Sink(true); 198 .asUtf8Sink(true);
199 try { 199 try {
200 action(decoderSink); 200 action(decoderSink);
201 } catch (e, s) { 201 } catch (e, s) {
202 Expect.fail("Unexpected throw ($tag): $e\n$s"); 202 Expect.fail("Unexpected throw ($tag): $e\n$s");
203 } 203 }
204 } 204 }
205 { // Not allowing malformed, expect throw. 205 { // Not allowing malformed, expect throw.
206 var sink = new ChunkedConversionSink.withCallback((values) { 206 var sink = new ChunkedConversionSink.withCallback((values) {
207 Expect.unreachable(tag); 207 Expect.fail(tag);
208 }); 208 });
209 var decoderSink = JSON.decoder.startChunkedConversion(sink) 209 var decoderSink = JSON.decoder.startChunkedConversion(sink)
210 .asUtf8Sink(false); 210 .asUtf8Sink(false);
211 Expect.throws(() { action(decoderSink); }, null, tag); 211 Expect.throws(() { action(decoderSink); }, null, tag);
212 } 212 }
213 } 213 }
214 214
215 // Test all two and three part slices. 215 // Test all two and three part slices.
216 for (int i = 1; i < codes.length - 1; i++) { 216 for (int i = 1; i < codes.length - 1; i++) {
217 test("$name:$i", expect, (sink) { 217 test("$name:$i", expect, (sink) {
(...skipping 15 matching lines...) Expand all
233 } 233 }
234 } 234 }
235 } 235 }
236 236
237 // Test that `codeString.codeUnits` fails to parse as UTF-8 JSON, 237 // Test that `codeString.codeUnits` fails to parse as UTF-8 JSON,
238 // even with decoder not throwing on malformed encodings. 238 // even with decoder not throwing on malformed encodings.
239 void jsonThrows(String name, String codeString) { 239 void jsonThrows(String name, String codeString) {
240 testJsonThrows(tag, action) { 240 testJsonThrows(tag, action) {
241 // Not allowing malformed, expect throw. 241 // Not allowing malformed, expect throw.
242 var sink = new ChunkedConversionSink.withCallback((values) { 242 var sink = new ChunkedConversionSink.withCallback((values) {
243 Expect.unreachable(tag); 243 Expect.fail(tag);
244 }); 244 });
245 var decoderSink = JSON.decoder.startChunkedConversion(sink) 245 var decoderSink = JSON.decoder.startChunkedConversion(sink)
246 .asUtf8Sink(true); 246 .asUtf8Sink(true);
247 Expect.throws(() { action(decoderSink); }, null, tag); 247 Expect.throws(() { action(decoderSink); }, null, tag);
248 } 248 }
249 249
250 var codes = codeString.codeUnits; 250 var codes = codeString.codeUnits;
251 for (int i = 1; i < codes.length - 1; i++) { 251 for (int i = 1; i < codes.length - 1; i++) {
252 testJsonThrows("$name:$i", (sink) { 252 testJsonThrows("$name:$i", (sink) {
253 sink.add(codes.sublist(0, i)); 253 sink.add(codes.sublist(0, i));
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 sink.add(bytes.sublist(0, i)); 441 sink.add(bytes.sublist(0, i));
442 sink.add(bytes.sublist(i, j)); 442 sink.add(bytes.sublist(i, j));
443 sink.add(bytes.sublist(j)); 443 sink.add(bytes.sublist(j));
444 sink.add([0x22]); 444 sink.add([0x22]);
445 sink.close(); 445 sink.close();
446 }); 446 });
447 } 447 }
448 } 448 }
449 } 449 }
450 } 450 }
OLDNEW
« tests/corelib/corelib.status ('K') | « tests/lib/convert/json_chunk_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698