function DataViewGetBuffer() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.buffer', this]);
}
return %DataViewGetBuffer(this);
function DataViewGetByteOffset() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.byteOffset', this]);
}
return %DataViewGetByteOffset(this);
function DataViewGetByteLength() {
if (!IS_DATAVIEW(this)) {
- throw MakeTypeError('incompatible_method_reciever',
+ throw MakeTypeError('incompatible_method_receiver',
['DataView.byteLength', this]);
}
return %DataViewGetByteLength(this);
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) {
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,
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) {
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,
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) {
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,
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) {
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,
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) {
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) {
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) {
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,
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) {
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,
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) {
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,
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");
}
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();