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

Unified 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: Only transition map to prototype if the prototype is not already correct 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/function-bind.js
diff --git a/test/mjsunit/function-bind.js b/test/mjsunit/function-bind.js
index 23dacf157e6ea85064d4b69a1718c1ddcea1470e..ca1ed7e489e64f8d5d24a46106025fcca3b2fc1b 100644
--- a/test/mjsunit/function-bind.js
+++ b/test/mjsunit/function-bind.js
@@ -25,6 +25,8 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// Flags: --allow-natives-syntax
+
// Tests the Function.prototype.bind (ES 15.3.4.5) method.
// Simple tests.
@@ -298,3 +300,20 @@ assertThrows(function() { f.arguments = 42; }, TypeError);
// the caller is strict and the callee isn't. A bound function is built-in,
// but not considered strict.
(function foo() { return foo.caller; }).bind()();
+
+
+(function TestProtoIsPreserved() {
+ function fun() {}
+
+ function proto() {}
+ Object.setPrototypeOf(fun, proto);
+ var bound = fun.bind({});
+ assertEquals(proto, Object.getPrototypeOf(bound));
+
+ var bound2 = fun.bind({});
+ assertTrue(%HaveSameMap(new bound, new bound2));
+
+ Object.setPrototypeOf(fun, null);
+ bound = Function.prototype.bind.call(fun, {});
+ assertEquals(null, Object.getPrototypeOf(bound));
+})();
« no previous file with comments | « src/runtime/runtime-function.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698