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

Unified Diff: test/mjsunit/harmony/typedarrays.js

Issue 14857002: Allow pathological zero-length typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 8 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 | « src/typedarray.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/typedarrays.js
diff --git a/test/mjsunit/harmony/typedarrays.js b/test/mjsunit/harmony/typedarrays.js
index 21c6054072a8f4875af75c9b34120133ff369285..ca76fe7bdfdd6dfdb8b5f5f04b36eb461de91fb6 100644
--- a/test/mjsunit/harmony/typedarrays.js
+++ b/test/mjsunit/harmony/typedarrays.js
@@ -191,7 +191,13 @@ function TestTypedArray(proto, elementSize, typicalElement) {
assertSame(typicalElement, a4[i]);
}
- assertThrows(function () { new proto(ab, 256*elementSize); }, RangeError);
+ var aAtTheEnd = new proto(ab, 256*elementSize);
+ assertSame(elementSize, aAtTheEnd.BYTES_PER_ELEMENT);
+ assertSame(0, aAtTheEnd.length);
+ assertSame(0, aAtTheEnd.byteLength);
+ assertSame(256*elementSize, aAtTheEnd.byteOffset);
+
+ assertThrows(function () { new proto(ab, 257*elementSize); }, RangeError);
assertThrows(
function () { new proto(ab, 128*elementSize, 192); },
RangeError);
@@ -229,6 +235,14 @@ function TestTypedArray(proto, elementSize, typicalElement) {
for (i = 0; i < 30; i++) {
assertSame(typicalElement, aFromArray[i]);
}
+
+ var abLen0 = new ArrayBuffer(0);
+ var aOverAbLen0 = new proto(abLen0);
+ assertSame(abLen0, aOverAbLen0.buffer);
+ assertSame(elementSize, aOverAbLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aOverAbLen0.length);
+ assertSame(0, aOverAbLen0.byteLength);
+ assertSame(0, aOverAbLen0.byteOffset);
}
TestTypedArray(Uint8Array, 1, 0xFF);
« no previous file with comments | « src/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698