OLD | NEW |
(Empty) | |
| 1 dart_library.library('lib/convert/codec2_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__codec2_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const convert = dart_sdk.convert; |
| 8 const _interceptors = dart_sdk._interceptors; |
| 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; |
| 11 const expect$ = expect.expect; |
| 12 const codec2_test = Object.create(null); |
| 13 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 14 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr
ray$(core.Object)))(); |
| 15 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); |
| 16 let ListOfint = () => (ListOfint = dart.constFn(core.List$(core.int)))(); |
| 17 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); |
| 18 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 19 let const$; |
| 20 codec2_test.main = function() { |
| 21 let RAW = '["122ç",50,50,231]'; |
| 22 let ENCODED = const$ || (const$ = dart.constList([91, 34, 49, 50, 50, 195, 1
67, 34, 44, 53, 48, 44, 53, 48, 44, 50, 51, 49, 93], core.int)); |
| 23 expect$.Expect.listEquals(ENCODED, convert.UTF8.encode(RAW)); |
| 24 expect$.Expect.equals(RAW, convert.UTF8.decode(ENCODED)); |
| 25 expect$.Expect.listEquals([], convert.UTF8.encode("")); |
| 26 expect$.Expect.equals("", convert.UTF8.decode(JSArrayOfint().of([]))); |
| 27 let JSON_ENCODED = RAW; |
| 28 expect$.Expect.equals(JSON_ENCODED, convert.JSON.encode(JSArrayOfObject().of
(["122ç", 50, 50, 231]))); |
| 29 expect$.Expect.listEquals(JSArrayOfObject().of(["122ç", 50, 50, 231]), core.
List._check(convert.JSON.decode(JSON_ENCODED))); |
| 30 let decoded = convert.JSON.decode('{"p": 5}', {reviver: dart.fn((k, v) => { |
| 31 if (k == null) return v; |
| 32 return dart.dsend(v, '*', 2); |
| 33 }, dynamicAnddynamicTodynamic())}); |
| 34 expect$.Expect.equals(10, dart.dindex(decoded, "p")); |
| 35 let jsonWithReviver = new convert.JsonCodec.withReviver(dart.fn((k, v) => { |
| 36 if (k == null) return v; |
| 37 return dart.dsend(v, '*', 2); |
| 38 }, dynamicAnddynamicTodynamic())); |
| 39 decoded = jsonWithReviver.decode('{"p": 5}'); |
| 40 expect$.Expect.equals(10, dart.dindex(decoded, "p")); |
| 41 let JSON_TO_BYTES = convert.JSON.fuse(convert.UTF8); |
| 42 let bytes = ListOfint()._check(JSON_TO_BYTES.encode(JSArrayOfString().of(["j
son-object"]))); |
| 43 decoded = JSON_TO_BYTES.decode(bytes); |
| 44 expect$.Expect.isTrue(core.List.is(decoded)); |
| 45 expect$.Expect.equals("json-object", core.List.as(decoded)[dartx.get](0)); |
| 46 }; |
| 47 dart.fn(codec2_test.main, VoidTodynamic()); |
| 48 // Exports: |
| 49 exports.codec2_test = codec2_test; |
| 50 }); |
OLD | NEW |