| OLD | NEW |
| 1 dart_library.library('corelib/map_from_test', null, /* Imports */[ | 1 dart_library.library('corelib/map_from_test', null, /* Imports */[ |
| 2 'dart_sdk', | 2 'dart_sdk', |
| 3 'expect' | 3 'expect' |
| 4 ], function load__map_from_test(exports, dart_sdk, expect) { | 4 ], function load__map_from_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 collection = dart_sdk.collection; | 7 const collection = dart_sdk.collection; |
| 8 const dart = dart_sdk.dart; | 8 const dart = dart_sdk.dart; |
| 9 const dartx = dart_sdk.dartx; | 9 const dartx = dart_sdk.dartx; |
| 10 const expect$ = expect.expect; | 10 const expect$ = expect.expect; |
| 11 const map_from_test = Object.create(null); | 11 const map_from_test = Object.create(null); |
| 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 12 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 13 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); | 13 let dynamicAnddynamicTodynamic = () => (dynamicAnddynamicTodynamic = dart.cons
tFn(dart.definiteFunctionType(dart.dynamic, [dart.dynamic, dart.dynamic])))(); |
| 14 let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionTyp
e(core.int, [dart.dynamic])))(); | 14 let dynamicToint = () => (dynamicToint = dart.constFn(dart.definiteFunctionTyp
e(core.int, [dart.dynamic])))(); |
| 15 map_from_test.main = function() { | 15 map_from_test.main = function() { |
| 16 map_from_test.testWithConstMap(); | 16 map_from_test.testWithConstMap(); |
| 17 map_from_test.testWithNonConstMap(); | 17 map_from_test.testWithNonConstMap(); |
| 18 map_from_test.testWithHashMap(); | 18 map_from_test.testWithHashMap(); |
| 19 map_from_test.testWithLinkedMap(); | 19 map_from_test.testWithLinkedMap(); |
| 20 }; | 20 }; |
| 21 dart.fn(map_from_test.main, VoidTodynamic()); | 21 dart.fn(map_from_test.main, VoidTodynamic()); |
| 22 let const$; | 22 let const$; |
| 23 map_from_test.testWithConstMap = function() { | 23 map_from_test.testWithConstMap = function() { |
| 24 let map = const$ || (const$ = dart.const(dart.map({b: 42, a: 43}))); | 24 let map = const$ || (const$ = dart.const(dart.map({b: 42, a: 43}, core.Strin
g, core.int))); |
| 25 let otherMap = core.Map.from(map); | 25 let otherMap = core.Map.from(map); |
| 26 expect$.Expect.isTrue(core.Map.is(otherMap)); | 26 expect$.Expect.isTrue(core.Map.is(otherMap)); |
| 27 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); | 27 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); |
| 28 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); | 28 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); |
| 29 expect$.Expect.equals(2, otherMap[dartx.length]); | 29 expect$.Expect.equals(2, otherMap[dartx.length]); |
| 30 expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]); | 30 expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]); |
| 31 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); | 31 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); |
| 32 let count = dart.fn(map => { | 32 let count = dart.fn(map => { |
| 33 let cnt = 0; | 33 let cnt = 0; |
| 34 dart.dsend(map, 'forEach', dart.fn((a, b) => { | 34 dart.dsend(map, 'forEach', dart.fn((a, b) => { |
| 35 cnt = dart.notNull(cnt) + dart.notNull(core.int._check(b)); | 35 cnt = dart.notNull(cnt) + dart.notNull(core.int._check(b)); |
| 36 }, dynamicAnddynamicTodynamic())); | 36 }, dynamicAnddynamicTodynamic())); |
| 37 return cnt; | 37 return cnt; |
| 38 }, dynamicToint()); | 38 }, dynamicToint()); |
| 39 expect$.Expect.equals(42 + 43, dart.dcall(count, map)); | 39 expect$.Expect.equals(42 + 43, dart.dcall(count, map)); |
| 40 expect$.Expect.equals(dart.dcall(count, map), dart.dcall(count, otherMap)); | 40 expect$.Expect.equals(dart.dcall(count, map), dart.dcall(count, otherMap)); |
| 41 }; | 41 }; |
| 42 dart.fn(map_from_test.testWithConstMap, VoidTodynamic()); | 42 dart.fn(map_from_test.testWithConstMap, VoidTodynamic()); |
| 43 map_from_test.testWithNonConstMap = function() { | 43 map_from_test.testWithNonConstMap = function() { |
| 44 let map = dart.map({b: 42, a: 43}); | 44 let map = dart.map({b: 42, a: 43}, core.String, core.int); |
| 45 let otherMap = core.Map.from(map); | 45 let otherMap = core.Map.from(map); |
| 46 expect$.Expect.isTrue(core.Map.is(otherMap)); | 46 expect$.Expect.isTrue(core.Map.is(otherMap)); |
| 47 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); | 47 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); |
| 48 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); | 48 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); |
| 49 expect$.Expect.equals(2, otherMap[dartx.length]); | 49 expect$.Expect.equals(2, otherMap[dartx.length]); |
| 50 expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]); | 50 expect$.Expect.equals(2, otherMap[dartx.keys][dartx.length]); |
| 51 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); | 51 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); |
| 52 function count(map) { | 52 function count(map) { |
| 53 let count = 0; | 53 let count = 0; |
| 54 dart.dsend(map, 'forEach', dart.fn((a, b) => { | 54 dart.dsend(map, 'forEach', dart.fn((a, b) => { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 67 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); | 67 expect$.Expect.equals(2, otherMap[dartx.values][dartx.length]); |
| 68 otherMap[dartx.set]('c', 44); | 68 otherMap[dartx.set]('c', 44); |
| 69 expect$.Expect.equals(3, map[dartx.length]); | 69 expect$.Expect.equals(3, map[dartx.length]); |
| 70 expect$.Expect.equals(3, otherMap[dartx.length]); | 70 expect$.Expect.equals(3, otherMap[dartx.length]); |
| 71 expect$.Expect.equals(3, otherMap[dartx.keys][dartx.length]); | 71 expect$.Expect.equals(3, otherMap[dartx.keys][dartx.length]); |
| 72 expect$.Expect.equals(3, otherMap[dartx.values][dartx.length]); | 72 expect$.Expect.equals(3, otherMap[dartx.values][dartx.length]); |
| 73 }; | 73 }; |
| 74 dart.fn(map_from_test.testWithNonConstMap, VoidTodynamic()); | 74 dart.fn(map_from_test.testWithNonConstMap, VoidTodynamic()); |
| 75 let const$0; | 75 let const$0; |
| 76 map_from_test.testWithHashMap = function() { | 76 map_from_test.testWithHashMap = function() { |
| 77 let map = const$0 || (const$0 = dart.const(dart.map({b: 1, a: 2, c: 3}))); | 77 let map = const$0 || (const$0 = dart.const(dart.map({b: 1, a: 2, c: 3}, core
.String, core.int))); |
| 78 let otherMap = collection.HashMap.from(map); | 78 let otherMap = collection.HashMap.from(map); |
| 79 expect$.Expect.isTrue(core.Map.is(otherMap)); | 79 expect$.Expect.isTrue(core.Map.is(otherMap)); |
| 80 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); | 80 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); |
| 81 expect$.Expect.isTrue(!collection.LinkedHashMap.is(otherMap)); | 81 expect$.Expect.isTrue(!collection.LinkedHashMap.is(otherMap)); |
| 82 let i = 1; | 82 let i = 1; |
| 83 for (let val of map[dartx.values]) { | 83 for (let val of map[dartx.values]) { |
| 84 expect$.Expect.equals(i++, val); | 84 expect$.Expect.equals(i++, val); |
| 85 } | 85 } |
| 86 }; | 86 }; |
| 87 dart.fn(map_from_test.testWithHashMap, VoidTodynamic()); | 87 dart.fn(map_from_test.testWithHashMap, VoidTodynamic()); |
| 88 let const$1; | 88 let const$1; |
| 89 map_from_test.testWithLinkedMap = function() { | 89 map_from_test.testWithLinkedMap = function() { |
| 90 let map = const$1 || (const$1 = dart.const(dart.map({b: 1, a: 2, c: 3}))); | 90 let map = const$1 || (const$1 = dart.const(dart.map({b: 1, a: 2, c: 3}, core
.String, core.int))); |
| 91 let otherMap = collection.LinkedHashMap.from(map); | 91 let otherMap = collection.LinkedHashMap.from(map); |
| 92 expect$.Expect.isTrue(core.Map.is(otherMap)); | 92 expect$.Expect.isTrue(core.Map.is(otherMap)); |
| 93 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); | 93 expect$.Expect.isTrue(collection.HashMap.is(otherMap)); |
| 94 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); | 94 expect$.Expect.isTrue(collection.LinkedHashMap.is(otherMap)); |
| 95 let i = 1; | 95 let i = 1; |
| 96 for (let val of map[dartx.values]) { | 96 for (let val of map[dartx.values]) { |
| 97 expect$.Expect.equals(i++, val); | 97 expect$.Expect.equals(i++, val); |
| 98 } | 98 } |
| 99 }; | 99 }; |
| 100 dart.fn(map_from_test.testWithLinkedMap, VoidTodynamic()); | 100 dart.fn(map_from_test.testWithLinkedMap, VoidTodynamic()); |
| 101 // Exports: | 101 // Exports: |
| 102 exports.map_from_test = map_from_test; | 102 exports.map_from_test = map_from_test; |
| 103 }); | 103 }); |
| OLD | NEW |