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

Unified Diff: test/mjsunit/harmony/array-find.js

Issue 1165003005: [es6] Array.prototype.find and findIndex should include holes (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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/harmony-array.js ('k') | test/mjsunit/harmony/array-findindex.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/array-find.js
diff --git a/test/mjsunit/harmony/array-find.js b/test/mjsunit/harmony/array-find.js
index eb3208227706e6e3654549dac10d47b8197728dd..44fc78292a81123a9535999717c1085159af9874 100644
--- a/test/mjsunit/harmony/array-find.js
+++ b/test/mjsunit/harmony/array-find.js
@@ -201,7 +201,7 @@ assertEquals(22, a.find(function(val) { return 22 === val; }), undefined);
//
-// Test predicate is only called for existing elements
+// Test predicate is called for holes
//
(function() {
var a = new Array(30);
@@ -211,7 +211,27 @@ assertEquals(22, a.find(function(val) { return 22 === val; }), undefined);
var count = 0;
a.find(function() { count++; return false; });
- assertEquals(3, count);
+ assertEquals(30, count);
+})();
+
+
+(function() {
+ var a = [0, 1, , 3];
+ var count = 0;
+ var found = a.find(function(val) { return val === undefined; });
+ assertEquals(undefined, found);
+})();
+
+
+(function() {
+ var a = [0, 1, , 3];
+ a.__proto__ = {
+ __proto__: Array.prototype,
+ 2: 42,
+ };
+ var count = 0;
+ var found = a.find(function(val) { return val === 42; });
+ assertEquals(42, found);
})();
« no previous file with comments | « src/harmony-array.js ('k') | test/mjsunit/harmony/array-findindex.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698