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

Unified Diff: test/mjsunit/harmony/typedarray-findindex.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-findindex.js
diff --git a/test/mjsunit/harmony/typedarray-findindex.js b/test/mjsunit/harmony/typedarray-findindex.js
index 5a0afb4e0b9082a904f449632609cbd4ad157531..1634448711d315b998998209329178fa0ad27283 100644
--- a/test/mjsunit/harmony/typedarray-findindex.js
+++ b/test/mjsunit/harmony/typedarray-findindex.js
@@ -176,4 +176,14 @@ assertThrows('new constructor([]).findIndex({})', TypeError);
assertThrows('new constructor([]).findIndex([])', TypeError);
assertThrows('new constructor([]).findIndex(/\d+/)', TypeError);
+// Shadowing length doesn't affect findIndex, unlike Array.prototype.findIndex
+a = new constructor([1, 2]);
+Object.defineProperty(a, 'length', {value: 1});
+var x = 0;
+assertEquals(a.findIndex(function(elt) { x += elt; return false; }), -1);
+assertEquals(x, 3);
+assertEquals(Array.prototype.findIndex.call(a,
+ function(elt) { x += elt; return false; }), -1);
+assertEquals(x, 4);
+
}

Powered by Google App Engine
This is Rietveld 408576698