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 'json_unicode_tests.dart'; | 8 import 'json_unicode_tests.dart'; |
9 import "package:async_helper/async_helper.dart"; | 9 import "package:async_helper/async_helper.dart"; |
10 | 10 |
11 final JSON_UTF8 = JSON.fuse(UTF8); | 11 final JSON_UTF8 = JSON.fuse<List<int>>(UTF8); |
12 | 12 |
13 | 13 |
14 Stream<List<int>> encode(Object o) { | 14 Stream<List<int>> encode(Object o) { |
15 var controller; | 15 var controller; |
16 controller = new StreamController(onListen: () { | 16 controller = new StreamController(onListen: () { |
17 controller.add(o); | 17 controller.add(o); |
18 controller.close(); | 18 controller.close(); |
19 }); | 19 }); |
20 return controller.stream.transform(JSON_UTF8.encoder); | 20 return controller.stream.transform(JSON_UTF8.encoder); |
21 } | 21 } |
(...skipping 22 matching lines...) Expand all Loading... |
44 } | 44 } |
45 | 45 |
46 void main() { | 46 void main() { |
47 for (var test in JSON_UNICODE_TESTS) { | 47 for (var test in JSON_UNICODE_TESTS) { |
48 var expected = test[0]; | 48 var expected = test[0]; |
49 var object = test[1]; | 49 var object = test[1]; |
50 testUnpaused(expected, encode(object)); | 50 testUnpaused(expected, encode(object)); |
51 testWithPauses(expected, encode(object)); | 51 testWithPauses(expected, encode(object)); |
52 } | 52 } |
53 } | 53 } |
OLD | NEW |