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

Unified Diff: test/mjsunit/harmony/typedarrays-foreach.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-foreach.js
diff --git a/test/mjsunit/harmony/typedarrays-foreach.js b/test/mjsunit/harmony/typedarrays-foreach.js
index 0d34c78efb20f87ddd016c509d8a65dd5aecf592..e1d375da1a08c9e5730436492f89fdc761db791e 100644
--- a/test/mjsunit/harmony/typedarrays-foreach.js
+++ b/test/mjsunit/harmony/typedarrays-foreach.js
@@ -138,6 +138,16 @@ function TestTypedArrayForEach(constructor) {
constructor.prototype.forEach.call(a, function (x) { count++ });
assertEquals(a.length, count);
}
+
+ // Shadowing length doesn't affect forEach, unlike Array.prototype.forEach
+ a = new constructor([1, 2]);
+ Object.defineProperty(a, 'length', {value: 1});
+ var x = 0;
+ assertEquals(a.forEach(function(elt) { x += elt; }), undefined);
+ assertEquals(x, 3);
+ assertEquals(Array.prototype.forEach.call(a,
+ function(elt) { x += elt; }), undefined);
+ assertEquals(x, 4);
}
for (i = 0; i < typedArrayConstructors.length; i++) {
« test/mjsunit/harmony/typedarray-fill.js ('K') | « test/mjsunit/harmony/typedarrays-every.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698