OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/generic_tearoff_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__generic_tearoff_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const math = dart_sdk.math; |
| 8 const dart = dart_sdk.dart; |
| 9 const dartx = dart_sdk.dartx; |
| 10 const expect$ = expect.expect; |
| 11 const generic_tearoff_test = Object.create(null); |
| 12 let TAndTToT = () => (TAndTToT = dart.constFn(dart.functionType(T => [T, [T, T
]])))(); |
| 13 let VoidTovoid = () => (VoidTovoid = dart.constFn(dart.definiteFunctionType(da
rt.void, [])))(); |
| 14 let Int2Int2IntTovoid = () => (Int2Int2IntTovoid = dart.constFn(dart.definiteF
unctionType(dart.void, [generic_tearoff_test.Int2Int2Int])))(); |
| 15 let FnTovoid = () => (FnTovoid = dart.constFn(dart.definiteFunctionType(dart.v
oid, [TAndTToT()])))(); |
| 16 let TAndTToT$ = () => (TAndTToT$ = dart.constFn(dart.definiteFunctionType(T =>
[T, [T, T]])))(); |
| 17 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 18 generic_tearoff_test.C = class C extends core.Object { |
| 19 m(T) { |
| 20 return (x, y) => { |
| 21 return math.min(T)(x, y); |
| 22 }; |
| 23 } |
| 24 m2(x, y) { |
| 25 return math.min(core.int)(x, y); |
| 26 } |
| 27 }; |
| 28 dart.setSignature(generic_tearoff_test.C, { |
| 29 methods: () => ({ |
| 30 m: dart.definiteFunctionType(T => [T, [T, T]]), |
| 31 m2: dart.definiteFunctionType(core.int, [core.int, core.int]) |
| 32 }) |
| 33 }); |
| 34 generic_tearoff_test.Int2Int2Int = dart.typedef('Int2Int2Int', () => dart.func
tionType(core.int, [core.int, core.int])); |
| 35 generic_tearoff_test._test = function(f) { |
| 36 let y = f(123, 456); |
| 37 expect$.Expect.equals(y, 123); |
| 38 expect$.Expect.throws(dart.fn(() => dart.dgcall(f, [core.int], 123, 456), Vo
idTovoid())); |
| 39 }; |
| 40 dart.fn(generic_tearoff_test._test, Int2Int2IntTovoid()); |
| 41 generic_tearoff_test._testParam = function(minFn) { |
| 42 generic_tearoff_test._test(dart.gbind(minFn, core.int)); |
| 43 }; |
| 44 dart.fn(generic_tearoff_test._testParam, FnTovoid()); |
| 45 generic_tearoff_test.main = function() { |
| 46 generic_tearoff_test._test(dart.gbind(math.min, core.int)); |
| 47 generic_tearoff_test._test(dart.gbind(math.min, core.int)); |
| 48 generic_tearoff_test._test(dart.gbind(dart.bind(new generic_tearoff_test.C()
, 'm'), core.int)); |
| 49 function m(T) { |
| 50 return (x, y) => { |
| 51 return math.min(T)(x, y); |
| 52 }; |
| 53 } |
| 54 dart.fn(m, TAndTToT$()); |
| 55 generic_tearoff_test._test(dart.gbind(m, core.int)); |
| 56 let f = math.min; |
| 57 generic_tearoff_test._test(dart.gbind(f, core.int)); |
| 58 generic_tearoff_test._testParam(math.min); |
| 59 expect$.Expect.equals(123, dart.dgsend(new generic_tearoff_test.C(), [core.i
nt], 'm', 123, 456)); |
| 60 expect$.Expect.throws(dart.fn(() => dart.dgsend(new generic_tearoff_test.C()
, [core.int], 'm2', 123, 456), VoidTovoid())); |
| 61 }; |
| 62 dart.fn(generic_tearoff_test.main, VoidTodynamic()); |
| 63 // Exports: |
| 64 exports.generic_tearoff_test = generic_tearoff_test; |
| 65 }); |
OLD | NEW |