OLD | NEW |
(Empty) | |
| 1 dart_library.library('language/call_operator_test', null, /* Imports */[ |
| 2 'dart_sdk', |
| 3 'expect' |
| 4 ], function load__call_operator_test(exports, dart_sdk, expect) { |
| 5 'use strict'; |
| 6 const core = dart_sdk.core; |
| 7 const dart = dart_sdk.dart; |
| 8 const dartx = dart_sdk.dartx; |
| 9 const expect$ = expect.expect; |
| 10 const call_operator_test = Object.create(null); |
| 11 let VoidTodynamic = () => (VoidTodynamic = dart.constFn(dart.definiteFunctionT
ype(dart.dynamic, [])))(); |
| 12 call_operator_test.A1 = dart.callableClass(function A1(...args) { |
| 13 const self = this; |
| 14 function call(...args) { |
| 15 return self.call.apply(self, args); |
| 16 } |
| 17 call.__proto__ = this.__proto__; |
| 18 call.new.apply(call, args); |
| 19 return call; |
| 20 }, class A1 extends core.Object { |
| 21 call() { |
| 22 return 42; |
| 23 } |
| 24 }); |
| 25 dart.setSignature(call_operator_test.A1, { |
| 26 methods: () => ({call: dart.definiteFunctionType(dart.dynamic, [])}) |
| 27 }); |
| 28 call_operator_test.A2 = dart.callableClass(function A2(...args) { |
| 29 const self = this; |
| 30 function call(...args) { |
| 31 return self.call.apply(self, args); |
| 32 } |
| 33 call.__proto__ = this.__proto__; |
| 34 call.new.apply(call, args); |
| 35 return call; |
| 36 }, class A2 extends core.Object { |
| 37 call() { |
| 38 return 35; |
| 39 } |
| 40 }); |
| 41 dart.setSignature(call_operator_test.A2, { |
| 42 methods: () => ({call: dart.definiteFunctionType(core.int, [])}) |
| 43 }); |
| 44 call_operator_test.B = dart.callableClass(function B(...args) { |
| 45 const self = this; |
| 46 function call(...args) { |
| 47 return self.call.apply(self, args); |
| 48 } |
| 49 call.__proto__ = this.__proto__; |
| 50 call.new.apply(call, args); |
| 51 return call; |
| 52 }, class B extends core.Object { |
| 53 call() { |
| 54 return 28; |
| 55 } |
| 56 }); |
| 57 dart.setSignature(call_operator_test.B, { |
| 58 methods: () => ({call: dart.definiteFunctionType(dart.dynamic, [])}) |
| 59 }); |
| 60 call_operator_test.C = dart.callableClass(function C(...args) { |
| 61 const self = this; |
| 62 function call(...args) { |
| 63 return self.call.apply(self, args); |
| 64 } |
| 65 call.__proto__ = this.__proto__; |
| 66 call.new.apply(call, args); |
| 67 return call; |
| 68 }, class C extends core.Object { |
| 69 call(arg) { |
| 70 return 7 * dart.notNull(core.num._check(arg)); |
| 71 } |
| 72 }); |
| 73 dart.setSignature(call_operator_test.C, { |
| 74 methods: () => ({call: dart.definiteFunctionType(dart.dynamic, [dart.dynamic
])}) |
| 75 }); |
| 76 call_operator_test.D = dart.callableClass(function D(...args) { |
| 77 const self = this; |
| 78 function call(...args) { |
| 79 return self.call.apply(self, args); |
| 80 } |
| 81 call.__proto__ = this.__proto__; |
| 82 call.new.apply(call, args); |
| 83 return call; |
| 84 }, class D extends core.Object { |
| 85 call(arg) { |
| 86 if (arg === void 0) arg = 6; |
| 87 return 7 * dart.notNull(core.num._check(arg)); |
| 88 } |
| 89 }); |
| 90 dart.setSignature(call_operator_test.D, { |
| 91 methods: () => ({call: dart.definiteFunctionType(dart.dynamic, [], [dart.dyn
amic])}) |
| 92 }); |
| 93 call_operator_test.E = dart.callableClass(function E(...args) { |
| 94 const self = this; |
| 95 function call(...args) { |
| 96 return self.call.apply(self, args); |
| 97 } |
| 98 call.__proto__ = this.__proto__; |
| 99 call.new.apply(call, args); |
| 100 return call; |
| 101 }, class E extends core.Object { |
| 102 call(str, opts) { |
| 103 let count = opts && 'count' in opts ? opts.count : 1; |
| 104 let buffer = new core.StringBuffer(); |
| 105 for (let i = 0; i < dart.notNull(count); i++) { |
| 106 buffer.write(str); |
| 107 if (i < dart.notNull(count) - 1) { |
| 108 buffer.write(":"); |
| 109 } |
| 110 } |
| 111 return buffer.toString(); |
| 112 } |
| 113 }); |
| 114 dart.setSignature(call_operator_test.E, { |
| 115 methods: () => ({call: dart.definiteFunctionType(core.String, [core.String],
{count: core.int})}) |
| 116 }); |
| 117 call_operator_test.main = function() { |
| 118 let a1 = new call_operator_test.A1(); |
| 119 expect$.Expect.equals(42, a1()); |
| 120 expect$.Expect.equals(42, a1.call()); |
| 121 let a2 = new call_operator_test.A2(); |
| 122 expect$.Expect.equals(35, a2()); |
| 123 expect$.Expect.equals(35, a2.call()); |
| 124 let b = new call_operator_test.B(); |
| 125 expect$.Expect.equals(28, b()); |
| 126 expect$.Expect.equals(28, b.call()); |
| 127 let c = new call_operator_test.C(); |
| 128 expect$.Expect.equals(42, dart.dcall(c, 6)); |
| 129 expect$.Expect.equals(42, c.call(6)); |
| 130 let d = new call_operator_test.D(); |
| 131 expect$.Expect.equals(42, dart.dcall(d)); |
| 132 expect$.Expect.equals(7, dart.dcall(d, 1)); |
| 133 expect$.Expect.equals(14, dart.dcall(d, 2)); |
| 134 expect$.Expect.equals(42, d.call()); |
| 135 expect$.Expect.equals(7, d.call(1)); |
| 136 expect$.Expect.equals(14, d.call(2)); |
| 137 let e = new call_operator_test.E(); |
| 138 expect$.Expect.equals("foo", e("foo")); |
| 139 expect$.Expect.equals("foo:foo", e("foo", {count: 2})); |
| 140 expect$.Expect.equals("foo:foo:foo", e("foo", {count: 3})); |
| 141 expect$.Expect.equals("foo", e.call("foo")); |
| 142 expect$.Expect.equals("foo:foo", e.call("foo", {count: 2})); |
| 143 expect$.Expect.equals("foo:foo:foo", e.call("foo", {count: 3})); |
| 144 expect$.Expect.isTrue(core.Function.is(a1)); |
| 145 expect$.Expect.isTrue(core.Function.is(e)); |
| 146 }; |
| 147 dart.fn(call_operator_test.main, VoidTodynamic()); |
| 148 // Exports: |
| 149 exports.call_operator_test = call_operator_test; |
| 150 }); |
OLD | NEW |