OLD | NEW |
(Empty) | |
| 1 dart_library.library('corelib/map_from_iterables_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__map_from_iterables_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const _interceptors = dart_sdk._interceptors; |
| 8 const collection = dart_sdk.collection; |
| 9 const dart = dart_sdk.dart; |
| 10 const dartx = dart_sdk.dartx; |
| 11 const expect$ = expect.expect; |
| 12 const map_from_iterables_test = Object.create(null); |
| 13 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 14 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); |
| 15 let MapOfint$String = () => (MapOfint$String = dart.constFn(core.Map$(core.int
, core.String)))(); |
| 16 let MapOfString$dynamic = () => (MapOfString$dynamic = dart.constFn(core.Map$(
core.String, dart.dynamic)))(); |
| 17 let MapOfdynamic$int = () => (MapOfdynamic$int = dart.constFn(core.Map$(dart.d
ynamic, core.int)))(); |
| 18 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 19 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 20 let VoidToMap = () => (VoidToMap = dart.constFn(dart.definiteFunctionType(core
.Map, [])))(); |
| 21 map_from_iterables_test.main = function() { |
| 22 map_from_iterables_test.positiveTest(); |
| 23 map_from_iterables_test.emptyMapTest(); |
| 24 map_from_iterables_test.fewerKeysIterableTest(); |
| 25 map_from_iterables_test.fewerValuesIterableTest(); |
| 26 map_from_iterables_test.equalElementsTest(); |
| 27 map_from_iterables_test.genericTypeTest(); |
| 28 }; |
| 29 dart.fn(map_from_iterables_test.main, VoidTodynamic()); |
| 30 map_from_iterables_test.positiveTest = function() { |
| 31 let map = core.Map.fromIterables(JSArrayOfint().of([1, 2, 3]), JSArrayOfStri
ng().of(["one", "two", "three"])); |
| 32 expect$.Expect.isTrue(core.Map.is(map)); |
| 33 expect$.Expect.isTrue(collection.LinkedHashMap.is(map)); |
| 34 expect$.Expect.equals(3, map[dartx.length]); |
| 35 expect$.Expect.equals(3, map[dartx.keys][dartx.length]); |
| 36 expect$.Expect.equals(3, map[dartx.values][dartx.length]); |
| 37 expect$.Expect.equals("one", map[dartx.get](1)); |
| 38 expect$.Expect.equals("two", map[dartx.get](2)); |
| 39 expect$.Expect.equals("three", map[dartx.get](3)); |
| 40 }; |
| 41 dart.fn(map_from_iterables_test.positiveTest, VoidTovoid()); |
| 42 map_from_iterables_test.emptyMapTest = function() { |
| 43 let map = core.Map.fromIterables([], []); |
| 44 expect$.Expect.isTrue(core.Map.is(map)); |
| 45 expect$.Expect.isTrue(collection.LinkedHashMap.is(map)); |
| 46 expect$.Expect.equals(0, map[dartx.length]); |
| 47 expect$.Expect.equals(0, map[dartx.keys][dartx.length]); |
| 48 expect$.Expect.equals(0, map[dartx.values][dartx.length]); |
| 49 }; |
| 50 dart.fn(map_from_iterables_test.emptyMapTest, VoidTovoid()); |
| 51 map_from_iterables_test.fewerValuesIterableTest = function() { |
| 52 expect$.Expect.throws(dart.fn(() => core.Map.fromIterables(JSArrayOfint().of
([1, 2]), JSArrayOfint().of([0])), VoidToMap())); |
| 53 }; |
| 54 dart.fn(map_from_iterables_test.fewerValuesIterableTest, VoidTovoid()); |
| 55 map_from_iterables_test.fewerKeysIterableTest = function() { |
| 56 expect$.Expect.throws(dart.fn(() => core.Map.fromIterables(JSArrayOfint().of
([1]), JSArrayOfint().of([0, 2])), VoidToMap())); |
| 57 }; |
| 58 dart.fn(map_from_iterables_test.fewerKeysIterableTest, VoidTovoid()); |
| 59 map_from_iterables_test.equalElementsTest = function() { |
| 60 let map = core.Map.fromIterables(JSArrayOfint().of([1, 2, 2]), JSArrayOfStri
ng().of(["one", "two", "three"])); |
| 61 expect$.Expect.isTrue(core.Map.is(map)); |
| 62 expect$.Expect.isTrue(collection.LinkedHashMap.is(map)); |
| 63 expect$.Expect.equals(2, map[dartx.length]); |
| 64 expect$.Expect.equals(2, map[dartx.keys][dartx.length]); |
| 65 expect$.Expect.equals(2, map[dartx.values][dartx.length]); |
| 66 expect$.Expect.equals("one", map[dartx.get](1)); |
| 67 expect$.Expect.equals("three", map[dartx.get](2)); |
| 68 }; |
| 69 dart.fn(map_from_iterables_test.equalElementsTest, VoidTovoid()); |
| 70 map_from_iterables_test.genericTypeTest = function() { |
| 71 let map = MapOfint$String().fromIterables(JSArrayOfint().of([1, 2, 3]), JSAr
rayOfString().of(["one", "two", "three"])); |
| 72 expect$.Expect.isTrue(MapOfint$String().is(map)); |
| 73 expect$.Expect.isFalse(MapOfString$dynamic().is(map)); |
| 74 expect$.Expect.isFalse(MapOfdynamic$int().is(map)); |
| 75 expect$.Expect.equals(3, map[dartx.length]); |
| 76 expect$.Expect.equals(3, map[dartx.keys][dartx.length]); |
| 77 expect$.Expect.equals(3, map[dartx.values][dartx.length]); |
| 78 expect$.Expect.equals("one", map[dartx.get](1)); |
| 79 expect$.Expect.equals("two", map[dartx.get](2)); |
| 80 expect$.Expect.equals("three", map[dartx.get](3)); |
| 81 }; |
| 82 dart.fn(map_from_iterables_test.genericTypeTest, VoidTovoid()); |
| 83 // Exports: |
| 84 exports.map_from_iterables_test = map_from_iterables_test; |
| 85 }); |
OLD | NEW |