OLD | NEW |
1 dart_library.library('language/call_closurization_test', null, /* Imports */[ | 1 dart_library.library('language/call_closurization_test', null, /* Imports */[ |
2 'dart_sdk', | 2 'dart_sdk', |
3 'expect' | 3 'expect' |
4 ], function load__call_closurization_test(exports, dart_sdk, expect) { | 4 ], function load__call_closurization_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 dart = dart_sdk.dart; | 7 const dart = dart_sdk.dart; |
8 const dartx = dart_sdk.dartx; | 8 const dartx = dart_sdk.dartx; |
9 const expect$ = expect.expect; | 9 const expect$ = expect.expect; |
10 const call_closurization_test = Object.create(null); | 10 const call_closurization_test = Object.create(null); |
11 let dynamicTodynamic = () => (dynamicTodynamic = dart.constFn(dart.definiteFun
ctionType(dart.dynamic, [dart.dynamic])))(); | 11 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); |
12 let __Todynamic = () => (__Todynamic = dart.constFn(dart.definiteFunctionType(
dart.dynamic, [], [dart.dynamic])))(); | 12 let __Tobool = () => (__Tobool = dart.constFn(dart.definiteFunctionType(core.b
ool, [], [dart.dynamic])))(); |
13 let __Todynamic$ = () => (__Todynamic$ = dart.constFn(dart.definiteFunctionTyp
e(dart.dynamic, [], {x: dart.dynamic, y: dart.dynamic})))(); | 13 let __ToString = () => (__ToString = dart.constFn(dart.definiteFunctionType(co
re.String, [], {x: dart.dynamic, y: dart.dynamic})))(); |
14 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); | 14 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
15 let dynamicTobool = () => (dynamicTobool = dart.constFn(dart.definiteFunctionT
ype(core.bool, [dart.dynamic])))(); | |
16 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); | 15 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
17 call_closurization_test.main = function() { | 16 call_closurization_test.main = function() { |
18 function bar(a) { | 17 function bar(a) { |
19 return typeof a == 'string'; | 18 return typeof a == 'string'; |
20 } | 19 } |
21 dart.fn(bar, dynamicTodynamic()); | 20 dart.fn(bar, dynamicTobool()); |
22 let bar_tearOff = dart.dload(bar, 'call'); | 21 let bar_tearOff = dart.dload(bar, 'call'); |
23 for (let i = 0; i < 20; i++) { | 22 for (let i = 0; i < 20; i++) { |
24 expect$.Expect.isFalse(dart.dcall(bar_tearOff, 1)); | 23 expect$.Expect.isFalse(dart.dcall(bar_tearOff, 1)); |
25 expect$.Expect.isTrue(dart.dsend(bar_tearOff, 'call', 'foo')); | 24 expect$.Expect.isTrue(dart.dsend(bar_tearOff, 'call', 'foo')); |
26 expect$.Expect.isFalse(dart.dsend(bar_tearOff, 'call', 1)); | 25 expect$.Expect.isFalse(dart.dsend(bar_tearOff, 'call', 1)); |
27 expect$.Expect.isTrue(dart.dcall(bar_tearOff, 'foo')); | 26 expect$.Expect.isTrue(dart.dcall(bar_tearOff, 'foo')); |
28 } | 27 } |
29 function opt_arg(a) { | 28 function opt_arg(a) { |
30 if (a === void 0) a = "a"; | 29 if (a === void 0) a = "a"; |
31 return typeof a == 'string'; | 30 return typeof a == 'string'; |
32 } | 31 } |
33 dart.fn(opt_arg, __Todynamic()); | 32 dart.fn(opt_arg, __Tobool()); |
34 let opt_arg_tearOff = dart.dload(opt_arg, 'call'); | 33 let opt_arg_tearOff = dart.dload(opt_arg, 'call'); |
35 for (let i = 0; i < 20; i++) { | 34 for (let i = 0; i < 20; i++) { |
36 expect$.Expect.isFalse(dart.dcall(opt_arg_tearOff, 1)); | 35 expect$.Expect.isFalse(dart.dcall(opt_arg_tearOff, 1)); |
37 expect$.Expect.isFalse(dart.dsend(opt_arg_tearOff, 'call', 1)); | 36 expect$.Expect.isFalse(dart.dsend(opt_arg_tearOff, 'call', 1)); |
38 expect$.Expect.isTrue(dart.dcall(opt_arg_tearOff)); | 37 expect$.Expect.isTrue(dart.dcall(opt_arg_tearOff)); |
39 expect$.Expect.isTrue(dart.dsend(opt_arg_tearOff, 'call')); | 38 expect$.Expect.isTrue(dart.dsend(opt_arg_tearOff, 'call')); |
40 expect$.Expect.isTrue(dart.dcall(opt_arg_tearOff, "b")); | 39 expect$.Expect.isTrue(dart.dcall(opt_arg_tearOff, "b")); |
41 expect$.Expect.isTrue(dart.dsend(opt_arg_tearOff, 'call', "b")); | 40 expect$.Expect.isTrue(dart.dsend(opt_arg_tearOff, 'call', "b")); |
42 } | 41 } |
43 function named_arg(opts) { | 42 function named_arg(opts) { |
44 let x = opts && 'x' in opts ? opts.x : 11; | 43 let x = opts && 'x' in opts ? opts.x : 11; |
45 let y = opts && 'y' in opts ? opts.y : 22; | 44 let y = opts && 'y' in opts ? opts.y : 22; |
46 return dart.str`${x}${y}`; | 45 return dart.str`${x}${y}`; |
47 } | 46 } |
48 dart.fn(named_arg, __Todynamic$()); | 47 dart.fn(named_arg, __ToString()); |
49 let named_arg_tearOff = dart.dload(named_arg, 'call'); | 48 let named_arg_tearOff = dart.dload(named_arg, 'call'); |
50 for (let i = 0; i < 20; i++) { | 49 for (let i = 0; i < 20; i++) { |
51 expect$.Expect.equals("1122", dart.dcall(named_arg_tearOff)); | 50 expect$.Expect.equals("1122", dart.dcall(named_arg_tearOff)); |
52 expect$.Expect.equals("1122", dart.dsend(named_arg_tearOff, 'call')); | 51 expect$.Expect.equals("1122", dart.dsend(named_arg_tearOff, 'call')); |
53 expect$.Expect.equals("4455", dart.dcall(named_arg_tearOff, {y: 55, x: 44}
)); | 52 expect$.Expect.equals("4455", dart.dcall(named_arg_tearOff, {y: 55, x: 44}
)); |
54 expect$.Expect.equals("4455", dart.dsend(named_arg_tearOff, 'call', {y: 55
, x: 44})); | 53 expect$.Expect.equals("4455", dart.dsend(named_arg_tearOff, 'call', {y: 55
, x: 44})); |
55 expect$.Expect.equals("4455", dart.dcall(named_arg_tearOff, {x: 44, y: 55}
)); | 54 expect$.Expect.equals("4455", dart.dcall(named_arg_tearOff, {x: 44, y: 55}
)); |
56 expect$.Expect.equals("4455", dart.dsend(named_arg_tearOff, 'call', {x: 44
, y: 55})); | 55 expect$.Expect.equals("4455", dart.dsend(named_arg_tearOff, 'call', {x: 44
, y: 55})); |
57 } | 56 } |
58 expect$.Expect.throws(dart.fn(() => dart.dsend(bar_tearOff, 'call'), VoidTov
oid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool())); | 57 expect$.Expect.throws(dart.fn(() => dart.dsend(bar_tearOff, 'call'), VoidTov
oid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool())); |
59 expect$.Expect.throws(dart.fn(() => dart.dsend(opt_arg_tearOff, 'call', {x:
"p"}), VoidTovoid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool()
)); | 58 expect$.Expect.throws(dart.fn(() => dart.dsend(opt_arg_tearOff, 'call', {x:
"p"}), VoidTovoid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool()
)); |
60 expect$.Expect.throws(dart.fn(() => dart.dsend(named_arg_tearOff, 'call', "p
", "q"), VoidTovoid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool
())); | 59 expect$.Expect.throws(dart.fn(() => dart.dsend(named_arg_tearOff, 'call', "p
", "q"), VoidTovoid()), dart.fn(e => core.NoSuchMethodError.is(e), dynamicTobool
())); |
61 }; | 60 }; |
62 dart.fn(call_closurization_test.main, VoidTodynamic()); | 61 dart.fn(call_closurization_test.main, VoidTodynamic()); |
63 // Exports: | 62 // Exports: |
64 exports.call_closurization_test = call_closurization_test; | 63 exports.call_closurization_test = call_closurization_test; |
65 }); | 64 }); |
OLD | NEW |