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

Side by Side Diff: test/codegen_expected/lib/convert/json_toEncodable_reviver_test.js

Issue 2211293002: Reify type params on map literals (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Suppress empty arg with dynamic params Created 4 years, 4 months 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
OLDNEW
1 dart_library.library('lib/convert/json_toEncodable_reviver_test', null, /* Impor ts */[ 1 dart_library.library('lib/convert/json_toEncodable_reviver_test', null, /* Impor ts */[
2 'dart_sdk', 2 'dart_sdk',
3 'expect' 3 'expect'
4 ], function load__json_toEncodable_reviver_test(exports, dart_sdk, expect) { 4 ], function load__json_toEncodable_reviver_test(exports, dart_sdk, expect) {
5 'use strict'; 5 'use strict';
6 const core = dart_sdk.core; 6 const core = dart_sdk.core;
7 const convert = dart_sdk.convert; 7 const convert = dart_sdk.convert;
8 const _interceptors = dart_sdk._interceptors; 8 const _interceptors = dart_sdk._interceptors;
9 const dart = dart_sdk.dart; 9 const dart = dart_sdk.dart;
10 const dartx = dart_sdk.dartx; 10 const dartx = dart_sdk.dartx;
11 const expect$ = expect.expect; 11 const expect$ = expect.expect;
12 const json_toEncodable_reviver_test = Object.create(null); 12 const json_toEncodable_reviver_test = Object.create(null);
13 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))(); 13 let JSArrayOfObject = () => (JSArrayOfObject = dart.constFn(_interceptors.JSAr ray$(core.Object)))();
14 let ATodynamic = () => (ATodynamic = dart.constFn(dart.definiteFunctionType(da rt.dynamic, [json_toEncodable_reviver_test.A])))(); 14 let ATodynamic = () => (ATodynamic = dart.constFn(dart.definiteFunctionType(da rt.dynamic, [json_toEncodable_reviver_test.A])))();
15 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); 15 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))();
16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))(); 16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT ype(dart.dynamic, [])))();
17 let dynamicToString = () => (dynamicToString = dart.constFn(dart.definiteFunct ionType(core.String, [dart.dynamic])))(); 17 let dynamicToString = () => (dynamicToString = dart.constFn(dart.definiteFunct ionType(core.String, [dart.dynamic])))();
18 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))(); 18 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da rt.void, [])))();
19 json_toEncodable_reviver_test.A = class A extends core.Object { 19 json_toEncodable_reviver_test.A = class A extends core.Object {
20 new(x) { 20 new(x) {
21 this.x = x; 21 this.x = x;
22 } 22 }
23 }; 23 };
24 dart.setSignature(json_toEncodable_reviver_test.A, { 24 dart.setSignature(json_toEncodable_reviver_test.A, {
25 constructors: () => ({new: dart.definiteFunctionType(json_toEncodable_revive r_test.A, [dart.dynamic])}) 25 constructors: () => ({new: dart.definiteFunctionType(json_toEncodable_revive r_test.A, [dart.dynamic])})
26 }); 26 });
27 json_toEncodable_reviver_test.toEncodable = function(a) { 27 json_toEncodable_reviver_test.toEncodable = function(a) {
28 return dart.map({A: a.x}); 28 return dart.map({A: a.x}, core.String, dart.dynamic);
29 }; 29 };
30 dart.fn(json_toEncodable_reviver_test.toEncodable, ATodynamic()); 30 dart.fn(json_toEncodable_reviver_test.toEncodable, ATodynamic());
31 json_toEncodable_reviver_test.reviver = function(key, value) { 31 json_toEncodable_reviver_test.reviver = function(key, value) {
32 if (core.Map.is(value) && value[dartx.length] == 1 && value[dartx.get]("A") != null) { 32 if (core.Map.is(value) && value[dartx.length] == 1 && value[dartx.get]("A") != null) {
33 return new json_toEncodable_reviver_test.A(value[dartx.get]("A")); 33 return new json_toEncodable_reviver_test.A(value[dartx.get]("A"));
34 } 34 }
35 return value; 35 return value;
36 }; 36 };
37 dart.fn(json_toEncodable_reviver_test.reviver, dynamicAnddynamicTodynamic()); 37 dart.fn(json_toEncodable_reviver_test.reviver, dynamicAnddynamicTodynamic());
38 json_toEncodable_reviver_test.extendedJson = dart.const(new convert.JsonCodec( {toEncodable: json_toEncodable_reviver_test.toEncodable, reviver: json_toEncodab le_reviver_test.reviver})); 38 json_toEncodable_reviver_test.extendedJson = dart.const(new convert.JsonCodec( {toEncodable: json_toEncodable_reviver_test.toEncodable, reviver: json_toEncodab le_reviver_test.reviver}));
39 json_toEncodable_reviver_test.main = function() { 39 json_toEncodable_reviver_test.main = function() {
40 let encoded = json_toEncodable_reviver_test.extendedJson.encode(JSArrayOfObj ect().of([new json_toEncodable_reviver_test.A(0), dart.map({"2": new json_toEnco dable_reviver_test.A(1)})])); 40 let encoded = json_toEncodable_reviver_test.extendedJson.encode(JSArrayOfObj ect().of([new json_toEncodable_reviver_test.A(0), dart.map({"2": new json_toEnco dable_reviver_test.A(1)}, core.String, json_toEncodable_reviver_test.A)]));
41 expect$.Expect.equals('[{"A":0},{"2":{"A":1}}]', encoded); 41 expect$.Expect.equals('[{"A":0},{"2":{"A":1}}]', encoded);
42 let decoded = json_toEncodable_reviver_test.extendedJson.decode(encoded); 42 let decoded = json_toEncodable_reviver_test.extendedJson.decode(encoded);
43 expect$.Expect.isTrue(core.List.is(decoded)); 43 expect$.Expect.isTrue(core.List.is(decoded));
44 expect$.Expect.equals(2, dart.dload(decoded, 'length')); 44 expect$.Expect.equals(2, dart.dload(decoded, 'length'));
45 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(dart.dindex(decoded , 0))); 45 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(dart.dindex(decoded , 0)));
46 expect$.Expect.equals(0, dart.dload(dart.dindex(decoded, 0), 'x')); 46 expect$.Expect.equals(0, dart.dload(dart.dindex(decoded, 0), 'x'));
47 expect$.Expect.isTrue(core.Map.is(dart.dindex(decoded, 1))); 47 expect$.Expect.isTrue(core.Map.is(dart.dindex(decoded, 1)));
48 expect$.Expect.isNotNull(dart.dindex(dart.dindex(decoded, 1), "2")); 48 expect$.Expect.isNotNull(dart.dindex(dart.dindex(decoded, 1), "2"));
49 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(dart.dindex(dart.di ndex(decoded, 1), "2"))); 49 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(dart.dindex(dart.di ndex(decoded, 1), "2")));
50 expect$.Expect.equals(1, dart.dload(dart.dindex(dart.dindex(decoded, 1), "2" ), 'x')); 50 expect$.Expect.equals(1, dart.dload(dart.dindex(dart.dindex(decoded, 1), "2" ), 'x'));
51 let a = json_toEncodable_reviver_test.extendedJson.decode(json_toEncodable_r eviver_test.extendedJson.encode(new json_toEncodable_reviver_test.A(499))); 51 let a = json_toEncodable_reviver_test.extendedJson.decode(json_toEncodable_r eviver_test.extendedJson.encode(new json_toEncodable_reviver_test.A(499)));
52 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(a)); 52 expect$.Expect.isTrue(json_toEncodable_reviver_test.A.is(a));
53 expect$.Expect.equals(499, dart.dload(a, 'x')); 53 expect$.Expect.equals(499, dart.dload(a, 'x'));
54 json_toEncodable_reviver_test.testInvalidMap(); 54 json_toEncodable_reviver_test.testInvalidMap();
55 }; 55 };
56 dart.fn(json_toEncodable_reviver_test.main, VoidTodynamic()); 56 dart.fn(json_toEncodable_reviver_test.main, VoidTodynamic());
57 json_toEncodable_reviver_test.testInvalidMap = function() { 57 json_toEncodable_reviver_test.testInvalidMap = function() {
58 let map = dart.map(["a", 42, "b", 42, 37, 42]); 58 let map = dart.map(["a", 42, "b", 42, 37, 42], core.Object, core.int);
59 let enc = new convert.JsonEncoder(dart.fn(_ => "fixed", dynamicToString())); 59 let enc = new convert.JsonEncoder(dart.fn(_ => "fixed", dynamicToString()));
60 let res = enc.convert(map); 60 let res = enc.convert(map);
61 expect$.Expect.equals('"fixed"', res); 61 expect$.Expect.equals('"fixed"', res);
62 enc = new convert.JsonEncoder.withIndent(" ", dart.fn(_ => "fixed", dynamicT oString())); 62 enc = new convert.JsonEncoder.withIndent(" ", dart.fn(_ => "fixed", dynamicT oString()));
63 res = enc.convert(map); 63 res = enc.convert(map);
64 expect$.Expect.equals('"fixed"', res); 64 expect$.Expect.equals('"fixed"', res);
65 }; 65 };
66 dart.fn(json_toEncodable_reviver_test.testInvalidMap, VoidTovoid()); 66 dart.fn(json_toEncodable_reviver_test.testInvalidMap, VoidTovoid());
67 // Exports: 67 // Exports:
68 exports.json_toEncodable_reviver_test = json_toEncodable_reviver_test; 68 exports.json_toEncodable_reviver_test = json_toEncodable_reviver_test;
69 }); 69 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698