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

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

Issue 14650014: Add type checks to typed array property getters. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Without rebase 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 | « no previous file | 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 6448938a80071b15afc54ce42222a84666fa1c08..1e0147633f20616f30e6e6d9e04d57d58397c0d8 100644
--- a/test/mjsunit/harmony/typedarrays.js
+++ b/test/mjsunit/harmony/typedarrays.js
@@ -323,6 +323,7 @@ function TestTypedArrayOutOfRange(constructor, value, result) {
TestTypedArrayOutOfRange(Uint8Array, 0x1FA, 0xFA);
TestTypedArrayOutOfRange(Uint8Array, -1, 0xFF);
+
TestTypedArrayOutOfRange(Int8Array, 0x1FA, 0x7A - 0x80);
TestTypedArrayOutOfRange(Uint16Array, 0x1FFFA, 0xFFFA);
@@ -336,28 +337,38 @@ TestTypedArrayOutOfRange(Int32Array, 0x1FFFFFFFA, 0x7FFFFFFA - 0x80000000);
TestTypedArrayOutOfRange(Uint8ClampedArray, 0x1FA, 0xFF);
TestTypedArrayOutOfRange(Uint8ClampedArray, -1, 0);
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array]
function TestPropertyTypeChecks(constructor) {
- function CheckThrows(name) {
+ var a = new constructor();
+ function CheckProperty(name) {
var d = Object.getOwnPropertyDescriptor(constructor.prototype, name);
var o = {}
assertThrows(function() {d.get.call(o);}, TypeError);
+ d.get.call(a); // shouldn't throw
+ for (var i = 0 ; i < typedArrayConstructors.length; i++) {
+ d.get.call(new typedArrayConstructors[i](10));
+ }
}
- CheckThrows("buffer");
- CheckThrows("byteOffset");
- CheckThrows("byteLength");
- CheckThrows("length");
+ CheckProperty("buffer");
+ CheckProperty("byteOffset");
+ CheckProperty("byteLength");
+ CheckProperty("length");
+}
+
+for(i = 0; i < typedArrayConstructors.lenght; i++) {
+ TestPropertyTypeChecks(typedArrayConstructors[i]);
}
-TestPropertyTypeChecks(Uint8Array);
-TestPropertyTypeChecks(Int8Array);
-TestPropertyTypeChecks(Uint16Array);
-TestPropertyTypeChecks(Int16Array);
-TestPropertyTypeChecks(Uint32Array);
-TestPropertyTypeChecks(Int32Array);
-TestPropertyTypeChecks(Uint8ClampedArray);
-TestPropertyTypeChecks(Float32Array);
-TestPropertyTypeChecks(Float64Array);
// General tests for properties
@@ -374,14 +385,9 @@ function TestEnumerable(func, obj) {
assertArrayEquals([], props(obj));
}
TestEnumerable(ArrayBuffer, new ArrayBuffer());
-TestEnumerable(Uint8Array);
-TestEnumerable(Int8Array);
-TestEnumerable(Uint16Array);
-TestEnumerable(Int16Array);
-TestEnumerable(Uint32Array);
-TestEnumerable(Int32Array);
-TestEnumerable(Float32Array);
-TestEnumerable(Uint8ClampedArray);
+for(i = 0; i < typedArrayConstructors.lenght; i++) {
+ TestEnumerable(typedArrayConstructors[i]);
+}
// Test arbitrary properties on ArrayBuffer
function TestArbitrary(m) {
@@ -395,6 +401,11 @@ function TestArbitrary(m) {
}
}
TestArbitrary(new ArrayBuffer(256));
+for(i = 0; i < typedArrayConstructors.lenght; i++) {
+ TestArbitary(new typedArrayConstructors[i](10));
+}
+
+
// Test direct constructor call
assertTrue(ArrayBuffer() instanceof ArrayBuffer);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698