Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: test/mjsunit/function-bind.js

Issue 1217603005: [es6] Function bind should preserve [[Prototype]] (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 assertThrows(function() { return f.caller; }, TypeError); 292 assertThrows(function() { return f.caller; }, TypeError);
293 assertThrows(function() { f.caller = 42; }, TypeError); 293 assertThrows(function() { f.caller = 42; }, TypeError);
294 assertThrows(function() { return f.arguments; }, TypeError); 294 assertThrows(function() { return f.arguments; }, TypeError);
295 assertThrows(function() { f.arguments = 42; }, TypeError); 295 assertThrows(function() { f.arguments = 42; }, TypeError);
296 296
297 // Shouldn't throw. Accessing the functions caller must throw if 297 // Shouldn't throw. Accessing the functions caller must throw if
298 // the caller is strict and the callee isn't. A bound function is built-in, 298 // the caller is strict and the callee isn't. A bound function is built-in,
299 // but not considered strict. 299 // but not considered strict.
300 (function foo() { return foo.caller; }).bind()(); 300 (function foo() { return foo.caller; }).bind()();
301
302
303 (function TestProtoIsPreserved() {
304 function fun() {}
305
306 function proto() {}
307 Object.setPrototypeOf(fun, proto);
308 var bound = fun.bind({});
309 assertEquals(proto, Object.getPrototypeOf(bound));
310
311 Object.setPrototypeOf(fun, null);
312 bound = Function.prototype.bind.call(fun, {});
313 assertEquals(null, Object.getPrototypeOf(bound));
314 })();
OLDNEW
« src/runtime/runtime-function.cc ('K') | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698