mirrored from https://chromium.googlesource.com/v8/v8.git
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[builtins] Allow bound function / proxy
add
in collection ctors
Bug: chromium:804801 Change-Id: I2d54e98df09b0ed5ccfcddd0815ad162641e03d6 Reviewed-on: https://chromium-review.googlesource.com/883121 Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Peter Marshall <petermarshall@chromium.org> Commit-Queue: Jakob Gruber <jgruber@chromium.org> Cr-Commit-Position: refs/heads/master@{#50827}
- Loading branch information
Showing
2 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
// Copyright 2018 the V8 project authors. All rights reserved. | |||
// Use of this source code is governed by a BSD-style license that can be | |||
// found in the LICENSE file. | |||
|
|||
function f() { return 42; } | |||
const bound_function = f.bind(); | |||
const callable_proxy = new Proxy(function(){}.__proto__, {}); | |||
|
|||
function testSet(ctor) { | |||
new ctor([]); | |||
new ctor([{},{}]); | |||
} | |||
|
|||
function testMap(ctor) { | |||
new ctor([]); | |||
new ctor([[{},{}],[{},{}]]); | |||
} | |||
|
|||
function testAllVariants(set_or_add_function) { | |||
Set.prototype.add = set_or_add_function; | |||
testSet(Set); | |||
|
|||
WeakSet.prototype.add = set_or_add_function; | |||
testSet(WeakSet); | |||
|
|||
Map.prototype.set = set_or_add_function; | |||
testMap(Map); | |||
|
|||
WeakMap.prototype.set = set_or_add_function; | |||
testMap(WeakMap); | |||
} | |||
|
|||
testAllVariants(bound_function); | |||
testAllVariants(callable_proxy); |