Home | History | Annotate | Download | only in harmony

Lines Matching refs:Function

33 function CreateFrozen(handler, callTrap, constructTrap) {
34 if (handler.fix === undefined) handler.fix = function() { return {} }
41 // Ensures that checking the "length" property of a function proxy doesn't
44 get : function(r, n) { return n == "length" ? 2 : undefined }
48 // Calling (call, Function.prototype.call, Function.prototype.apply,
49 // Function.prototype.bind).
54 function TestCall(isStrict, callTrap) {
60 get: function(r, k) {
61 return k == "length" ? 2 : Function.prototype[k]
97 assertEquals(42, Function.prototype.call.call(f, o, 20, 22))
100 assertEquals(43, Function.prototype.call.call(f, null, 20, 23))
102 assertEquals(44, Function.prototype.call.call(f, 2, 21, 23))
108 assertEquals(32, Function.prototype.apply.call(f, o, [17, 15]))
129 var ff = Function.prototype.bind.call(f, o, 12)
135 assertEquals(33, Function.prototype.call.call(ff, {}, 21))
138 assertEquals(32, Function.prototype.apply.call(ff, {}, [20]))
159 var fff = Function.prototype.bind.call(ff, o, 30)
165 assertEquals(42, Function.prototype.call.call(fff, {}))
168 assertEquals(42, Function.prototype.apply.call(fff, {}))
210 assertEquals(42, Function.prototype.call.call(f, o, 20, 22))
213 assertEquals(32, Function.prototype.apply.call(f, o, [17, 15]))
226 TestCall(false, function(x, y) {
231 TestCall(true, function(x, y) {
237 TestCall(false, function() {
242 TestCall(false, Proxy.createFunction(handler, function(x, y) {
247 TestCall(true, Proxy.createFunction(handler, function(x, y) {
253 TestCall(false, CreateFrozen(handler, function(x, y) {
262 function TestCallIntrinsic(type, callTrap) {
272 TestCallIntrinsic("function", Function)
278 function TestCallThrow(callTrap) {
280 assertThrows(function(){ f(11) }, "myexn")
281 assertThrows(function(){ ({x: f}).x(11) }, "myexn")
282 assertThrows(function(){ ({x: f})["x"](11) }, "myexn")
283 assertThrows(function(){ Function.prototype.call.call(f, {}, 2) }, "myexn")
284 assertThrows(function(){ Function.prototype.apply.call(f, {}, [1]) }, "myexn")
285 assertThrows(function(){ %Call({}, f) }, "myexn")
286 assertThrows(function(){ %Call({}, 1, 2, f) }, "myexn")
287 assertThrows(function(){ %Apply({}, f, [], 3, 0) }, "myexn")
288 assertThrows(function(){ %Apply({}, f, [3, 4], 0, 1) }, "myexn")
289 assertThrows(function(){ %_CallFunction({}, f) }, "myexn")
290 assertThrows(function(){ %_CallFunction({}, 1, 2, f) }, "myexn")
293 assertThrows(function(){ f(11) }, "myexn")
294 assertThrows(function(){ ({x: f}).x(11) }, "myexn")
295 assertThrows(function(){ ({x: f})["x"](11) }, "myexn")
296 assertThrows(function(){ Function.prototype.call.call(f, {}, 2) }, "myexn")
297 assertThrows(function(){ Function.prototype.apply.call(f, {}, [1]) }, "myexn")
298 assertThrows(function(){ %Call({}, f) }, "myexn")
299 assertThrows(function(){ %Call({}, 1, 2, f) }, "myexn")
300 assertThrows(function(){ %Apply({}, f, [], 3, 0) }, "myexn")
301 assertThrows(function(){ %Apply({}, f, [3, 4], 0, 1) }, "myexn")
302 assertThrows(function(){ %_CallFunction({}, f) }, "myexn")
303 assertThrows(function(){ %_CallFunction({}, 1, 2, f) }, "myexn")
306 TestCallThrow(function() { throw "myexn" })
307 TestCallThrow(Proxy.createFunction({}, function() { throw "myexn" }))
308 TestCallThrow(CreateFrozen({}, function() { throw "myexn" }))
318 fix: function() { return { prototype: { value: prototype } }; },
319 get: function(r, n) {
327 fix: function() { return { length: { value: 2 } } },
328 get: function(r, n) {
335 function ReturnUndef(x, y) {
341 function ReturnThis(x, y) {
348 function ReturnNew(x, y) {
354 function ReturnNewWithProto(x, y) {
362 function TestConstruct(proto, constructTrap) {
367 function TestConstruct2(proto, constructTrap, handler) {
368 var f = Proxy.createFunction(handler, function() {}, constructTrap)
374 var f = CreateFrozen(handler, function() {}, constructTrap)
394 function TestConstructFromCall(proto, returnsThis, callTrap) {
399 function TestConstructFromCall2(proto, returnsThis, callTrap, handler) {
477 function TestConstructThrow(trap) {
478 TestConstructThrow2(Proxy.createFunction({ fix: function() {return {};} },
480 TestConstructThrow2(Proxy.createFunction({ fix: function() {return {};} },
481 function() {},
485 function TestConstructThrow2(f) {
486 assertThrows(function(){ new f(11) }, "myexn")
488 assertThrows(function(){ new f(11) }, "myexn")
491 function() { throw "myexn" })
492 TestConstructThrow(Proxy.createFunction({}, function() { throw "myexn" }))
493 TestConstructThrow(CreateFrozen({}, function() { throw "myexn" }))
497 // Using function proxies as getters and setters.
502 function TestAccessorCall(getterCallTrap, setterCallTrap) {
503 var handler = { fix: function() { return {} } }
555 assertThrows(function() { "use strict"; o.b = 51 }, TypeError)
577 assertThrows(function() { "use strict"; oo.b = 61 }, TypeError)
593 function() { receiver = this; return 42 },
594 function(x) { receiver = this; value = x }
598 function() { "use strict"; receiver = this; return 42 },
599 function(x) { "use strict"; receiver = this; value = x }
603 Proxy.createFunction({}, function() { receiver = this; return 42 }),
604 Proxy.createFunction({}, function(x) { receiver = this; value = x })
608 CreateFrozen({}, function() { receiver = this; return 42 }),
609 CreateFrozen({}, function(x) { receiver = this; value = x })
614 // Passing a proxy function to higher-order library functions.
616 function TestHigherOrder(f) {
623 TestHigherOrder(function(x) { return x })
624 TestHigherOrder(function(x) { "use strict"; return x })
625 TestHigherOrder(Proxy.createFunction({}, function(x) { return x }))
626 TestHigherOrder(CreateFrozen({}, function(x) { return x }))
630 // TODO(rossberg): Ultimately, I want to have the following test function
634 function TestCalls() {
636 get: function(r, k) {
637 return k == "length" ? 2 : Function.prototype[k]
640 var bind = Function.prototype.bind
644 function(x, y) {
647 function(x, y) { "use strict";
650 function() {
654 Proxy.createFunction(handler, function(x, y) {
657 Proxy.createFunction(handler, function() {
661 Proxy.createFunction(handler, function(x, y) { "use strict"
664 CreateFrozen(handler, function(x, y) {
667 CreateFrozen(handler, function(x, y) { "use strict"
672 function(trap) { return trap },
673 function(trap) { return CreateFrozen({}, callTrap) },
674 function(trap) { return Proxy.createFunction(handler, callTrap) },
675 function(trap) {
678 function(trap) {
683 function(f, o, x, y) { return f },
684 function(f, o, x, y) { return bind.call(f, o) },
685 function(f, o, x, y) { return bind.call(f, o, x) },
686 function(f, o, x, y) { return bind.call(f, o, x, y) },
687 function(f, o, x, y) { return bind.call(f, o, x, y, 5) },
688 function(f, o, x, y) { return bind.call(bind.call(f, o), {}, x, y) },
689 function(f, o, x, y) { return bind.call(bind.call(f, o, x), {}, y) },
690 function(f, o, x, y) { return bind.call(bind.call(f, o, x, y), {}, 5) },
693 function(f, x, y) { return f(x, y) },
694 function(f, x, y) { var g = f; return g(x, y) },
695 function(f, x, y) { with ({}) return f(x, y) },
696 function(f, x, y) { var g = f; with ({}) return g(x, y) },
697 function(f, x, y, o) { with (o) return f(x, y) },
698 function(f, x, y, o) { return f.call(o, x, y) },
699 function(f, x, y, o) { return f.apply(o, [x, y]) },
700 function(f, x, y, o) { return Function.prototype.call.call(f, o, x, y) },
701 function(f, x, y, o) { return Function.prototype.apply.call(f, o, [x, y]) },
702 function(f, x, y, o) { return %_CallFunction(o, x, y, f) },
703 function(f, x, y, o) { return %Call(o, x, y, f) },
704 function(f, x, y, o) { return %Apply(f, o, [null, x, y, null], 1, 2) },
705 function(f, x, y, o) { return %Apply(f, o, arguments, 2, 2) },
706 function(f, x, y, o) { if (typeof o == "object") return o.f(x, y) },
707 function(f, x, y, o) { if (typeof o == "object") return o["f"](x, y) },
708 function(f, x, y, o) { if (typeof o == "object") return (1, o).f(x, y) },
709 function(f, x, y, o) { if (typeof o == "object") return (1, o)["f"](x, y) },