Reviewers: Benedikt Meurer, rossberg,
Message:
Please take a look.
These are (very unfortunate) typos, basically.
Description:
Make DataView setters throw when only offset is provided.
Also fix typo in error message id.
[email protected],[email protected]
Please review this at https://codereview.chromium.org/20030004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/typedarray.js
M test/mjsunit/harmony/dataview-accessors.js
Index: src/typedarray.js
diff --git a/src/typedarray.js b/src/typedarray.js
index
601012d58ef07c15f446220f547605f5582b137e..d5357b4f2cbdbd3c656041754ac6ea0b863def16
100644
--- a/src/typedarray.js
+++ b/src/typedarray.js
@@ -237,7 +237,7 @@ function DataViewConstructor(buffer, byteOffset,
byteLength) { // length = 3
function DataViewGetBuffer() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.buffer', this]);
}
return %DataViewGetBuffer(this);
@@ -245,7 +245,7 @@ function DataViewGetBuffer() {
function DataViewGetByteOffset() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.byteOffset', this]);
}
return %DataViewGetByteOffset(this);
@@ -253,7 +253,7 @@ function DataViewGetByteOffset() {
function DataViewGetByteLength() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.byteLength', this]);
}
return %DataViewGetByteLength(this);
@@ -265,7 +265,7 @@ function ToPositiveDataViewOffset(offset) {
function DataViewGetInt8(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getInt8', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -278,10 +278,10 @@ function DataViewGetInt8(offset, little_endian) {
function DataViewSetInt8(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setInt8', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetInt8(this,
@@ -292,7 +292,7 @@ function DataViewSetInt8(offset, value, little_endian) {
function DataViewGetUint8(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getUint8', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -305,10 +305,10 @@ function DataViewGetUint8(offset, little_endian) {
function DataViewSetUint8(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setUint8', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetUint8(this,
@@ -319,7 +319,7 @@ function DataViewSetUint8(offset, value, little_endian)
{
function DataViewGetInt16(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getInt16', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -332,10 +332,10 @@ function DataViewGetInt16(offset, little_endian) {
function DataViewSetInt16(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setInt16', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetInt16(this,
@@ -346,7 +346,7 @@ function DataViewSetInt16(offset, value, little_endian)
{
function DataViewGetUint16(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getUint16', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -359,10 +359,10 @@ function DataViewGetUint16(offset, little_endian) {
function DataViewSetUint16(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setUint16', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetUint16(this,
@@ -373,7 +373,7 @@ function DataViewSetUint16(offset, value,
little_endian) {
function DataViewGetInt32(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getInt32', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -386,7 +386,7 @@ function DataViewGetInt32(offset, little_endian) {
function DataViewSetInt32(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setInt32', this]);
}
if (%_ArgumentsLength() < 2) {
@@ -400,7 +400,7 @@ function DataViewSetInt32(offset, value, little_endian)
{
function DataViewGetUint32(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getUint32', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -413,10 +413,10 @@ function DataViewGetUint32(offset, little_endian) {
function DataViewSetUint32(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setUint32', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetUint32(this,
@@ -427,7 +427,7 @@ function DataViewSetUint32(offset, value,
little_endian) {
function DataViewGetFloat32(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getFloat32', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -440,10 +440,10 @@ function DataViewGetFloat32(offset, little_endian) {
function DataViewSetFloat32(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setFloat32', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetFloat32(this,
@@ -454,7 +454,7 @@ function DataViewSetFloat32(offset, value,
little_endian) {
function DataViewGetFloat64(offset, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.getFloat64', this]);
}
if (%_ArgumentsLength() < 1) {
@@ -467,10 +467,10 @@ function DataViewGetFloat64(offset, little_endian) {
function DataViewSetFloat64(offset, value, little_endian) {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.setFloat64', this]);
}
- if (%_ArgumentsLength() < 1) {
+ if (%_ArgumentsLength() < 2) {
throw MakeTypeError('invalid_argument');
}
%DataViewSetFloat64(this,
Index: test/mjsunit/harmony/dataview-accessors.js
diff --git a/test/mjsunit/harmony/dataview-accessors.js
b/test/mjsunit/harmony/dataview-accessors.js
index
c57841c4941a69f4fb85595c61101712f7243f35..7b03da7089721235ce96a85d16afe7b6428513bf
100644
--- a/test/mjsunit/harmony/dataview-accessors.js
+++ b/test/mjsunit/harmony/dataview-accessors.js
@@ -389,6 +389,11 @@ function TestGeneralAccessors() {
f.call(a, 0, 0); // should not throw
assertThrows(function() { f.call({}, 0, 0); }, TypeError);
assertThrows(function() { f.call(a); }, TypeError);
+ if (name.indexOf("set") == 0) {
+ assertThrows(function() { f.call(a, 1); }, TypeError);
+ } else {
+ f.call(a, 1); // should not throw
+ }
}
CheckAccessor("getUint8");
CheckAccessor("setUint8");
@@ -409,3 +414,36 @@ function TestGeneralAccessors() {
}
TestGeneralAccessors();
+
+function TestInsufficientArguments() {
+ var a = new DataView(new ArrayBuffer(256));
+
+ assertThrows(function() { a.getUint8(); }, TypeError);
+ assertThrows(function() { a.getInt8(); }, TypeError);
+ assertThrows(function() { a.getUint16(); }, TypeError);
+ assertThrows(function() { a.getInt16(); }, TypeError);
+ assertThrows(function() { a.getUint32(); }, TypeError);
+ assertThrows(function() { a.getInt32(); }, TypeError);
+ assertThrows(function() { a.getFloat32(); }, TypeError);
+ assertThrows(function() { a.getFloat64(); }, TypeError);
+
+ assertThrows(function() { a.setUint8(); }, TypeError);
+ assertThrows(function() { a.setInt8(); }, TypeError);
+ assertThrows(function() { a.setUint16(); }, TypeError);
+ assertThrows(function() { a.setInt16(); }, TypeError);
+ assertThrows(function() { a.setUint32(); }, TypeError);
+ assertThrows(function() { a.setInt32(); }, TypeError);
+ assertThrows(function() { a.setFloat32(); }, TypeError);
+ assertThrows(function() { a.setFloat64(); }, TypeError);
+
+ assertThrows(function() { a.setUint8(1) }, TypeError);
+ assertThrows(function() { a.setInt8(1) }, TypeError);
+ assertThrows(function() { a.setUint16(1) }, TypeError);
+ assertThrows(function() { a.setInt16(1) }, TypeError);
+ assertThrows(function() { a.setUint32(1) }, TypeError);
+ assertThrows(function() { a.setInt32(1) }, TypeError);
+ assertThrows(function() { a.setFloat32(1) }, TypeError);
+ assertThrows(function() { a.setFloat64(1) }, TypeError);
+}
+
+TestInsufficientArguments();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.