Revision: 11968
Author:   [email protected]
Date:     Mon Jul  2 06:09:47 2012
Log:      Added tests for calling typed array constructors as functions.

[email protected]
BUG=v8:1497
TEST=

Review URL: https://chromiumcodereview.appspot.com/10701055
http://code.google.com/p/v8/source/detail?r=11968

Modified:
 /branches/bleeding_edge/test/mjsunit/external-array.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/external-array.js Fri Jun 29 08:06:36 2012 +++ /branches/bleeding_edge/test/mjsunit/external-array.js Mon Jul 2 06:09:47 2012
@@ -540,3 +540,28 @@
 assertThrows(function(){ a.subarray.call({}, 0) });
 assertThrows(function(){ a.subarray.call([], 0) });
 assertThrows(function(){ a.subarray.call(a) });
+
+
+// Call constructors directly as functions, and through .call and .apply
+
+b = ArrayBuffer(100)
+a = Int8Array(b, 5, 77)
+assertInstance(b, ArrayBuffer)
+assertInstance(a, Int8Array)
+assertSame(b, a.buffer)
+assertEquals(5, a.byteOffset)
+assertEquals(77, a.byteLength)
+b = ArrayBuffer.call(null, 10)
+a = Uint16Array.call(null, b, 2, 4)
+assertInstance(b, ArrayBuffer)
+assertInstance(a, Uint16Array)
+assertSame(b, a.buffer)
+assertEquals(2, a.byteOffset)
+assertEquals(8, a.byteLength)
+b = ArrayBuffer.apply(null, [1000])
+a = Float32Array.apply(null, [b, 128, 1])
+assertInstance(b, ArrayBuffer)
+assertInstance(a, Float32Array)
+assertSame(b, a.buffer)
+assertEquals(128, a.byteOffset)
+assertEquals(4, a.byteLength)

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to