| OLD | NEW |
| 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 // Disable background compilation so that the Issue 24908 can be reproduced. | 4 // Disable background compilation so that the Issue 24908 can be reproduced. |
| 5 // VMOptions=--no-background-compilation | 5 // VMOptions=--no-background-compilation |
| 6 | 6 |
| 7 library json_test; | 7 library json_test; |
| 8 | 8 |
| 9 import "package:expect/expect.dart"; | 9 import "package:expect/expect.dart"; |
| 10 import "dart:convert"; | 10 import "dart:convert"; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 Expect.isTrue(expected.compareTo(actual) == 0, | 31 Expect.isTrue(expected.compareTo(actual) == 0, |
| 32 "$path: Expected: $expected, was: $actual"); | 32 "$path: Expected: $expected, was: $actual"); |
| 33 } else { | 33 } else { |
| 34 // String, bool, null. | 34 // String, bool, null. |
| 35 Expect.equals(expected, actual, path); | 35 Expect.equals(expected, actual, path); |
| 36 } | 36 } |
| 37 } | 37 } |
| 38 for (var reviver in [null, (k, v) => v]) { | 38 for (var reviver in [null, (k, v) => v]) { |
| 39 for (var split in [0, 1, 2, 3]) { | 39 for (var split in [0, 1, 2, 3]) { |
| 40 var name = (reviver == null) ? "" : "reviver:"; | 40 var name = (reviver == null) ? "" : "reviver:"; |
| 41 var sink = new ChunkedConversionSink.withCallback((values) { | 41 var sink = new ChunkedConversionSink<dynamic>.withCallback((values) { |
| 42 var value = values[0]; | 42 var value = values[0]; |
| 43 compare(expected, value, "$name$value"); | 43 compare(expected, value, "$name$value"); |
| 44 }); | 44 }); |
| 45 var decoderSink = JSON.decoder.startChunkedConversion(sink); | 45 var decoderSink = JSON.decoder.startChunkedConversion(sink); |
| 46 switch (split) { | 46 switch (split) { |
| 47 case 0: | 47 case 0: |
| 48 // Split after first char. | 48 // Split after first char. |
| 49 decoderSink.add(json.substring(0, 1)); | 49 decoderSink.add(json.substring(0, 1)); |
| 50 decoderSink.add(json.substring(1)); | 50 decoderSink.add(json.substring(1)); |
| 51 decoderSink.close(); | 51 decoderSink.close(); |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 } | 319 } |
| 320 | 320 |
| 321 main() { | 321 main() { |
| 322 testNumbers(); | 322 testNumbers(); |
| 323 testStrings(); | 323 testStrings(); |
| 324 testWords(); | 324 testWords(); |
| 325 testObjects(); | 325 testObjects(); |
| 326 testArrays(); | 326 testArrays(); |
| 327 testWhitespace(); | 327 testWhitespace(); |
| 328 } | 328 } |
| OLD | NEW |