Add tests for DataView.prototype.setFloat64

This commit is contained in:
Leonardo Balter 2016-05-12 18:06:18 -04:00 committed by Mike Pennisi
parent da67e6b305
commit 1b64789ce0
20 changed files with 830 additions and 18 deletions

View File

@ -0,0 +1,62 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Throws a RangeError if numberIndex getIndex
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
4. Let numberIndex be ? ToNumber(requestIndex).
5. Let getIndex be ToInteger(numberIndex).
6. If numberIndex getIndex or getIndex < 0, throw a RangeError exception.
...
features: [DataView.prototype.getFloat64]
---*/
var buffer = new ArrayBuffer(12);
var sample = new DataView(buffer, 0);
assert.throws(RangeError, function() {
sample.setFloat64();
}, "no args");
assert.sameValue(sample.getFloat64(0), 0, "no args - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(undefined, 39);
}, "undefined");
assert.sameValue(sample.getFloat64(0), 0, "undefined - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(1.1, 39);
}, "floating number");
assert.sameValue(sample.getFloat64(0), 0, "floating number - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(0.1, 39);
}, "0.1");
assert.sameValue(sample.getFloat64(0), 0, "0.1 - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(NaN, 39);
}, "NaN");
assert.sameValue(sample.getFloat64(0), 0, "NaN - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(-0.1, 39);
}, "-0.1");
assert.sameValue(sample.getFloat64(0), 0, "-0.1 - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(-1.1, 39);
}, "-1.1");
assert.sameValue(sample.getFloat64(0), 0, "-1.1 - no value was set");

View File

@ -0,0 +1,37 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Throws a RangeError if getIndex < 0
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
4. Let numberIndex be ? ToNumber(requestIndex).
5. Let getIndex be ToInteger(numberIndex).
6. If numberIndex getIndex or getIndex < 0, throw a RangeError exception.
...
features: [DataView.prototype.getFloat64]
---*/
var buffer = new ArrayBuffer(12);
var sample = new DataView(buffer, 0);
assert.throws(RangeError, function() {
sample.setFloat64(-1, 39);
}, "-1");
assert.sameValue(sample.getFloat64(0), 0, "-1 - no value was set");
assert.throws(RangeError, function() {
sample.setFloat64(-Infinity, 39);
}, "-Infinity");
assert.sameValue(sample.getFloat64(0), 0, "-Infinity - no value was set");

View File

@ -0,0 +1,38 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Detached buffer is checked after checking If numberIndex getIndex or
getIndex < 0
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
6. If numberIndex getIndex or getIndex < 0, throw a RangeError exception.
...
9. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
10. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [detachArrayBuffer.js]
---*/
var buffer = new ArrayBuffer(12);
var sample = new DataView(buffer, 0);
$DETACHBUFFER(buffer);
assert.throws(RangeError, function() {
sample.setFloat64(1.1, 0);
});
assert.throws(RangeError, function() {
sample.setFloat64(-1, 0);
});

View File

@ -0,0 +1,39 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Detached buffer is checked after ToNumber(value)
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
7. Let numberValue be ? ToNumber(value).
...
9. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
10. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [detachArrayBuffer.js]
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var v = {
valueOf: function() {
throw new Test262Error();
}
};
$DETACHBUFFER(buffer);
assert.throws(Test262Error, function() {
sample.setFloat64(0, v);
});

View File

@ -0,0 +1,40 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Detached buffer is checked before out of range byteOffset's value
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
9. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
10. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
14. If getIndex + elementSize > viewSize, throw a RangeError exception.
...
includes: [detachArrayBuffer.js]
---*/
var sample;
var buffer = new ArrayBuffer(12);
sample = new DataView(buffer, 0);
$DETACHBUFFER(buffer);
assert.throws(TypeError, function() {
sample.setFloat64(Infinity, 0);
}, "Infinity");
assert.throws(TypeError, function() {
sample.setFloat64(13, 0);
}, "13");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Throws a TypeError if buffer is detached
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
9. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
10. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
...
includes: [detachArrayBuffer.js]
---*/
var buffer = new ArrayBuffer(1);
var sample = new DataView(buffer, 0);
$DETACHBUFFER(buffer);
assert.throws(TypeError, function() {
sample.setFloat64(0, 0);
});

View File

@ -4,25 +4,27 @@
/*---
esid: sec-dataview.prototype.setfloat64
description: >
Throws a RangeError if the index is negative or non-integral number.
RangeError exception for negative or non-integral index is thrown before
the value conversion.
info: >
...
3. Return SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
3. Let numberIndex be ToNumber(requestIndex).
4. Let getIndex be ? ToInteger(numberIndex).
5. If numberIndex getIndex or getIndex < 0, throw a RangeError exception.
6. Let numberValue be ? ToNumber(value).
...
...
4. Let numberIndex be ToNumber(requestIndex).
5. Let getIndex be ? ToInteger(numberIndex).
6. If numberIndex getIndex or getIndex < 0, throw a RangeError exception.
7. Let numberValue be ? ToNumber(value).
...
---*/
var dataView = new DataView(new ArrayBuffer(16));
var dataView = new DataView(new ArrayBuffer(16), 0);
var poisoned = {
valueOf: function() {
$ERROR("valueOf called");
throw new Test262Error("valueOf called");
}
};

View File

@ -0,0 +1,105 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Throws a RangeError if getIndex + elementSize > viewSize
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
11. Let viewOffset be the value of view's [[ByteOffset]] internal slot.
12. Let viewSize be the value of view's [[ByteLength]] internal slot.
13. Let elementSize be the Number value of the Element Size value specified in
Table 50 for Element Type type.
14. If getIndex + elementSize > viewSize, throw a RangeError exception.
...
features: [DataView.prototype.getFloat64]
---*/
var sample;
var buffer = new ArrayBuffer(12);
sample = new DataView(buffer, 0);
assert.throws(RangeError, function() {
sample.setFloat64(Infinity, 39);
}, "getIndex == Infinity");
assert.throws(RangeError, function() {
sample.setFloat64(13, 39);
}, "13 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(12, 39);
}, "12 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(11, 39);
}, "11 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(10, 39);
}, "10 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(9, 39);
}, "9 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(8, 39);
}, "8 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(7, 39);
}, "7 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(6, 39);
}, "6 + 8 > 12");
assert.throws(RangeError, function() {
sample.setFloat64(5, 39);
}, "5 + 8 > 12");
sample = new DataView(buffer, 8);
assert.throws(RangeError, function() {
sample.setFloat64(1, 39);
}, "1 + 8 > 4 (offset)");
sample = new DataView(buffer, 9);
assert.throws(RangeError, function() {
sample.setFloat64(0, 39);
}, "0 + 8 > 3 (offset)");
sample = new DataView(buffer, 0, 8);
assert.throws(RangeError, function() {
sample.setFloat64(1, 39);
}, "1 + 8 > 8 (length)");
sample = new DataView(buffer, 0, 7);
assert.throws(RangeError, function() {
sample.setFloat64(0, 39);
}, "0 + 8 > 7 (length)");
sample = new DataView(buffer, 4, 8);
assert.throws(RangeError, function() {
sample.setFloat64(1, 39);
}, "1 + 8 > 8 (offset+length)");
sample = new DataView(buffer, 4, 7);
assert.throws(RangeError, function() {
sample.setFloat64(0, 39);
}, "0 + 8 > 7 (offset+length)");
sample = new DataView(buffer, 0);
assert.sameValue(sample.getFloat64(0), 0, "[0] no value was set");
assert.sameValue(sample.getFloat64(4), 0, "[1] no value was set");

View File

@ -17,7 +17,7 @@ info: >
...
---*/
var dataView = new DataView(new ArrayBuffer(16));
var dataView = new DataView(new ArrayBuffer(16), 0);
dataView.setFloat64(+0, 1);
assert.sameValue(dataView.getFloat64(0), 1, "setFloat64(+0, 1)");

View File

@ -0,0 +1,47 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Set value as undefined (cast to NaN) when value argument is not present
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
15. Let bufferIndex be getIndex + viewOffset.
16. Return SetValueInBuffer(buffer, bufferIndex, type, numberValue, isLittleEndian).
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result of
converting value to IEEE 754-2008 binary32 format using Round to nearest,
ties to even rounding mode. If isLittleEndian is false, the bytes are
arranged in big endian order. Otherwise, the bytes are arranged in little
endian order. If value is NaN, rawValue may be set to any implementation
chosen IEEE 754-2008 binary32 format Not-a-Number encoding. An
implementation must always choose the same encoding for each implementation
distinguishable NaN value.
...
11. Store the individual bytes of rawBytes into block, in order, starting at
block[byteIndex].
12. Return NormalCompletion(undefined).
features: [DataView.prototype.getFloat64]
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var result = sample.setFloat64(0);
assert.sameValue(sample.getFloat64(0), NaN);
assert.sameValue(result, undefined);

View File

@ -22,28 +22,26 @@ info: >
...
---*/
var dataView = new DataView(new ArrayBuffer(8));
function DummyError() { }
var dataView = new DataView(new ArrayBuffer(8), 0);
var poisoned = {
valueOf: function() {
throw new DummyError();
throw new Test262Error();
}
};
assert.throws(DummyError, function() {
assert.throws(Test262Error, function() {
dataView.setFloat64(Infinity, poisoned);
}, "setFloat64(Infinity, poisoned)");
assert.throws(DummyError, function() {
assert.throws(Test262Error, function() {
dataView.setFloat64(100, poisoned);
}, "setFloat64(100, poisoned)");
assert.throws(DummyError, function() {
assert.throws(Test262Error, function() {
dataView.setFloat64('Infinity', poisoned);
}, "setFloat64('Infinity', poisoned)");
assert.throws(DummyError, function() {
assert.throws(Test262Error, function() {
dataView.setFloat64('100', poisoned);
}, "setFloat64('100', poisoned)");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Return abrupt from ToNumber(symbol byteOffset)
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
4. Let numberIndex be ? ToNumber(requestIndex).
...
features: [Symbol]
---*/
var buffer = new ArrayBuffer(1);
var sample = new DataView(buffer, 0);
var s = Symbol("1");
assert.throws(TypeError, function() {
sample.setFloat64(s, 1);
});

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Return abrupt from ToNumber(byteOffset)
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
4. Let numberIndex be ? ToNumber(requestIndex).
...
---*/
var buffer = new ArrayBuffer(1);
var sample = new DataView(buffer, 0);
var bo1 = {
valueOf: function() {
throw new Test262Error();
}
};
var bo2 = {
toString: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
sample.setFloat64(bo1, 1);
}, "valueOf");
assert.throws(Test262Error, function() {
sample.setFloat64(bo2, 1);
}, "toString");

View File

@ -0,0 +1,31 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Return abrupt from ToNumber(symbol value)
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
7. Let numberValue be ? ToNumber(value).
...
features: [Symbol]
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var s = Symbol("1");
assert.throws(TypeError, function() {
sample.setFloat64(0, s);
});

View File

@ -0,0 +1,44 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Return abrupt from ToNumber(value)
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
7. Let numberValue be ? ToNumber(value).
...
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var bo1 = {
valueOf: function() {
throw new Test262Error();
}
};
var bo2 = {
toString: function() {
throw new Test262Error();
}
};
assert.throws(Test262Error, function() {
sample.setFloat64(0, bo1);
}, "valueOf");
assert.throws(Test262Error, function() {
sample.setFloat64(0, bo2);
}, "toString");

View File

@ -0,0 +1,50 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Set values on little endian order
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
15. Let bufferIndex be getIndex + viewOffset.
16. Return SetValueInBuffer(buffer, bufferIndex, type, numberValue, isLittleEndian).
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , isLittleEndian ] )
...
9. Else if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE 754-2008
binary64 format encoding of value. If isLittleEndian is false, the bytes are
arranged in big endian order. Otherwise, the bytes are arranged in little
endian order. If value is NaN, rawValue may be set to any implementation
chosen IEEE 754-2008 binary64 format Not-a-Number encoding. An
implementation must always choose the same encoding for each implementation
distinguishable NaN value.
...
11. Store the individual bytes of rawBytes into block, in order, starting at
block[byteIndex].
12. Return NormalCompletion(undefined).
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var result;
result = sample.setFloat64(0, 42, true);
assert.sameValue(result, undefined, "returns undefined #1");
assert.sameValue(sample.getFloat64(0), 8.759e-320);
result = sample.setFloat64(0, 8.759e-320, true);
assert.sameValue(result, undefined, "returns undefined #2");
assert.sameValue(sample.getFloat64(0), 42);

View File

@ -0,0 +1,62 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Set values and return undefined
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
15. Let bufferIndex be getIndex + viewOffset.
16. Return SetValueInBuffer(buffer, bufferIndex, type, numberValue, isLittleEndian).
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , isLittleEndian ] )
...
8. If type is "Float32", then
a. Set rawBytes to a List containing the 4 bytes that are the result of
converting value to IEEE 754-2008 binary32 format using Round to nearest,
ties to even rounding mode. If isLittleEndian is false, the bytes are
arranged in big endian order. Otherwise, the bytes are arranged in little
endian order. If value is NaN, rawValue may be set to any implementation
chosen IEEE 754-2008 binary32 format Not-a-Number encoding. An
implementation must always choose the same encoding for each implementation
distinguishable NaN value.
...
11. Store the individual bytes of rawBytes into block, in order, starting at
block[byteIndex].
12. Return NormalCompletion(undefined).
includes: [byteConversionValues.js]
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
var values = byteConversionValues.values;
var expectedValues = byteConversionValues.expected.Float64;
values.forEach(function(value, i) {
var expected = expectedValues[i];
var result = sample.setFloat64(0, value, false);
assert.sameValue(
sample.getFloat64(0),
expected,
"value: " + value
);
assert.sameValue(
result,
undefined,
"return is undefined, value: " + value
);
});

View File

@ -0,0 +1,43 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Throws a TypeError if this does not have a [[DataView]] internal slot
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
1. If Type(view) is not Object, throw a TypeError exception.
2. If view does not have a [[DataView]] internal slot, throw a TypeError
exception.
...
features: [Int8Array]
---*/
var setFloat64 = DataView.prototype.setFloat64;
assert.throws(TypeError, function() {
setFloat64.call({});
}, "{}");
assert.throws(TypeError, function() {
setFloat64.call([]);
}, "[]");
var ab = new ArrayBuffer(1);
assert.throws(TypeError, function() {
setFloat64.call(ab);
}, "ArrayBuffer");
var ta = new Int8Array();
assert.throws(TypeError, function() {
setFloat64.call(ta);
}, "TypedArray");

View File

@ -0,0 +1,51 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: Throws a TypeError if this is not Object
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
1. If Type(view) is not Object, throw a TypeError exception.
...
features: [Symbol]
---*/
var setFloat64 = DataView.prototype.setFloat64;
assert.throws(TypeError, function() {
setFloat64.call(undefined);
}, "undefined");
assert.throws(TypeError, function() {
setFloat64.call(null);
}, "null");
assert.throws(TypeError, function() {
setFloat64.call(1);
}, "1");
assert.throws(TypeError, function() {
setFloat64.call("string");
}, "string");
assert.throws(TypeError, function() {
setFloat64.call(true);
}, "true");
assert.throws(TypeError, function() {
setFloat64.call(false);
}, "false");
var s = Symbol("1");
assert.throws(TypeError, function() {
setFloat64.call(s);
}, "symbol");

View File

@ -0,0 +1,57 @@
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-dataview.prototype.setfloat64
es6id: 24.2.4.14
description: >
Boolean littleEndian argument coerced in ToBoolean
info: |
24.2.4.14 DataView.prototype.setFloat64 ( byteOffset, value [ , littleEndian ] )
1. Let v be the this value.
2. If littleEndian is not present, let littleEndian be false.
3. Return ? SetViewValue(v, byteOffset, littleEndian, "Float64", value).
24.2.1.2 SetViewValue ( view, requestIndex, isLittleEndian, type, value )
...
15. Let bufferIndex be getIndex + viewOffset.
16. Return SetValueInBuffer(buffer, bufferIndex, type, numberValue, isLittleEndian).
24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , isLittleEndian ] )
...
9. Else if type is "Float64", then
a. Set rawBytes to a List containing the 8 bytes that are the IEEE 754-2008
binary64 format encoding of value. If isLittleEndian is false, the bytes are
arranged in big endian order. Otherwise, the bytes are arranged in little
endian order. [...]
...
features: [DataView.prototype.getFloat64, Symbol]
---*/
var buffer = new ArrayBuffer(8);
var sample = new DataView(buffer, 0);
// False
sample.setFloat64(0, 1);
assert.sameValue(sample.getFloat64(0), 1, "no arg");
sample.setFloat64(0, 2, undefined);
assert.sameValue(sample.getFloat64(0), 2, "undefined");
sample.setFloat64(0, 3, null);
assert.sameValue(sample.getFloat64(0), 3, "null");
sample.setFloat64(0, 4, 0);
assert.sameValue(sample.getFloat64(0), 4, "0");
sample.setFloat64(0, 5, "");
assert.sameValue(sample.getFloat64(0), 5, "the empty string");
// True
sample.setFloat64(0, 3.067e-320, {});
assert.sameValue(sample.getFloat64(0), 6, "{}");
sample.setFloat64(0, 3.573e-320, Symbol("1"));
assert.sameValue(sample.getFloat64(0), 7, "symbol");
sample.setFloat64(0, 4.079e-320, 1);
assert.sameValue(sample.getFloat64(0), 8, "1");
sample.setFloat64(0, 4.332e-320, "string");
assert.sameValue(sample.getFloat64(0), 9, "string");