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

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

Issue 1130413010: Test that TypedArray methods don't read length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
Index: test/mjsunit/harmony/typedarray-find.js
diff --git a/test/mjsunit/harmony/typedarray-find.js b/test/mjsunit/harmony/typedarray-find.js
index 5e3512571868c4454a147930bcc820b5b75f010e..3b7ba1e0e9194e935474ec43fc12cb3179201798 100644
--- a/test/mjsunit/harmony/typedarray-find.js
+++ b/test/mjsunit/harmony/typedarray-find.js
@@ -176,4 +176,14 @@ assertThrows('new constructor([]).find({})', TypeError);
assertThrows('new constructor([]).find([])', TypeError);
assertThrows('new constructor([]).find(/\d+/)', TypeError);
+// Shadowing length doesn't affect find, unlike Array.prototype.find
+a = new constructor([1, 2]);
+Object.defineProperty(a, 'length', {value: 1});
+var x = 0;
+assertEquals(a.find(function(elt) { x += elt; return false; }), undefined);
+assertEquals(x, 3);
+assertEquals(Array.prototype.find.call(a,
+ function(elt) { x += elt; return false; }), undefined);
+assertEquals(x, 4);
+
}

Powered by Google App Engine
This is Rietveld 408576698