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

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

Issue 553413002: Array.prototype.{every, filter, find, findIndex, forEach, map, some}: Use fresh primitive wrapper f… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created wrapper. Added tests for strict mode. Fixed nits. Created 6 years, 3 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
« test/mjsunit/array-iteration.js ('K') | « test/mjsunit/harmony/array-find.js ('k') | no next file » | 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 a33849dab393afd1f233bd9ec5461d0c489e794a..1a4ed5865c2be04ec6edc8a8c9c35d4ea1e296d2 100644
--- a/test/mjsunit/harmony/array-findindex.js
+++ b/test/mjsunit/harmony/array-findindex.js
@@ -237,6 +237,24 @@ assertEquals(3, a.findIndex(function(val) { return 24 === val; }));
return this.elementAt(key) === val;
}, thisArg);
assertEquals(1, index);
+
+ // When evaluating 'this', primitive values should be coerced to an object.
+ // See ECMA-262, Annex C.
+ a = [];
+ [1, 2].findIndex(function() { a.push(this) }, "");
+ assertTrue(a[0] !== a[1]);
+
+ // When evaluating 'this', non-primitive values are not coerced to an object.
+ a = [];
+ [1, 2].findIndex(function() { a.push(this) }, {});
+ assertFalse(a[0] !== a[1]);
+
+ // In strict mode, when evaluating 'this', primitive values should not be
+ // coerced to an object.
+ a = [];
+ [1, 2].findIndex(function() { 'use strict'; a.push(this); }, "");
+ assertTrue(a[0] === "" && a[0] === a[1]);
+
})();
// Test exceptions
« test/mjsunit/array-iteration.js ('K') | « test/mjsunit/harmony/array-find.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698