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

Unified Diff: test/mjsunit/harmony/array-find.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: Fixed nits from last patch. Created 6 years, 2 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/es6/collections.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 9f5750eca05d03a66c979902b021c1564672b893..eb3208227706e6e3654549dac10d47b8197728dd 100644
--- a/test/mjsunit/harmony/array-find.js
+++ b/test/mjsunit/harmony/array-find.js
@@ -237,6 +237,24 @@ assertEquals(22, a.find(function(val) { return 22 === val; }), undefined);
return this.elementAt(key) === val;
}, thisArg);
assertEquals("b", found);
+
+ // Create a new object in each function call when receiver is a
+ // primitive value. See ECMA-262, Annex C.
+ a = [];
+ [1, 2].find(function() { a.push(this) }, "");
+ assertTrue(a[0] !== a[1]);
+
+ // Do not create a new object otherwise.
+ a = [];
+ [1, 2].find(function() { a.push(this) }, {});
+ assertEquals(a[0], a[1]);
+
+ // In strict mode primitive values should not be coerced to an object.
+ a = [];
+ [1, 2].find(function() { 'use strict'; a.push(this); }, "");
+ assertEquals("", a[0]);
+ assertEquals(a[0], a[1]);
+
})();
// Test exceptions
« no previous file with comments | « test/mjsunit/es6/collections.js ('k') | test/mjsunit/harmony/array-findindex.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698