| OLD | NEW |
| 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:async'; | 6 import 'dart:async'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import "package:async_helper/async_helper.dart"; | 8 import "package:async_helper/async_helper.dart"; |
| 9 | 9 |
| 10 final TESTS = [ | 10 final TESTS = [ |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (!isJsonEqual(o1[key], o2[key])) return false; | 76 if (!isJsonEqual(o1[key], o2[key])) return false; |
| 77 } | 77 } |
| 78 return true; | 78 return true; |
| 79 } | 79 } |
| 80 return false; | 80 return false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 Stream<Object> createStream(List<String> chunks) { | 83 Stream<Object> createStream(List<String> chunks) { |
| 84 var decoder = new JsonDecoder(null); | 84 var decoder = new JsonDecoder(null); |
| 85 var controller; | 85 var controller; |
| 86 controller = new StreamController(onListen: () { | 86 controller = new StreamController<String>(onListen: () { |
| 87 chunks.forEach(controller.add); | 87 chunks.forEach(controller.add); |
| 88 controller.close(); | 88 controller.close(); |
| 89 }); | 89 }); |
| 90 return controller.stream.transform(decoder); | 90 return controller.stream.transform(decoder); |
| 91 } | 91 } |
| 92 | 92 |
| 93 Stream<Object> decode(String str) { | 93 Stream<Object> decode(String str) { |
| 94 return createStream([str]); | 94 return createStream([str]); |
| 95 } | 95 } |
| 96 | 96 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 120 [object, longString] | 120 [object, longString] |
| 121 ]; | 121 ]; |
| 122 }); | 122 }); |
| 123 for (var test in TESTS) { | 123 for (var test in TESTS) { |
| 124 var o = test[0]; | 124 var o = test[0]; |
| 125 var string = test[1]; | 125 var string = test[1]; |
| 126 checkIsJsonEqual(o, decode(string)); | 126 checkIsJsonEqual(o, decode(string)); |
| 127 checkIsJsonEqual(o, decode2(string)); | 127 checkIsJsonEqual(o, decode2(string)); |
| 128 } | 128 } |
| 129 } | 129 } |
| OLD | NEW |