OLD | NEW |
1 dart_library.library('corelib/iterable_generate_test', null, /* Imports */[ | 1 dart_library.library('corelib/iterable_generate_test', null, /* Imports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'expect' | 3 'expect' |
4 ], function load__iterable_generate_test(exports, dart_sdk, expect) { | 4 ], function load__iterable_generate_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 _interceptors = dart_sdk._interceptors; | 7 const _interceptors = dart_sdk._interceptors; |
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 iterable_generate_test = Object.create(null); | 11 const iterable_generate_test = Object.create(null); |
12 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); | 12 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
13 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); | 13 let JSArrayOfString = () => (JSArrayOfString = dart.constFn(_interceptors.JSAr
ray$(core.String)))(); |
| 14 let IterableOfString = () => (IterableOfString = dart.constFn(core.Iterable$(c
ore.String)))(); |
14 let IterableOfint = () => (IterableOfint = dart.constFn(core.Iterable$(core.in
t)))(); | 15 let IterableOfint = () => (IterableOfint = dart.constFn(core.Iterable$(core.in
t)))(); |
15 let IteratorOfint = () => (IteratorOfint = dart.constFn(core.Iterator$(core.in
t)))(); | 16 let IteratorOfint = () => (IteratorOfint = dart.constFn(core.Iterator$(core.in
t)))(); |
16 let IterableOfString = () => (IterableOfString = dart.constFn(core.Iterable$(c
ore.String)))(); | |
17 let IteratorOfString = () => (IteratorOfString = dart.constFn(core.Iterator$(c
ore.String)))(); | 17 let IteratorOfString = () => (IteratorOfString = dart.constFn(core.Iterator$(c
ore.String)))(); |
18 let dynamicAnddynamicTovoid = () => (dynamicAnddynamicTovoid = dart.constFn(da
rt.definiteFunctionType(dart.void, [dart.dynamic, dart.dynamic])))(); | 18 let dynamicAnddynamicTovoid = () => (dynamicAnddynamicTovoid = dart.constFn(da
rt.definiteFunctionType(dart.void, [dart.dynamic, dart.dynamic])))(); |
19 let intToString = () => (intToString = dart.constFn(dart.definiteFunctionType(
core.String, [core.int])))(); | 19 let intToString = () => (intToString = dart.constFn(dart.definiteFunctionType(
core.String, [core.int])))(); |
20 let VoidToIterableOfString = () => (VoidToIterableOfString = dart.constFn(dart
.definiteFunctionType(IterableOfString(), [])))(); | 20 let VoidToIterableOfString = () => (VoidToIterableOfString = dart.constFn(dart
.definiteFunctionType(IterableOfString(), [])))(); |
21 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 21 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
22 iterable_generate_test.main = function() { | 22 iterable_generate_test.main = function() { |
23 let checkedMode = false; | 23 let checkedMode = false; |
24 dart.assert(checkedMode = true); | 24 dart.assert(checkedMode = true); |
25 function test(expectedList, generatedIterable) { | 25 function test(expectedList, generatedIterable) { |
26 expect$.Expect.equals(dart.dload(expectedList, 'length'), dart.dload(gener
atedIterable, 'length')); | 26 expect$.Expect.equals(dart.dload(expectedList, 'length'), dart.dload(gener
atedIterable, 'length')); |
27 expect$.Expect.listEquals(core.List._check(expectedList), core.List._check
(dart.dsend(generatedIterable, 'toList'))); | 27 expect$.Expect.listEquals(core.List._check(expectedList), core.List._check
(dart.dsend(generatedIterable, 'toList'))); |
28 } | 28 } |
29 dart.fn(test, dynamicAnddynamicTovoid()); | 29 dart.fn(test, dynamicAnddynamicTovoid()); |
30 test([], core.Iterable.generate(0)); | 30 test([], core.Iterable.generate(0)); |
31 test(JSArrayOfint().of([0]), core.Iterable.generate(1)); | 31 test(JSArrayOfint().of([0]), core.Iterable.generate(1)); |
32 test(JSArrayOfint().of([0, 1, 2, 3, 4]), core.Iterable.generate(5)); | 32 test(JSArrayOfint().of([0, 1, 2, 3, 4]), core.Iterable.generate(5)); |
33 test(JSArrayOfString().of(["0", "1", "2", "3", "4"]), core.Iterable.generate
(5, dart.fn(x => dart.str`${x}`, intToString()))); | 33 test(JSArrayOfString().of(["0", "1", "2", "3", "4"]), IterableOfString().gen
erate(5, dart.fn(x => dart.str`${x}`, intToString()))); |
34 test(JSArrayOfint().of([2, 3, 4, 5, 6]), core.Iterable.generate(7)[dartx.ski
p](2)); | 34 test(JSArrayOfint().of([2, 3, 4, 5, 6]), core.Iterable.generate(7)[dartx.ski
p](2)); |
35 test(JSArrayOfint().of([0, 1, 2, 3, 4]), core.Iterable.generate(7)[dartx.tak
e](5)); | 35 test(JSArrayOfint().of([0, 1, 2, 3, 4]), core.Iterable.generate(7)[dartx.tak
e](5)); |
36 test([], core.Iterable.generate(5)[dartx.skip](6)); | 36 test([], core.Iterable.generate(5)[dartx.skip](6)); |
37 test([], core.Iterable.generate(5)[dartx.take](0)); | 37 test([], core.Iterable.generate(5)[dartx.take](0)); |
38 test([], core.Iterable.generate(5)[dartx.take](3)[dartx.skip](3)); | 38 test([], core.Iterable.generate(5)[dartx.take](3)[dartx.skip](3)); |
39 test([], core.Iterable.generate(5)[dartx.skip](6)[dartx.take](0)); | 39 test([], core.Iterable.generate(5)[dartx.skip](6)[dartx.take](0)); |
40 let it = IterableOfint().generate(5); | 40 let it = IterableOfint().generate(5); |
41 expect$.Expect.isTrue(IterableOfint().is(it)); | 41 expect$.Expect.isTrue(IterableOfint().is(it)); |
42 expect$.Expect.isTrue(IteratorOfint().is(it[dartx.iterator])); | 42 expect$.Expect.isTrue(IteratorOfint().is(it[dartx.iterator])); |
43 expect$.Expect.isTrue(!IterableOfString().is(it)); | 43 expect$.Expect.isTrue(!IterableOfString().is(it)); |
44 expect$.Expect.isTrue(!IteratorOfString().is(it[dartx.iterator])); | 44 expect$.Expect.isTrue(!IteratorOfString().is(it[dartx.iterator])); |
45 test(JSArrayOfint().of([0, 1, 2, 3, 4]), it); | 45 test(JSArrayOfint().of([0, 1, 2, 3, 4]), it); |
46 let st = IterableOfString().generate(5, dart.fn(x => dart.str`${x}`, intToSt
ring())); | 46 let st = IterableOfString().generate(5, dart.fn(x => dart.str`${x}`, intToSt
ring())); |
47 expect$.Expect.isTrue(IterableOfString().is(st)); | 47 expect$.Expect.isTrue(IterableOfString().is(st)); |
48 expect$.Expect.isTrue(IteratorOfString().is(st[dartx.iterator])); | 48 expect$.Expect.isTrue(IteratorOfString().is(st[dartx.iterator])); |
49 expect$.Expect.isFalse(IterableOfint().is(st)); | 49 expect$.Expect.isFalse(IterableOfint().is(st)); |
50 expect$.Expect.isFalse(IteratorOfint().is(st[dartx.iterator])); | 50 expect$.Expect.isFalse(IteratorOfint().is(st[dartx.iterator])); |
51 test(JSArrayOfString().of(["0", "1", "2", "3", "4"]), st); | 51 test(JSArrayOfString().of(["0", "1", "2", "3", "4"]), st); |
52 if (checkedMode) { | 52 if (checkedMode) { |
53 expect$.Expect.throws(dart.fn(() => IterableOfString().generate(5), VoidTo
IterableOfString())); | 53 expect$.Expect.throws(dart.fn(() => IterableOfString().generate(5), VoidTo
IterableOfString())); |
54 } | 54 } |
55 }; | 55 }; |
56 dart.fn(iterable_generate_test.main, VoidTodynamic()); | 56 dart.fn(iterable_generate_test.main, VoidTodynamic()); |
57 // Exports: | 57 // Exports: |
58 exports.iterable_generate_test = iterable_generate_test; | 58 exports.iterable_generate_test = iterable_generate_test; |
59 }); | 59 }); |
OLD | NEW |