OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/param2_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__param2_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const _interceptors = dart_sdk._interceptors; |
| 8 const dart = dart_sdk.dart; |
| 9 const dartx = dart_sdk.dartx; |
| 10 const expect$ = expect.expect; |
| 11 const param2_test = Object.create(null); |
| 12 let JSArrayOfint = () => (JSArrayOfint = dart.constFn(_interceptors.JSArray$(c
ore.int)))(); |
| 13 let intToint = () => (intToint = dart.constFn(dart.definiteFunctionType(core.i
nt, [core.int])))(); |
| 14 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); |
| 15 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
| 16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 17 param2_test.Param2Test = class Param2Test extends core.Object { |
| 18 static forEach(a, f) { |
| 19 for (let i = 0; i < dart.notNull(a[dartx.length]); i++) { |
| 20 a[dartx.set](i, dart.dcall(f, a[dartx.get](i))); |
| 21 } |
| 22 } |
| 23 static apply(f, arg) { |
| 24 let res = f(arg); |
| 25 return core.int._check(res); |
| 26 } |
| 27 static exists(a, f) { |
| 28 for (let i = 0; i < dart.notNull(a[dartx.length]); i++) { |
| 29 if (dart.test(dart.dcall(f, a[dartx.get](i)))) return true; |
| 30 } |
| 31 return false; |
| 32 } |
| 33 static testMain() { |
| 34 function square(x) { |
| 35 return dart.notNull(x) * dart.notNull(x); |
| 36 } |
| 37 dart.fn(square, intToint()); |
| 38 expect$.Expect.equals(4, param2_test.Param2Test.apply(square, 2)); |
| 39 expect$.Expect.equals(100, param2_test.Param2Test.apply(square, 10)); |
| 40 let v = JSArrayOfint().of([1, 2, 3, 4, 5, 6]); |
| 41 param2_test.Param2Test.forEach(v, square); |
| 42 expect$.Expect.equals(1, v[dartx.get](0)); |
| 43 expect$.Expect.equals(4, v[dartx.get](1)); |
| 44 expect$.Expect.equals(9, v[dartx.get](2)); |
| 45 expect$.Expect.equals(16, v[dartx.get](3)); |
| 46 expect$.Expect.equals(25, v[dartx.get](4)); |
| 47 expect$.Expect.equals(36, v[dartx.get](5)); |
| 48 function isOdd(element) { |
| 49 return dart.equals(dart.dsend(element, '%', 2), 1); |
| 50 } |
| 51 dart.fn(isOdd, dynamicTodynamic()); |
| 52 expect$.Expect.equals(true, param2_test.Param2Test.exists(JSArrayOfint().o
f([3, 5, 7, 11, 13]), isOdd)); |
| 53 expect$.Expect.equals(false, param2_test.Param2Test.exists(JSArrayOfint().
of([2, 4, 10]), isOdd)); |
| 54 expect$.Expect.equals(false, param2_test.Param2Test.exists(JSArrayOfint().
of([]), isOdd)); |
| 55 v = JSArrayOfint().of([4, 5, 7]); |
| 56 expect$.Expect.equals(true, param2_test.Param2Test.exists(v, dart.fn(e =>
dart.equals(dart.dsend(e, '%', 2), 1), dynamicTobool()))); |
| 57 expect$.Expect.equals(false, param2_test.Param2Test.exists(v, dart.fn(e =>
dart.equals(e, 6), dynamicTobool()))); |
| 58 let isZero = dart.fn(e => dart.equals(e, 0), dynamicTobool()); |
| 59 expect$.Expect.equals(false, param2_test.Param2Test.exists(v, isZero)); |
| 60 } |
| 61 }; |
| 62 dart.setSignature(param2_test.Param2Test, { |
| 63 statics: () => ({ |
| 64 forEach: dart.definiteFunctionType(dart.dynamic, [core.List$(core.int), da
rt.functionType(core.int, [dart.dynamic])]), |
| 65 apply: dart.definiteFunctionType(core.int, [dart.functionType(dart.dynamic
, [core.int]), core.int]), |
| 66 exists: dart.definiteFunctionType(dart.dynamic, [core.List$(core.int), dar
t.functionType(dart.dynamic, [dart.dynamic])]), |
| 67 testMain: dart.definiteFunctionType(dart.dynamic, []) |
| 68 }), |
| 69 names: ['forEach', 'apply', 'exists', 'testMain'] |
| 70 }); |
| 71 param2_test.main = function() { |
| 72 param2_test.Param2Test.testMain(); |
| 73 }; |
| 74 dart.fn(param2_test.main, VoidTodynamic()); |
| 75 // Exports: |
| 76 exports.param2_test = param2_test; |
| 77 }); |
OLD | NEW |