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

Unified Diff: test/mjsunit/harmony/typedarrays-every.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/typedarrays-every.js
diff --git a/test/mjsunit/harmony/typedarrays-every.js b/test/mjsunit/harmony/typedarrays-every.js
index c81fd966ca623ae268b1d3b257fc07014574bf5f..e6acb566ac61a8adbf96a8b374b509106876cce7 100644
--- a/test/mjsunit/harmony/typedarrays-every.js
+++ b/test/mjsunit/harmony/typedarrays-every.js
@@ -135,6 +135,16 @@ function TestTypedArrayForEach(constructor) {
constructor.prototype.every.call(a, function (x) { count++; return true; });
assertEquals(a.length, count);
}
+
+ // Shadowing length doesn't affect every, unlike Array.prototype.every
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ var x = 0;
+ assertEquals(a.every(function(elt) { x += elt; return true; }), true);
+ assertEquals(x, 3);
+ assertEquals(Array.prototype.every.call(a,
+ function(elt) { x += elt; return true; }), true);
+ assertEquals(x, 4);
}
for (i = 0; i < typedArrayConstructors.length; i++) {

Powered by Google App Engine
This is Rietveld 408576698