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

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

Issue 14460008: TypedArray(length) constructor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added unit-tests for typed array length 0 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 418d55e3fb685281b316571556e4dd30ff07c833..2e0398526258b52b3540faeacc51f61a97a0c948 100644
--- a/test/mjsunit/harmony/typedarrays.js
+++ b/test/mjsunit/harmony/typedarrays.js
@@ -113,6 +113,27 @@ TestArrayBufferSlice();
function TestTypedArray(proto, elementSize, typicalElement) {
var ab = new ArrayBuffer(256*elementSize);
+ var a0 = new proto(30);
+ assertSame(elementSize, a0.BYTES_PER_ELEMENT);
+ assertSame(30, a0.length);
+ assertSame(30*elementSize, a0.byteLength);
+ assertSame(0, a0.byteOffset);
+ assertSame(30*elementSize, a0.buffer.byteLength);
+
+ var aLen0 = new proto(0);
+ assertSame(elementSize, aLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aLen0.length);
+ assertSame(0, aLen0.byteLength);
+ assertSame(0, aLen0.byteOffset);
+ assertSame(0, aLen0.buffer.byteLength);
+
+ var aOverBufferLen0 = new proto(ab, 128*elementSize, 0);
+ assertSame(ab, aOverBufferLen0.buffer);
+ assertSame(elementSize, aOverBufferLen0.BYTES_PER_ELEMENT);
+ assertSame(0, aOverBufferLen0.length);
+ assertSame(0, aOverBufferLen0.byteLength);
+ assertSame(128*elementSize, aOverBufferLen0.byteOffset);
+
var a1 = new proto(ab, 128*elementSize, 128);
assertSame(ab, a1.buffer);
assertSame(elementSize, a1.BYTES_PER_ELEMENT);
« 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