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

Unified Diff: test/mjsunit/harmony/array-findindex.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 | « test/mjsunit/harmony/array-find.js ('k') | test/test262-es6/test262-es6.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/array-findindex.js
diff --git a/test/mjsunit/harmony/array-findindex.js b/test/mjsunit/harmony/array-findindex.js
index a5df05a05c0a2b0fdd1505763dc3773ed9991a00..7068a9cb4005935b2a58af05240e6062627b6cc8 100644
--- a/test/mjsunit/harmony/array-findindex.js
+++ b/test/mjsunit/harmony/array-findindex.js
@@ -201,7 +201,7 @@ assertEquals(3, a.findIndex(function(val) { return 24 === val; }));
//
-// 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(3, a.findIndex(function(val) { return 24 === val; }));
var count = 0;
a.findIndex(function() { count++; return false; });
- assertEquals(3, count);
+ assertEquals(30, count);
+})();
+
+
+(function() {
+ var a = [0, 1, , 3];
+ var count = 0;
+ var index = a.findIndex(function(val) { return val === undefined; });
+ assertEquals(2, index);
+})();
+
+
+(function() {
+ var a = [0, 1, , 3];
+ a.__proto__ = {
+ __proto__: Array.prototype,
+ 2: 42,
+ };
+ var count = 0;
+ var index = a.findIndex(function(val) { return val === 42; });
+ assertEquals(2, index);
})();
« no previous file with comments | « test/mjsunit/harmony/array-find.js ('k') | test/test262-es6/test262-es6.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698